我的任务:
创建一个程序来复制图片(仅作为输入)使用基元(如三角形或其他东西).程序应使用进化算法来创建输出图像.
我的问题:
我需要发明一种算法来创建种群并检查它们(多少 - 以%为单位 - 它们与输入图像匹配).我有个主意; 你可以在下面找到它.
所以我想要你:建议(如果你发现我的想法不那么糟糕)或灵感(也许你有更好的主意?)
我的想法:
假设我将仅使用三角形来构建输出图片.
我的第一个人口是P图片(通过使用T随机生成的三角形生成 - 称为元素).
我通过我的健身功能检查每个人口中的图片,并选择他们的E作为精英,其余的人口只是删除:
To compare 2 pictures we check every pixel in picture A and compare his R,G,B with the same pixel (the same coordinates) in picture B. I use this: SingleDif = sqrt[ (Ar - Br)^2 + (Ag - Bg)^2 + (Ab - Bb)^2] then i sum all differences (from all pixels) - lets call it SumDif and use: PictureDif = (DifMax - SumDif)/DifMax where DifMax = pictureHeight * pictureWidth * 255*3
最好用于以这种方式创建下一个群体:
picture MakeChild(picture Mother, picture Father) { picture child; for( int i = 0; i < T; ++i ) { j //this is a random number from 0 to 1 - created now if( j < 0.5 ) child.element(i) = Mother.element(i); else child.element(i) = Father.element(i) if( j < some small % ) mutate( child.element(i) ); } return child; }
所以这很简单.只有突变才需要评论:因此,孩子中的元素X与父母中的X不同,总有一些小概率.为此,我们对子元素进行随机更改(通过随机数改变颜色,或将随机数添加到他的(x,y)坐标 - 或他的节点).
所以这是我的想法......我没有测试它,没有编码.请检查我的想法 - 你怎么看?