## Smarter Colors

Gradient mapping can produce nice results, but I got to wondering if there was another way. Perhaps there is a way for a strange attractor to produce it’s own color scheme. As there are often many intricate and overlapping elements in these images, I needed some unique characteristic that will identify these separate elements and Â decide their color.

The strange attractors are generated by a single point jumping around the place according to a set of formulas:

It occurs that if the (x, y) position of any given point in the strange attractor is determined by its “parent” point — the (x, y) values that are passed into the *f* and *g* formulas.

So, one unique characteristic of any given point in a strange attractor is the location of its parent point. This is the idea I used to colorize these new images.

Take a look at this snippet of Python code and you will see how the color of the next pixel is calculated *before* the new *x* and *y* values are calculated:

# determine the color of the next pixel based on current x position color = hsv_to_rgb(x+trap_size, .8, 1) # calculate the new x, y based on the old x, y x, y = (a*(x**2) + b*x*y + c*(y**2) + d*x + e*y + f, g*(x**2) + h*x*y + i*(y**2) + j*x + k*y + l) # translate floats, x, y into array indices px = int((x+trap_size)*(size/(trap_size*2))) py = int((y+trap_size)*(size/(trap_size*2))) # add some colour to the corresponding pixel img_array[px, py, :] += np.array(color)

This code uses a useful module from the Python standard library, colorsys, which provides functions for converting between color models.

This method achieved the goal of applying different colors to distinct overlapping elements. This a a feat which cannot be achieve by mapping a gradient to a greyscale image.

Here a few more images which demonstrate this effect (click to enlarge):