private double fitness(final PolygonChromosome chromosome) {
		final BufferedImage img = _workingImage.get();
		final Graphics2D g2 = img.createGraphics();
		final int width = img.getWidth();
		final int height = img.getHeight();

		chromosome.draw(g2, width, height);
		g2.dispose();

		final int[] testPixels = img.getData()
			.getPixels(0, 0, width, height, (int[])null);

		int diff = 0;
		int p = width*height*4 - 1; // 4 channels: rgba
		int idx = 0;
		do {
			if (idx++%4 != 0) { // ignore the alpha channel for fitness
				int dp = testPixels[p] - _refImagePixels[p];
				diff += (dp < 0) ? -dp : dp;
			}
		} while (--p > 0);

		return 1.0 - diff/(double)(width*height*3*256);
	}
Calculate the fitness function for a Polygon chromosome.
<p>
For this purpose, we first draw the polygons on the test buffer,  and
then compare the resulting image pixel by pixel with the  reference image.
jenetics.example/src/main/java/io/jenetics/example/image/EvolvingImagesWorker.java