2019-03-19 09:14:19 +00:00
|
|
|
|
[[http://spacemacs.org][file:https://cdn.rawgit.com/syl20bnr/spacemacs/442d025779da2f62fc86c2082703697714db6514/assets/spacemacs-badge.svg]]
|
|
|
|
|
|
|
|
|
|
* Genetic image generation
|
|
|
|
|
|
|
|
|
|
This project is a university assignment that aims at regenerating a reference
|
|
|
|
|
image from random shapes of random color applied. There will be lots of
|
|
|
|
|
different tests on what method is the best and/or the fastest to get a new
|
|
|
|
|
image as close as possible to the reference image.
|
|
|
|
|
|
2019-03-19 13:19:27 +00:00
|
|
|
|
The first method will be the random addition of squares of random size to random
|
|
|
|
|
locations of random color. If the picture with the new random square improves in
|
|
|
|
|
similarity with the reference image, then it is preserved, otherwise the change
|
2019-03-19 16:32:41 +00:00
|
|
|
|
is discarded. This method is here as a reference for the other methods.
|
2019-03-19 13:19:27 +00:00
|
|
|
|
|
2019-03-19 16:32:41 +00:00
|
|
|
|
The second method will be the same as the first method, however The generation
|
|
|
|
|
of the new pictures will be multi-threaded; if two or more threads return an
|
|
|
|
|
improved picture, the best one will be selected. Then it will be reused by the
|
|
|
|
|
next threads.
|
|
|
|
|
|
|
|
|
|
The third method will instead delegate different parts of the picture to
|
2019-03-19 13:19:27 +00:00
|
|
|
|
different threads. For instance, if the software runs on four threads, the
|
|
|
|
|
reference picture will be divided in four zones, each one will be generated by a
|
|
|
|
|
separate thread.
|
|
|
|
|
|
2019-03-19 16:32:41 +00:00
|
|
|
|
The fourth method, which can be combined with the first three, will limit the
|
|
|
|
|
choice in terms of random color to the colors already existing in the reference
|
|
|
|
|
image.
|
2019-03-19 13:19:27 +00:00
|
|
|
|
|
2019-03-19 16:32:41 +00:00
|
|
|
|
The fifth method, which can be combined with the four first methods, will force
|
|
|
|
|
the random squares to be larger during the first iterations and progressively
|
|
|
|
|
smaller until the smallest specified size which should be reached by the last
|
|
|
|
|
iteration.
|
2019-03-19 13:19:27 +00:00
|
|
|
|
|
|
|
|
|
More methods will be added later once these four will be implemented.
|
|
|
|
|
|
|
|
|
|
* How to build this project
|
2019-03-19 09:14:19 +00:00
|
|
|
|
|
2019-03-19 10:01:39 +00:00
|
|
|
|
To build the project, you will also be required to install the development
|
2019-03-19 16:24:28 +00:00
|
|
|
|
libraries your distro offers for GTK+3. For Ubuntu, it is ~libgtk3-devel~, for
|
|
|
|
|
Void Linux it is ~gtk3-devel~ and for Arch Linux it is already bundled with the
|
|
|
|
|
~gtk3~ package.
|
2019-03-19 10:01:39 +00:00
|
|
|
|
|
|
|
|
|
You will also ned to have Ninja and Conan installed. To install Ninja, install
|
|
|
|
|
the appropriate package offered by your package manager (~ninja-build~ on
|
|
|
|
|
Debian, ~ninja~ on Arch Linux and Void Linux), and to install conan, use ~pip~.
|
|
|
|
|
#+begin_src shell
|
|
|
|
|
pip install --user conan
|
|
|
|
|
#+end_src
|
|
|
|
|
|
2019-03-19 09:14:19 +00:00
|
|
|
|
This project is built with conan, ninja and cmake using clang-7 for C++17. To
|
|
|
|
|
use it, first install clang-7 and lldb 7, then run this:
|
|
|
|
|
#+begin_src shell
|
|
|
|
|
conan profile new default --detect
|
|
|
|
|
conan profile update settings.compiler=clang default
|
|
|
|
|
conan profile update settings.compiler.version=7.0 default
|
2019-03-24 18:43:25 +00:00
|
|
|
|
conan profile update settings.compiler.libcxx=libstdc++11 default
|
2019-03-19 09:14:19 +00:00
|
|
|
|
conan profile update env.CC=/bin/clang default
|
|
|
|
|
conan profile update env.CXX=/bin/clang++ default
|
|
|
|
|
#+end_src
|
|
|
|
|
If you do not wish to overwrite your ~default~ profile, you can instead create a
|
|
|
|
|
new one, for instance ~clang~. To do so, write the name of your new profile (in
|
|
|
|
|
this example ~clang~) instead of ~default~ in the commands shown above.
|
|
|
|
|
|
|
|
|
|
Then, To build and run the program, go to the root of the project and run this:
|
|
|
|
|
#+begin_src shell
|
|
|
|
|
mkdir build && cd build
|
|
|
|
|
conan install .. --build missing
|
2019-03-24 18:43:25 +00:00
|
|
|
|
cmake -DCMAKE_CXX_COMPILER=clang++ .. -G Ninja
|
2019-03-19 09:14:19 +00:00
|
|
|
|
cmake --build .
|
|
|
|
|
#+end_src
|
|
|
|
|
If you want to use another profile than your default one, you should run the
|
|
|
|
|
following line instead of the second line:
|
|
|
|
|
#+begin_src shell
|
|
|
|
|
conan install .. --build missing --profile <your_profile>
|
|
|
|
|
#+end_src
|
2019-03-27 14:24:45 +00:00
|
|
|
|
If you wish to build the project’s tests in addition to the project itself, you
|
|
|
|
|
can add the option ~-DTESTS=True~ to the first ~cmake~ command to build the
|
|
|
|
|
project’s tests too.
|
|
|
|
|
#+begin_src shell
|
|
|
|
|
cmake -DCMAKE_CXX_COMPILER=clang++ -DTESTS=True .. -G Ninja
|
|
|
|
|
#+end_src
|
2019-03-19 09:14:19 +00:00
|
|
|
|
|
2019-03-24 18:43:25 +00:00
|
|
|
|
If you do not wish to build your project with Ninja but with another generator,
|
|
|
|
|
such as Unix Makefiles, simply replace ~Ninja~ in the second to last ~cmake~
|
|
|
|
|
command with the name of your generator. For instance:
|
|
|
|
|
#+begin_src shell
|
|
|
|
|
cmake -DCMAKE_CXX_COMPILER=clang++ .. -G "Unix Makefiles"
|
|
|
|
|
#+end_src
|
|
|
|
|
You can still build your project by running ~cmake --build .~ or by running
|
|
|
|
|
~make~ manually.
|
|
|
|
|
|
2019-03-19 09:14:19 +00:00
|
|
|
|
This project was built and tested using clang-7, lldb and gdb on Void Linux
|
|
|
|
|
(kernel 4.19) and Arch Linux (kernel 5.0).
|
|
|
|
|
|
|
|
|
|
* Credits
|
|
|
|
|
|
2019-03-19 13:19:27 +00:00
|
|
|
|
Awesome C++ Template by [[https://github.com/devkoriel/AwesomeCppTemplate][devkoriel]].
|