artificial life
Chapter 7: The Genetic Images Application
7.3 Representation
In order to be able to use Genetic Programming to create images it is necessary to devise a scheme in which function trees can be used to generate images. The structure of these trees is the same as the structure for the Symbolic Expression system illustrated in Chapter 6. The interior nodes are Unary or Binary Functions while the leaves are constants or variables controlled by the fitness evaluator. All trees for the Genetic Images resolve to a Red-Green-Blue triple that represents a color. The colors are clamped between (0,0,0) for black and (1,1,1) for white. Constants for the Genetic Images system are simply randomly generated RGB triples. The third square in Figure 7.2 shows an image produced by a Genetic Image tree comprised of only a constant.

Figure 7.2 : Terminal expressions in the Genetic Images
The other type of Terminal in the Genetic Images system
represents variables. The two variables used in the system are “X” and “Y”.
These variables correspond to the appropriate screen coordinates of the
Genetic Image. The first two squares of Figure 7.2 show the images resulting
from Genetic Image trees with only these variables placed in the tree.

Figure 7.3 : Unary operators in the Genetic Images
All of the interior nodes of the function tree are functions. Figure 7.3 illustrates four different unary functions. The unary functions available to the Genetic Images system are:
ABS, SIN, TAN, NEG, Sqrt, Log, ATAN, Invert, RGB_to_HSV, HSV_to_RGB, Shift_Left, Shift_Right, ~.
Most of these functions, such as SIN and Sqrt, are simply standard mathematical functions that add complexity to the images. Invert, RGB_to_HSV, and HSV_to_RGB are color operators. Invert inverts an RGB image while the other two unary functions convert the triples from a Red-Green-Blue color space to a Hue-Saturation-Value color space [Foley, 1997]. The ~ is a bit-wise-Not operator that operates on the underlying floating-point values. The value these functions operate on is the result of a single Genetic Images sub-tree.

Figure 7.4 : Binary Operators in the Genetic Images
Figure 7.4 shows some of the binary functions used in the Genetic Images. The binary functions available to the Genetic Images system are:
+,-,*,/,%, pow,>,<,max, min,&,|,^.
+,-,*,/,%, pow are all standard mathematical operators that add complexity to the system. <,> are “greater-than”/”less-than” operators that return a value of 1.0 or 0.0 depending upon which value is greater or less. These functions are good for creating hard lines. Max and min return the greater or lesser of the two given values. &,|,^ are logical bit-wise operators which operate on the underlying floating-point values, these operators tend to produce fractal type images such as that seen in the second square of Figure 7.4.