Quasiperiodic and periodic kaleidoscopes from higher dimensional space

To get quasi-periodic and periodic designs in the two-dimensional plane we first make a periodic decoration of higher dimensional space. Then we cut an infinitely thin two-dimensional slice out of this space. This gives a design with rotational symmetry if we use particular orientations and positions for making the slice. There is some relation to the projection method for creating quasi-periodic tilings, but this method is much easier to use.

Let’s begin with a p-dimensional space. To avoid confusion I am using Greek letters for its vectors and components:

We have the usual vector product for p-dimensional space:

For vectors in the two-dimensional plane of the resulting image I am using Latin letters.

The periodic decoration of the p-dimensional space results from a mapping to the two-dimensional space of the input image. Its X-component is a Fourier series

where the A with integer indices k are complex coefficients. We can write a p-dimensional wavevector of integers

and simplify the equation for X

Obviously, the Y-component of the mapping is essentially the same

Both X and Y have real values and thus their coefficients for opposed wavevectors are complex conjugates

and similarly for the B’s.

We now place the plane of the output image in the p-dimensional space. A point with output coordinates (x,y) has in the full p-dimensional space the coordinates

are vectors of the p-dimensional space. The mapping to the input image gives

which we can reorder to

We then define new vectors in the output plane

where h=1, 2, … , p. Thus



We rewrite this to use real valued coefficients and functions. Thus


Similarly we get


The coefficients a, b, c, d and the vectors e together with the input image make the output image and its symmetries. There are many different choices, which I will discuss in following posts.



Posted in Anamorphosis, Kaleidoscopes, Quasiperiodic design, Tilings | Tagged , | Leave a comment

Changing the hue

It has been easy to find special color transformations for 2- and 3-color symmetries. For other color symmetries I use a rather general color transformation that changes the hue.

First, we separate the pixel color in a grey part and a pure color part. The grey part is given by the smallest of the three pixel color components:


We subtract this value from the red, green and blue components. One of these values is then equal to zero. The larger of the other two values is the intensity of the color part:


Finally, we have to define a numerical value for the hue to characterize the color. The hue is cyclic. We can assign the value 0 to red, going to yellow for 1, green for 2, cyan for 3, blue for 4, magenta for 5 and then comes red again for 6. For intermediate colors we use an interpolation that comes directly from the color components. As an example, subtracting grey the pure red has color components

red-grey=intensity, green-grey=0, blue-grey=0

and the pure yellow is made of

red-grey=intensity, green-grey=intensity, blue-grey=0.

For intermediate colors like orange the hue is given by


Similarly, we get the value for the hue of other colors. That’s how to calculate the values of grey, intensity and hue parameters from the red, green and blue channels and inversely.

To transform the color of a pixel we get first the grey, hue and intensity values from its red, green and blue channels. Then we change the hue. For an n-color symmetry we would add 6/n. Finally, we calculate the values for red, green and blue channels using the new value of the hue.

We can do other color manipulations too. Here, a minstrel bug with red and black stripes becomes a rainbow bug:


Posted in Kaleidoscopes, programming | Tagged , , , | Leave a comment

3-color symmetry

For color symmetries we need a mapping W(z) for its structure as discussed in the last post and some suitable color transformations. In an earlier post I discussed some simple transformations for making a 2-color symmetry. For 3-color symmetries we easily find a fitting transformation using that a pixel has red, green and blue color components. We simply exchange them cyclically – red becomes green, green becomes blue and blue becomes red. Another possibility: red becomes blue, blue becomes green and green becomes red. Together with the original colors we get three color variants as needed.

This 3-color symmetry together with a six-fold rotational symmetry gives results like this:

The mapping of the color symmetry is simply W(z)=z². Here I added a dark border between the different sectors of the color symmetry. Admittedly, this is merely a proof of concept and not very interesting. Color symmetries become more useful in periodic and quasi-periodic kaleidoscopes.

Posted in Anamorphosis, Kaleidoscopes | Tagged , , , , | Leave a comment

n-fold color symmetry

Let’s begin with a simple kaleidoscope, where a pixel at coordinates z=x+iy has the original colors of an input image at the mapped coordinates Z(z)=X(x,y)+iY(x,y). It has some symmetry s. It is a mapping of the plane that does not change the output image as Z(s(z))=Z(z). Now, we want to add an n-fold color-symmetry to this symmetry. We have n different ways k=1…n to transform the color of the input image – such as leaving it as it is or making its negative for a 2-color symmetry. Each possibility will appear as often as the other ones.

How do we do that? Reading “Creating Symmetry” of Farris, we discover that we need another mapping W(z)=U(x,y)+iV(x,y) to select the good color transformation for the output image points z. In the W-plane we make n equal seized sectors around the center and the sector containing the point W(z) determines the applicable transformation of the color. More precisely, first we get the angle φ of the point (U,V) in polar coordinates. If 2π(k-1)/n < φ < 2πk/n, then we use the color transformation with number k for the output pixel at (x,y).

To get the correct switching between color variants we impose on the mapping W(s(z))=exp(2πi/n)W(z). This partially defines W(z) and makes sure that the symmetric point s(z) will in the next color sector. That is, if the color transition number k applies to the pixel at position z then the transformation number k+1 should apply the pixel at s(z).

A p-fold symmetry of the kaleidoscopic image gives back a point z if we apply it p-times on z:


We can combine the symmetry s with an n-fold color symmetry if p is an integer multiple of n, p=m*n. Then, going through a full cycle of all unique powers 0,1,2,… p-1 of s we get each color variant m times. Thus we make m cycles in the W-plane.

A good example is the p-fold rotational symmetry of rosettes. Using polar coordinates z=r*exp(iφ) we write W(z) similarly as Z(z) in the earlier post “How to generate rosettes“:

The terms with l>0 are not required, but offer additional artistic possibilities. For programming we better use real valued functions and coordinate pairs:


where the integers k and l can be negative. Note that U(x,y) and V(x,y) use the same coefficients  u and v and that they are not independent. These equations resemble in part a rotation matrix.

Posted in Anamorphosis, Kaleidoscopes | Tagged , , , , | Leave a comment

Simple example of a rosette with two-color symmetry

To keep things simple I am creating rosette with six-fold rotational symmetry. The mapping functions are, using polar coordinates: X = r³ cos(6*φ) and Y = r³ sin(6*φ). An input image of a single butterfly results in 6 distorted butterflies:

The black wings make a dominant shape resembling a propeller with 6 blades.

For a two-color symmetry I use a control function of three-fold rotational symmetry
W = r cos(3*φ).

Using simple color inversion I get:

Clearly, this image has only three-fold rotational symmetry. The black wings become white in the parts with the inverted color and this destroys the propeller shape. The image now has two rather disparate parts.

With the improved inversion of my last post, that only changes the hue and not the grey part, I get a subtler effect:

The propeller shape is not destroyed and the image seems to be more coherent. We see that the rather bright yellow of the centers of the flowers becomes a much darker blue. Thus, even with this method we get changes in brightness. The false colors are interesting or disturbing – that depends on your taste.

Posted in Kaleidoscopes | Tagged , , , | Leave a comment

Color transformation

I am now discussing color transformations for creating kaleidoscopic images with two-color symmetry. Each pixel has three color components: red, green and blue. Their values are between 0 and 255. Thus we can think that a pixel color is a point with coordinates (r, g, b) inside a three-dimensional cube. The corners of the cube are the following: black with coordinates (0,0,0) and white (255, 255, 255), the primary colors red (255, 0, 0), green (0, 255, 0) and blue (255, 0, 0) and the secondary colors cyan (0, 255, 255), magenta (255, 0, 255) and yellow (255, 255, 0). A color transformation is a mapping of points inside this cube. Clearly, it should not map points into the outside of the cube because all possible colors are in its inside. Further, the mapping should not destroy information. This means that every point in the cube is only the image of exactly one other point and that the color transformation has an inverse.

For two-color symmetry we want that the transformation is its own inverse. Then we could not say which part of the kaleidoscopic image has the original colors and which part has the transformed colors without knowing the input image.

The most simple transformation with these properties is making the negative image:

r → 255 – r, g → 255 – g and b → 255 – b.

This inverts the color cube and maps black to white, red to cyan, blue to yellow and green to magenta. The result is often quite bewildering. Consider this photo of a bee on lavender blossoms:

Its negative image is quite strange:

This is no surprise for those who do analogue photography. The developed negative does not give a good idea of the final image both in color or black and white photography. The problem is that dark parts become light and inversely. This makes it difficult to recognize details of the input image in the kaleidoscopic image with transformed colors.

We might want to have a different transformation. The grays should not be changed; especially, black remains black and white remains white. The other corners of the color cube should map as for making the negative image. To get this, we dissect the pixel color into two parts: an achromatic grey and a fully saturated color. The grey part results from the smallest of the red, green or blue components. If

s = min(r, g, b),

then (s,s,s) are the coordinates of the grey. It has no hue, zero saturation (colorfulness) and its intensity is given by s. By the way, you can call s “value” or “brightness” or whatever, see https://en.wikipedia.org/wiki/HSL_and_HSV. Subtracting this, we get the color part with components (r-s,g-s,b-s). At least one of these components is equal to zero, which means that we have a fully saturated color. Its hue depends on the input image. The largest of the three color components:

L = max(r, g, b)

defines its intensity. It is L-s.

To transform the color we leave the gray part as it is. For the saturated color part we want the smallest component to become the largest and inversely. This is easiest done by making a negative such as r-s→(L-s)-r-s=L-r. Adding the gray part, we get a simple transformation:

r → L+s-r,

g → L+s-g and

b → L+s-b.

You can easily verify that this transforms the corners of the color cube as desired and that this transformation is its own inverse. Using it on the image of the bee we get:

In spite of the false colors we recognize the bee very well. For some images you might prefer this transformation.

Then, we can use both transformations together, one after the other. The result does not depend on the order of execution. This combination exchanges black and white, whereas the other corners of the color cube stay in place. We get something strange like this:

Posted in Kaleidoscopes, programming | Tagged , , , , | Leave a comment

Kaleidoscopes with twofold color symmetry.

A checkerboard is a square lattice with twofold color symmetry. The alternating black and white squares make it more interesting than a simple square lattice. Thus I want to have too some twofold color symmetry for our kaleidoscopes. Farris has done this too in his book “Creating Symmetry”; but I am proposing a different method.

First think about the simple square lattice. How would you tell a human or a computer to build it ? You could say: “Place squares side by side in rows and columns.” This defines the geometrical structure and does about the same as the functions X(x,y) and Y(x,y) of the kaleidoscope, which can generate rosettes, friezes or tilings of the plane. Now consider the checkerboard and how to get it. You could say: “Make a square lattice and for each square look at the sum of its row and column numbers. If the sum is an even number, then paint the square black, and else paint the square white.” Think of this sum as an extra function W(x,y) for defining the color symmetry.

Such a function W(x,y) is useful to generate kaleidoscopic images with two-color symmetry. For a pixel at the position (x,y) we look up the color of the input image at the mapped position [X(x,y),Y(x,y)]. For positive W(x,y)>>0 the pixel gets this color without change, and for negative W(x,y)<<0 we somehow transform the color. If W(x,y) is near 0 then we use an interpolated color. Clearly, symmetries of W must relate to symmetries of X and Y as in the example of the checkerboard.

For further discussion, we use the more convenient complex numbers z=x+i*y for points in the plane and a complex function Z(z)=X(x,y)+i*Y(x,y) for the mapping. A complex function S(z) is a symmetry of the function Z if Z(S(z))=Z(z) for all z. Thus the kaleidoscope will look up the same point in the input image for z and for S(z). Then, both points will have the same color in the kaleidoscopic image if use no color transformation. To get two-color symmetry we make that W(S(z))=-W(z) and use it to control a suitable transformation of color. This makes that z and S(z) in general have different colors. Then the symmetry S(z) is broken in the image but S(S(z)) is still a symmetry because W(S(S(Z)))=-W(S(z))=W(z).

For the checkerboard, the important symmetries S(z) are translations in x or y-direction: S(x,y)=(x+a,y) and S(x,y)=(x,y+a), where a is the length of the sides of the squares. As color control function we can use W(x,y)=cos(π*x/a)*cos(π*y/a), which is positive on some squares and negative on their neighboring squares. We get a checkerboard pattern if we draw white pixels for W>0 and black pixels for W<0. Note that doubled translations by 2*a in x or y-direction are symmetries of the checkerboard.

Posted in Kaleidoscopes, programming | Tagged , , , | Leave a comment