Evolve
An iOS app that takes an input image and generates an abstract piece of art through an evolutionary algorithm.
Jun 2019Introduction
During the third year of my university experience I was tasked with a final year project. I chose to develop a mobile application that could generate an artistic rendering from an input image. It would do this by using an evolutionary algorithm inspired by Roger Johansson that uses evolutionary methods to mutate shapes to generate a piece of art.
The Algorithm
The algorithm I have created takes an input image and without human interaction places shapes on a canvas before continuously mutating them with only successful changes carried over, this results in a render that improves gradually over time. The outline of the algorithm is shown below.
- Generate random shapes.
- Mutate shapes.
- Find fitness of new shapes.
- Overwrite shapes if new fitness is lower than previous.
- Repeat from step 2.
I have designed the system to be modular and there is little code duplication. The way I achieved this was to separate any classes not directly relating to the application views. This created independence for the algorithm and therefore allowed it to not only be used with just one application, but could be extracted and used in multiple applications as long as the correct methods were implemented.
The two classes are the Evolve class and the EvolveViewController class. First an evolve class is created within the EvolveViewController, then the delegate for the evolve class is set as the evolve view controller class, at this point both classes have references to each other which means that they can both communicate by calling each-others methods. The benefit of structuring the program like this is that the Evolve class is completely independent so as long as a controller implements the ModelDelegate it can make use of the algorithm contained within the Evolve class.
The Application
I have heavily focused on design in order to produce applications that users will find easy to use and intuitive. After all an app is useless if nobody wants to use it. Before designing the app I first read through Apples own Human Interface Guidelines, these are documents that provide recommendations on how to design and develop an application on any of its platforms. The aim is to create a consistent platform for its users, by following these rules the application I create will be intuitive and persistent to the user.
When designing for the apple ecosystem there are several key points that differentiate it from other platforms. They themselves list these reasons in their Human Interface Guidelines, the first being clarity, throughout the application text should be legible to read at any size, icons precise and design aspects should subtly highlight important content and convey interactivity. The next theme is deference, the interface should have fluid motion and a crisp beautiful interface and help people understand and interact with content while never competing with it. Finally depth, distinct visual layers and realistic motion convey hierarchy and contribute to the intuitive understanding a user can have with the app. I will take all of these themes into account when designing my application to create a dependable application that aligns with the design practices that apple have laid out.
In addition to these key themes I also used reliable design principles that will ensure my application is enjoyable to use and functional for the user. The most important principle with my app is user control. As my app will require large amounts of CPU processing power it is important that the user is still able to use the app whilst this intensive task is taking place, additionally I will give the user controls to modify the work done by the algorithm, allowing user to cancel or restart specific actions within the app. Another principle is that I will enforce is consistency, I will achieve this by using familiar standards and display well known icons, iOS standards text styles and by incorporating features an behaviours in the way that people expect.
Results
In regards to the algorithm that generates the shapes it works well and generates a decent looking image within 5 minutes however to create a satisfyingly detailed image it takes around 10 minutes which is something that could possibly be improved. Below are the images that were generated with the algorithm. which clearly resemble their original images, they each took 10 000 generations before I stopped them, if I had let them go on for longer they would be slightly more detailed but only slightly as the fitness increase becomes quite stale at around this iteration level. The algorithm not only generates polygon based artworks but also can generate renders using rectangles and circles, however I have not spent as much time refining this process so it does not work as well as the polygons however as you can see in the images below decent results have been produced.