What is this plot/pattern called, generated by multiplying the x, y coordinates to a pixel value? What is the math behind it?

44 Views Asked by At

In a computer, a color is often represented as a triple or red (R), green (G), and blue (B) values ranging from 0 to 255, where $(0, 0, 0)$ is black and $(255, 255, 255)$ is white. 255 is 11111111 in binary, consuming 8 bits, so 24 contiguous bits can represent all colors of this triple. It's often written in hexadecimal because ff, having two of the largest hexadecimal digit, equals 255 in decimal, so you can simply write ffffff to represent $(255, 255, 255)$.

One common way to order the colors is that the lowest 8 bits represent blue, and the highest 8 bits represent red. Thus, ff will be the bluest color and ff0000 will be the reddest color.

Each pixel on a 2-dimensional image has a coordinate value. Usually, the pixel at the upper-left corner has $(0, 0)$, and the pixel at the lower-right corner has $(width - 1, height - 1)$. Note that this is different from the mathematical convention.

With a coordinate $(x, y)$, we can simply multiply $xy$ and use the product as the color value of the pixel at the point.

For example, with $(x, y) = (1234, 5678)$, $xy = 1234 \times 5678 = 7006652$, which is 6ae9bc in hexadecimal. By assigning this to the value of the pixel, 6a will represent red, e9 for green, and bc for blue. In decimal, this is $(106, 233, 188)$, and in actual color, it's some greenish color.

When the product doesn't fit in six hexadecimal digits, the upper digits are thrown away truncating the number to six digits.

The explanation was quite long, but in actual code, it's basically, pixel = (x + t) * (y + t), where t is a constant value added to explore various ranges.

Here are some actual plots of 512x512 images with varying $t$ values.

$t = 0$

0

$t = 3840$

3840

$t = 7936$

7936

$t = 16128$

16128

$t = 32512$

32512

$t = 65280$

65280


A very small difference in $t$ as little as 0.1 can make a big difference.

$t = 43392$

43392

$t = 43392.1$

43392.1

Is there a name for these patterns? I'd like to know any theory or explanation behind those interestingly looking curves and colors.

This is the C/OpenGL program I used to generate those images.