TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Mona Lisa in 50 polygons, using a genetic algorithm (2008)

209 点作者 liamk超过 12 年前

24 条评论

habosa超过 12 年前
Source code? I really, really want to try something like this but I've never done GP and I'm not sure where to start.<p>In lieue of the source code, can anyone point me to a reference on GP and maybe something about image generation in C? In particular, what's an efficient graphics pipeline for converting all of these polygons to pixels? Something like bresenham for the edges and then additive coloring in the middle? And then how do I convert an RGB pixel array into some reasonable image format? I apologize for my ignorance, I don't even know what to start googling.<p>I think it would be a good exercise for me to write something like this from scratch on my own, just want some pointers to start.
评论 #4913805 未加载
评论 #4913929 未加载
nemo1618超过 12 年前
Here's a similar algorithm you can play around with, implemented in Javascript + Canvas: <a href="http://alteredqualia.com/visualization/evolve/" rel="nofollow">http://alteredqualia.com/visualization/evolve/</a><p>HN post here: <a href="http://news.ycombinator.com/item?id=392036" rel="nofollow">http://news.ycombinator.com/item?id=392036</a>
akent超过 12 年前
Also of interest: MonaTweeta, using genetic algorithms to fit Mona Lisa into a 140 "character" tweet. <a href="http://www.flickr.com/photos/quasimondo/3518306770/" rel="nofollow">http://www.flickr.com/photos/quasimondo/3518306770/</a>
smanek超过 12 年前
I did something similar around 2008: (but in Lisp!): <a href="https://github.com/smanek/ga" rel="nofollow">https://github.com/smanek/ga</a><p>Had to write my own bitmap processing library, since couldn't find anything fast enough off the shelf :-D Handled alpha blending, file i/o, etc (checkout the bitmap.lisp and color.lisp files in the repo).<p>Here's a video of it 'evolving' a picture of John McCarthy (best individual from each generation): <a href="http://www.youtube.com/watch?v=-_VFZ_ON0A8" rel="nofollow">http://www.youtube.com/watch?v=-_VFZ_ON0A8</a><p>And here it is doing the Mona Lisa: <a href="http://www.youtube.com/watch?v=S1ZPSbImvFE" rel="nofollow">http://www.youtube.com/watch?v=S1ZPSbImvFE</a>
drallison超过 12 年前
It is not quite a genetic algorithm: there is no population of individuals s which get mated and possibly mutated. It's more of a dynamic programming polygon match. Still, the result is impressive and amusing.
评论 #4913597 未加载
评论 #4913363 未加载
RogerAlsing超过 12 年前
Roger Alsing the author of that old gimmic here :-)<p>Some clarifications from my part here, 4 years after the post was released:<p>1) No this does not qualify as a true GA/GP. by definition GP need to have an computational AST, EvoLisa has an declarative AST. There is also no cross over in play here. (see 3* for explatation on this)<p>2) Hill climbing or not? According to wikipedia, Hill climbing only changes _one_ value of the problem solving vector per generation. ""At each iteration, hill climbing will adjust a single element in X and determine whether the change improves the value of f(X)""<p>So it doesn't quite fit the hill climbing definition either, also the DNA/vector is of dynamic size in EvoLisa while Hill climbing AFAIK uses fixed size vectors (?)<p>3) Why wasn't a larger population used and why no cross over?<p>This is the part that most of you get wrong, increasing the population size and adding cross over will NOT benefit this specific problem.<p>The polygons are semi transparend and overlap, thus, adding/removing polygons will have a high impact on the fitness level, in pretty much every case in the wrong direction.<p>Let's use words as an example here:<p>organism1: "The Mona Lisa" organism2: "La Gioconda"<p>Both may have similar fitness level, but completely different sets of polygons (letters in this naive example)<p>combining those will very very rarely yeild an improvement.<p>e.g. child(result of org1 and org2) "Lae Mocondisa" that is complete nonsense and the fitness level falls back to pretty much random levels.<p>Thus, you can just as well use pure mutation instead of cross over here.<p>If the problem instead had been based on genes that paint individual parts, e.g. a gene for the face, a gene for the background, a gene for the body etc.<p>THEN it would have made sense to use crossover. In such case it would be possible to combine a good face gene with a good background gene and the fitness level would improve.<p>However, due to the nature of this specific problem where the polygons span the entire image, this is not effective.<p>And if crossover is not benefitial, then a larger population gets less interesting also since you cannot combine them.<p>Increasing the population will only make more separate individuals compete against eachother with no additative effect in any way.<p>see it like this.<p>If we have one sprinter running 100meters, if he might complete the run in about 10 sec.<p>If we add 1000 sprinters to the population, each of them might complete the run in about 10 sec each.<p>Thus, the problem is not solved any faster by adding more individuals here. Also, by increasing the population size, there will be much more data to evaluate for each generation, so even if we can bring down the number of generations needed to solve the problem, the actual real world time to complete it would increase due to evaluation logic.<p>Anyway, nice to see that people still find this somewhat interesting. It was pretty much a single evening hack back 4 years ago..<p>//Roger
评论 #4914903 未加载
评论 #4915784 未加载
评论 #4915842 未加载
mattdw超过 12 年前
To add to the cacophony of "I built one of these too!", here's mine:<p><a href="http://mattdw.github.com/experiments/image-evo/" rel="nofollow">http://mattdw.github.com/experiments/image-evo/</a><p>It's more strictly a genetic algorithm than the OP, too, as it's mutating a population, and instances age and eventually die.
gregschlom超过 12 年前
Only 50 semi transparent polygons? I would have thought a lot more would have been needed.<p>Also worth checking out, the gallery with more paintings: <a href="http://rogeralsing.com/2008/12/11/genetic-gallery/" rel="nofollow">http://rogeralsing.com/2008/12/11/genetic-gallery/</a>
评论 #4914735 未加载
评论 #4915115 未加载
RBerenguel超过 12 年前
I wrote my own a long time ago in C (inspired by Roger) to create a Christmas postcard: <a href="http://www.mostlymaths.net/2010/04/approximating-images-with-randomly.html" rel="nofollow">http://www.mostlymaths.net/2010/04/approximating-images-with...</a>
评论 #4913455 未加载
conroe64超过 12 年前
I wonder if this could be used to create a 3D sculpture using semi-reflective film, which if you looked at from a certain angle with light coming from a certain angle, you could recreate the image.
abuzzooz超过 12 年前
Not to be outdone, I wrote my own genetic algorithm in Perl to do the same. It starts from randomly generated triangles, and evolves them to match the given image.<p>Here is the result of my first trial after 5000 generations:<p><a href="http://imgur.com/L9Odx" rel="nofollow">http://imgur.com/L9Odx</a><p>For this run, I used 50 triangles, each at 50% alpha (fixed), a GA population size of 200, a crossover rate of 0.91 and a mutation rate of 0.01. It took around 12 hours to run, but that's mainly because I opted to do it in Perl and didn't spend any time optimizing it.
sdoering超过 12 年前
Given, that it took more than 900k generations, I couldn't help but think, that this means, it would take way more then 22 million years in human evolution.<p>A human generation is said to be round about 25 years.<p>;-)
Lerc超过 12 年前
Since this has popped up again I might as well point to where I took this. <a href="http://screamingduck.com/Article.php?ArticleID=46&#38;Show=ABCE" rel="nofollow">http://screamingduck.com/Article.php?ArticleID=46&#38;Show=A...</a><p>And some reconstructions from data. <a href="http://screamingduck.com/Lerc/showit.html" rel="nofollow">http://screamingduck.com/Lerc/showit.html</a> <a href="http://screamingduck.com/Lerc/showit2.html" rel="nofollow">http://screamingduck.com/Lerc/showit2.html</a>
montecarl超过 12 年前
The goal here to use polygons (a set of 2d points, a color, and opacity) to best reproduce the original image.<p>A given number of n-sided polygons represent a choice of basis set. This can be viewed as an optimization problem, where you try to minimize the difference between the rendered polygon image and the original image.<p>I wonder if this basis set is ideal? That is, is there a basis set you can choose, that represents the original image equally well, but uses less information?<p>Each n-sided polygon uses 2n+4 numbers (2n for the points and 4 for the color (RGB) and opacity). What is the ideal number of points in the polygon basis?<p>One could imaging using a set of orthogonal functions to represent the image. Coming up with a good set that isn't overfit to a training set might be a challenge. Perhaps one can make use of features of the human eye to come up with a good basis (maybe similar how MP3 does this for audio).
评论 #4913518 未加载
评论 #4913557 未加载
oboizt超过 12 年前
I read these things and wish so desperately that I was this creative. Mind. Blown.
评论 #4913295 未加载
评论 #4913285 未加载
acd超过 12 年前
NASA has used genetic programming to make more efficient antennas. But would it be possible to use Genetic algorithms to produce more efficient aircraft wings? And how about more difficult problems like CPU design, say that you want a 3d stackable cpu consisting of different layers and cooling but you let the computer design it itself. How about using it to construct more efficient solar cells and wind turbines. Is that possible? How do you make it general enough so the constraints does not constrain the possible solutions to much?
评论 #4917785 未加载
calinet6超过 12 年前
Holy crap this would make a good image compression algorithm. Might be complex to encode, but super small and efficient to decode.<p>Can we have this, please? Someone?
评论 #4914740 未加载
评论 #4916907 未加载
wangweij超过 12 年前
Is there a limit on the number of vertices for each polygon? If no, I think there is always a way to emulate anything with a single polygon.<p>Edit: albeit the colors.
评论 #4913814 未加载
Ives超过 12 年前
From the looks of it the average polygon in the system has about 6 vertices, so at 4 bytes a vertex and 4 bytes for RGBA color that's a total of 28 bytes per poly or 1400 bytes total.<p>And that's overestimating vertex positioning (at that size, 1 or maybe 2 bytes would suffice). Encoding an image like that would be very slow though.
yesbabyyes超过 12 年前
Original discussion:<p><a href="https://news.ycombinator.com/item?id=389727" rel="nofollow">https://news.ycombinator.com/item?id=389727</a><p>Discussion about bd's javascript reimplementation:<p><a href="https://news.ycombinator.com/item?id=392036" rel="nofollow">https://news.ycombinator.com/item?id=392036</a>
smoyer超过 12 年前
My favorite is 005456 ... it's obvious that it's her if you look at it but still abstract.
prezjordan超过 12 年前
How do you determine how similar two images are?
评论 #4913553 未加载
评论 #4913574 未加载
评论 #4913550 未加载
admiralpumpkin超过 12 年前
How about an iOS (and Android) app that does this for any selected picture?
piyush_soni超过 12 年前
This is cool !:)