
Image rendering with polygons
During my masters, I took a course called Physics of Algorithms – this is largely where I developed an interest in nature inspired algorithms. For my exam, I worked on an algorithm that could render images using polygons. This is not an original idea – Roger Johansson was one of the first to do this back in 2008. However at the time, I had not come across existing versions that would successfully run in Python 2.7 or 3.6, and the original program was written in .NET 2.0/VS.NET 2008. I therefore decided to recreate his project in Python for my final report, which you can take a look at here (all code for the program is included in the report – I will not reproduce it in this post).
If you don’t already know what a genetic algorithm is, I advise you to take a look at this post before reading on.
Details of the original program
Johansson does not reveal much about the parameter settings in his original program – and I didn’t understand the available source code binaries. I also didn’t have much interest in simply replicating his original code, i instead used the immediately available information as a guideline for my own implementation:
- The image consists of 50 semitransparent polygons
- Population size was only 2: a “current” candidate, and a mutation of the current candidate
- It took 3 hours to obtain the following result


With a population of only 2, it is arguable that Johansson does not truly employ the principles behind genetic programming and is rather solving the problem using hill climbing. This discussion isn’t relevant right now, but I acknowledge that we might not entirely be employing genetic programming.
Genetic programming is a metaheuristic that revolves around the propagation and modification of genetic material over time. Here, the genetic material should obviously be some string or array which describes the polygons
Performance of my solution
I’ll let you know straight away that I never managed to produce as impressive results as Johansson, but I did obtain recognisable results. In the following are a couple of comments on what affects the final solution. The main issue in this project was the time it took to to produce images – my program never performed at the speed of Johansson’s, and I never obtained images
Size matters
In the developing phase, the target picture of Mona Lisa was 800×1192 px, and it took >10 seconds to produce 10 images. Using a smaller version at just 270×402 px significantly improved the speed so that 10 images were produced in <10 seconds. I finally decided to use a small cut out of Mona Lisa of just 150×184 px.

Triangles or polygons?
I personally couldn’t prove that it was beneficial to use triangles over polygons. It seemed to depend more on the parameter settings than some intrinsic quality, one shape should possess more than the other. All test were therefore performed in order to compare – take a look for yourself below and see what you think.
Initial test performance
The initial runs tested the performance after 10,000 iterations just to see if there was promising convergence towards the target picture.
Using either 50 triangles or 50 polygons and a mutation rate of 5%, the program converged to two pictures showing resemblance to the most predominant characteristics of the target picture (the chest area, the background, and the general face and hair traits, although not with impressive detail. These runs took about 50 minutes each on the computer I used.
50 polygons 5% mutation rate 10,000 iterations


Mutation rate and number of polygons
I realised quickly that my solutions stopped progressing much after a “short” while. To overcome this within my time frame, I tried to change both the number of polygons, and the mutation rate, but never ended up settling on anything. To begin with, the solutions for 50 polygons had not progressed much at 65,000 iterations:
50 polygons 5% mutation rate 65,000 iterations


However, it quickly seemed to be a general problem.
50 polygons 3.5% mutation rate 100,000 iterations


50 polygons 3.5% mutation rate 240,000 iterations


Should we use more polygons?
100 polygons 3.5% mutation rate 120,000 iterations


Maybe even more?? This is actually the closest I managed to get to the target picture within the time frame.
300 polygons 5% mutation rate 100,000 iterations


300 polygons 5% mutation rate 400,000 iterations



29 Comments
ปั๊มไลค์
Like!! Thank you for publishing this awesome article.
กรองหน้ากากอนามัย
Thank you ever so for you article post.
erotik izle
Having read this I believed it was really enlightening. Annabal Iain Kimberli
sikis izle
Because the admin of this web page is working, no uncertainty very shortly it will be well-known, due to its feature contents. Pier Gage Firman
erotik
Some genuinely fantastic content on this site, appreciate it for contribution. Kara Julian Tyrone
erotik film izle
Im grateful for the blog post. Thanks Again. Really Cool. Celene Hubert Laidlaw
maseczki na twarz
I’m extremely pleased to discover this website. I wanted to thank you for ones time just for this fantastic read!! I definitely enjoyed every part of it and i also have you bookmarked to see new stuff in your site.
cialis online
VIA Gras Golden Makeup I didn’t understand LIVE.Patients should be advised to discontinue sildenafil therapy in case of sudden loss of vision and to consult a doctor immediately.Whilst alcohol may help any anxiety or shyness, there is evidence to suggest that it helps arousal too.The differences are symbolic and are made by manufacturers in order not to pay for the patent.The PDE-5 inhibitors do not have any psychological or neurological effect.
maseczki z filtrem
I’m extremely pleased to discover this website. I wanted to thank you for ones time just for this fantastic read!! I absolutely enjoyed every part of it and i also have you bookmarked to see new stuff in your site.
brand cialis
Definitely, what a great blog and revealing posts, I definitely will bookmark your site. Best Regards!
pożyczki online
I got what you intend,bookmarked, very decent website.
auto locksmiths near me
I am incessantly thought about this, thanks for posting.
chwilówki
I reckon something truly special in this website.
renault clio key fob
Some really great info, Gladiola I detected this. I’m not spaming. I’m just saying your website is AWSOME! Thank you so much! Please vist also my website.
sang lattimer
I randomly stopped by your site but you are really successful
estetika
Do you want to hit the jackpot in your SEO efforts? this online marketing offer is for you. I offer you the most advance and safe link building method thrive to your site top SERPS and traffic to your Website or Video.
yolanda depaolo
You have a quality site, I congratulate you on this
cbd for sale
Needed to write you this very small word to help thank you very much yet again with your wonderful views you have shown on this website. This is so wonderfully open-handed with you to supply without restraint what exactly some people would have supplied for an electronic book to make some profit on their own, specifically since you might well have tried it in the event you wanted. Those tricks likewise worked to provide a great way to understand that the rest have the same zeal the same as my very own to understand whole lot more with respect to this problem. I think there are thousands of more pleasurable times up front for those who view your website.
remeron online
My husband and i felt now fortunate Emmanuel could conclude his investigation from your ideas he gained in your site. It’s not at all simplistic just to choose to be giving for free information that most people have been making money from. And we all do understand we have the website owner to be grateful to because of that. The explanations you’ve made, the easy site menu, the friendships you can give support to engender – it’s everything extraordinary, and it’s facilitating our son and our family feel that that idea is enjoyable, and that is highly important. Many thanks for all the pieces!
kova
kovaci baba geldi
dolandirici
dolandirici thank you.
dolandirici
dolandirici thank you.
emre
emremisin nesin paramı geri ver
superbeets review
Ahaa, its nice dialogue about this post here at this weblog, I have read all that, so now me also commenting at this place.|
longchamp outlet
I wish to express some appreciation to this writer just for rescuing me from this type of setting. Just after looking out through the internet and obtaining ways that were not productive, I thought my entire life was well over. Existing devoid of the strategies to the issues you have solved by means of this article content is a crucial case, and those that might have adversely damaged my entire career if I had not come across your blog post. Your actual natural talent and kindness in dealing with the whole lot was excellent. I’m not sure what I would have done if I hadn’t discovered such a stuff like this. It’s possible to at this time look forward to my future. Thank you so much for the impressive and effective guide. I won’t hesitate to recommend your blog to any individual who ought to have guide about this subject.
off white hoodie
I’m writing to make you understand what a superb experience my cousin’s girl experienced checking your site. She mastered such a lot of issues, which included what it is like to have an incredible teaching mood to make others without problems completely grasp several grueling subject matter. You truly surpassed our expectations. Thanks for giving those powerful, safe, revealing and even unique guidance on your topic to Jane.
kawhi leonard shoes
My spouse and i have been so excited Jordan could do his homework through the entire ideas he received while using the weblog. It’s not at all simplistic just to find yourself giving freely steps which people may have been making money from. So we recognize we need the website owner to appreciate because of that. The most important illustrations you’ve made, the simple blog menu, the friendships you can help engender – it’s mostly fantastic, and it’s really assisting our son and us recognize that this idea is interesting, and that’s wonderfully important. Thanks for everything!
yeezy
I not to mention my buddies appeared to be going through the nice points on the website then immediately developed an awful feeling I had not expressed respect to the blog owner for those techniques. Most of the boys happened to be totally stimulated to read through all of them and already have without a doubt been loving those things. Thank you for being really kind as well as for using certain essential subject matter most people are really desperate to be aware of. Our honest regret for not expressing gratitude to sooner.
yeezy boost 350 v2
Thank you for your entire hard work on this website. My aunt really loves doing research and it’s really obvious why. My partner and i learn all of the dynamic ways you create advantageous tips via the web site and in addition recommend participation from some others on that subject then our favorite girl has been discovering a lot. Have fun with the remaining portion of the year. Your conducting a stunning job.