Git Product home page Git Product logo

geneticdrawing's Introduction

About

GeneticDrawing is a programme which uses a genetic/hill-climbing algorithm to draw a continually evolving copy of a source image, using a set number of polygons containing 3 or more points.

The process is as follows :

  1. Setup a random DNA string (application start).

  2. Copy the current DNA sequence and mutate it slightly.

  3. Use the new DNA to render polygons onto a canvas.

  4. Compare the canvas to the source image.

  5. If the new painting looks more like the source image than the previous painting did, then overwrite the current DNA with the new DNA.

  6. repeat from 1.

==============

The core classes are:

  1. GeneticAlgo.java, which contains the method which preforms the above steps.

  2. DNAString.java, which encapsulates a "solution". i.e a number of 'genes'

  3. Gene.java, a gene encapsulates a polygon in the following format: Red Green Blue Alpha Xcoordinates... Ycoordinates..

  4. FitnessCalculator.java, the fitness calculator gives a fitness rating, based on how simillar an image is to the calculators source image.

==============

Screenshots:

The app: http://oi57.tinypic.com/a0xobk.jpg

Firefox logo (50 polygons, 6 points) after ~300k candidate solutions: http://oi62.tinypic.com/2djuyhd.jpg

Mona Lisa (50 polygons, 3 points) after ~50k candidate solutions: http://oi58.tinypic.com/nq1mwz.jpg

==============

There is an option to export an SVG of the generated drawing File -> Export. You can change the number of polygons, points in the polygons, and the initial color of the DNA under Settings.

This programme is an implementation of Roger Alsings original idea: http://rogeralsing.com/2008/12/07/genetic-programming-evolution-of-mona-lisa/

geneticdrawing's People

Contributors

rjzflynn avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.