Turning a photo into a Lego mosaic with the GIMP

This method is fairly simple, but produces very cool images. This tutorial was written with the GIMP in mind, but should apply to many image editors (and if you don't have one, I highly recommend GIMP and an online book about it: Grokking the GIMP). Basic familiarity with the GIMP is assumed. If something is unclear however, don't hesitate to email me (address below).

In summary the technique is quite simple: a photo is pixelized and then impressed with a pattern of lego pieces which are the same size as a "pixel". The lego pattern was obtained by digitizing a lego piece in a scanner.

Making the lego pattern

First, we need a pattern of a lego piece. You can make your own or just download mine [1]. I decided to use a 1x1 flat lego brick. A square brick is necessary because GIMP's pixelize plugin is currently limited to making square pixels. The final image will appear to be made up of these bricks.

scanned
legos

Figure 1: Initial scan of the legos.

I began by scanning the 1x1 brick surrounded by other bricks with my scanner. Care was taken to line up the bricks with the scanner so the straight edge of the brick didn't create a jagged edge of pixels. This has the side effect of causing the shadows on the brick to form as if the light was directly above. Other orientations may be useful for doing different effects, but keeping the edges lined up with the scanner seems simplest for now.

upper
left corner of crop lower
right corner of crop touched up brick

Figure 2: Detail of upper left and lower right corner of the crop, and touched up lego brick.

The single brick was cropped, with the left and top edges of the selection touching the brick and the lower and right edges touching the neighboring brick (including the small black void between the bricks). This way, when the pattern is repeated, the edges and crevices match up correctly. The rest of the image was discarded. I scanned my legos at 300dpi and cropped out a 94x94 pixel section (be sure to crop out a square section). I touched up the image and removed the "lego" printing with the airbrush and clone tools (no sense flirting with trademark violation).

gray brick
with highlights selected highlights from lego
brick

Figure 3: Desaturated and contrast streched brick with highlights selected, and highlights copied into a new black image.

The brick was converted to grayscale (Image -> Colors -> Desaturate) and the contrast was autostreched (Image -> Colors -> Auto -> Stretch Contrast). The reason will be apparent later, but the white highlights around the edge of the stud were selected with the magic wand tool and copied into a new black image of the same size (94x94 pixels).

curves and lightened brick

Figure 4: Curves dialog; inset: lightened brick.

The original image was then brightened with the "Curves" tool to adjust the "Value" channel (Image -> Colors -> Curves). Skipping this step causes white areas to appear gray in the final image. Both images were scaled to 20x20 (Image -> Scale Image...) and then saved to ~/gimp-1.2/patterns/ as GIMP pattern files (.pat). This makes the two patterns available in the Patterns dialog (Dialogs -> Patterns). It may be necessary to refresh the pattern list before you can select your new patterns.

Legoizing an image

initial image of sailboat pixelized image of sailboat

Figure 5: Initial sailboat image and pixelized sailboat.

Now that we've got some lego patterns, we can start by opening a photograph or any image in the GIMP. I've chosen a picture of a sailboat. Use Filters -> Blur -> Pixelize... to pixelize the image. This filter makes the image appear to be made up of giant pixels. Choose an appropriate size depending on the size of your lego piece pattern. 20 x 20 is chosen here because that's the size of the lego pattern.

after
lego, before highlight lego pattern layer
set to multiply

Figure 6: Image after creating lego pattern layer and setting mode to "Multiply (Burn)".

Create a new layer, and use the Bucket Fill tool to fill with a pattern. Make sure the lego pattern is the current pattern. Double click on the Bucket Fill tool to bring up the Tool Options dialog. Choose "Pattern Fill". Then select the entire new layer (Ctrl-a) and click to fill it with the pattern. Set the layer mode to "Multiply (Burn)" in the "Layers and Channels" dialog (Dialogs -> Layers, Channels & Paths) so that the lego pattern is impressed into the image below. You may wish to adjust the brightness of the original layer because multiplying tends to darken things (which is why we made sure to lighten the pattern earlier).

Ok, now we're lookin' good. Only thing, the legos aren't quite as shiny as they should be (especially dark ones).

after
highlight highlight layer set
to addition

Figure 7: Image after creating lego highlight layer and setting mode to "Addition".

Repeat the above sequence, only this time fill a new layer with the "highlight" pattern. Set the layer mode to "Addition", so only the white highlights show. You can adjust this layer's opacity if the highlights are too bright (50% seems to work well).

I then usually use Image -> Colors -> Posterize to reduce the number of colors in the pixelized image layer. This makes it more realistic as legos don't come in very many colors. I use a value around 12 which is somewhere between too many and too few. You may also wish to make a palette of actual lego colors and only use those in the image. Doing that is left as an exercise to the reader :-)

That's it. Now you can drool at your super cool lego mosaic. Here's a link to my finished example: example and another example (notice the illusion of pieces created with painstaking erasure of crevices, ...working on an easier way to do this).

[1] Here are the links to the lego patterns I used (in png and GIMP pattern format):

Lego is a registered trademark of the LEGO Group. This site is in no way endorsed by or affiliated with the LEGO Group.