Written by: Chris Dunkle

This type of LEGO creation is called a mosaic. A mosaic is a picture made up of smaller pieces collectively make a larger picture. But this particular mosaic is unique. Rather than representing a picture you may be used to, this mosaic creation depicts a different kind of image, known as an Autostereogram.

A stereogram is a pair of two-dimensional images that can be viewed by each eye independently to create a three-dimensional image. This can be achieved using a device called a stereoscope which ensures each eye can only see one image. An example of a stereoscope is a classic children’s toy that cycled through various images on a small interchangeable reel.

Classic Stereoscope Toy (circa sometime in the past)

An autostereogram uses one image instead of two to achieve this similar three-dimensional illusion without the use of a stereoscope. The image above is referred to as a random-dot autostereogram because it uses a repeated pattern of random dots. By focusing your eyes either in front or behind the image, your brain will attempt to merge the patterns and create an illusion of depth.

Think of each of your eyes as a separate camera. They independently capture a separate image and your brain attempts to merge the two images into one. When your brain properly merges the two images captured by your eyes, the result is depth perception.

An autostereogram tricks your brain into merging multiple images of the same random pattern. A change in the visual depth occurs when the pattern is slightly changed. By removing dots to shrink the pattern, or adding new random dots to expand the pattern, those parts of the image will either look closer or further away, creating the illusion of depth.

This autostereogram started with a depth template. The template indicates where the depth should change according to the different colors. The following table shows the depth associated with each color used in this sample template.

ColorDepth
White0
Black1
Blue2
Green3

While most autostereograms are created with a high resolution, this particular image is only 144×64 dots, which is extremely small fro most digital images, as shown to the right.

But the same image is fairly large when built out of LEGO, assuming one stud per pixel, which is approximately 4 feet long. This size greatly limits the resolution of the image, which also affects how often the depth can change. To make it easier to visualize, the first layer of depth was removed from this template (the black frame and outline) to reduce the number of depth changes. The first depth change was kept at 2 to cause the illusion to stick out just a little bit more. Additionally, the depth template was shifted to the right slightly to make the final image to appear centered. Otherwise it would appear slightly to the left due to the visual duplication of the pattern.

Because your eyes are horizontal, the random pattern must be repeated horizontally. Each horizontal line, or row, of the image can contain a new random pattern. It is not necessary to repeat the pattern vertically, though it can be if desired. The pattern is copied according to the depth template.

In this example, the starting pattern of each row is 16 dots wide. The current position in the pattern must be tracked to ensure the dots are added or removed in the proper location. When switching from white (0) to blue (2), two dots are removed from the pattern at that position. When switching from blue (2) to green (3), only one dot is removed from the pattern. Both of these shrink the pattern, creating a new layer of depth at those positions.

When switching from green (3) back to blue (2), a single new random dot is inserted into the pattern. When returning from blue (2) back to white (0), two new random dots are inserted into the pattern. Both of these expand the pattern, restoring the depth to the original. This process of changing the pattern was repeated for each row based on the depth until the entire image was complete.

But in this case, there was an additional challenge. It would have been disappointing to buy all of the dots to build this mosaic and find the dots were too large to actually see the three-dimensional image.

To make the purchase worthwhile, it was necessary to ensure the same dots could be used to build something else interesting, such as the actual LEGO logo! (Yes, it may be rectangular instead of square, but still contains the logo.) So a new mosaic was generated as shown to obtain the exact number of dots for each color.

The following table shows the exact number of colors used in both the LEGO logo mosaic, and the autostereogram mosaic. Next it was necessary to figure out how to generate the autostereogram using the process above and end up with the exact number of each color. Rather than choosing a color when generating the random pattern or when inserting a new color into the pattern, each random color was assigned a unique number. When the pattern was copied, each dot retained its unique number.

ColorCount
Black2742
Red2681
White2813
Yellow980

After the entire image was generated, the number of instances of each unique number was counted. Each unique number was then assigned a random color, but the color was picked such that the different colors were distributed across the entire image and the final count equaled the exact amounts listed above.

Since each row had a separate pattern, every unique number had at most 11 instances on any particular row. There was also a large number of dots with only 1 instance, due to changes in the pattern, so there were plenty of opportunities to ensure the final count equaled the desired amount. And if the final image had small clumps of the same color, they were swapped with another repeated dot somewhere else in the image, as long as it had the same number of instances.

Obviously it would be extremely time consuming to design this autostereogram mosaic by hand, and would likely result in errors. This mosaic was first designed digitally to ease this process. A computer program was written to automate the random pattern using unique numbers, copy the pattern according to the depth template, and then randomly assign a color to each unique number.

LDraw screen capture

An additional computer program was written to convert the autostereogram image into an LDraw file, shown to the left from a Linux program called LeoCAD. LDraw is a computer aided design (CAD) standard for creating virtual LEGO models.

This file was used to separate the image into 16×16 plates so the physical mosaic would be modular and easy to build!