def get_fitness( self ):
     if ( self._fitness != -1 ):
         return self._fitness
     else:
         GeneticCode.surface.fill( (0,0,0) ) 
         self.draw_onto_surface( GeneticCode.surface )
         pixelArray = convertToPixelArray( GeneticCode.surface )
         euclideanDist = euclideanDistance( pixelArray , IMG_PIXEL_ARRAY )
         self._fitness = -(log10( euclideanDist ) - log10(norm( pixelArray ) + IMG_PIXEL_ARRAY_NORM ) )
         return self._fitness
Beispiel #2
0
 def get_fitness(self):
     if (self._fitness != -1):
         return self._fitness
     else:
         GeneticCode.surface.fill((0, 0, 0))
         self.draw_onto_surface(GeneticCode.surface)
         pixelArray = convertToPixelArray(GeneticCode.surface)
         euclideanDist = euclideanDistance(pixelArray, IMG_PIXEL_ARRAY)
         self._fitness = -(log10(euclideanDist) -
                           log10(norm(pixelArray) + IMG_PIXEL_ARRAY_NORM))
         return self._fitness
Beispiel #3
0
'''
Created on Sep 12, 2015

@author: mjchao
'''
import pygame
from Utils import convertToPixelArray, norm

#list of global parameter constants


P = 100
N = 1
K = 1
T = 500000
E = 500000

#---Change when image changes---#
IMG = pygame.image.load( "../html/mona_lisa.bmp" )
OUTPUT_DIR = "tmp"
IMG_WIDTH = 32
IMG_HEIGHT = 32
#--------------------------#

IMG_PIXEL_ARRAY = convertToPixelArray( IMG )
IMG_PIXEL_ARRAY_NORM = norm( IMG_PIXEL_ARRAY )