Home

About

« Back to Graphics

Create an image mosaic with Metapixel

This is for Linux only, as I don't know of a Windows version of Metapixel.

Metapixel takes two inputs:

It then creates a mosaic version of the large picture where each pixel is replaced by one of the pictures from the collection, like this:

(example photo taken from here).

Here's how to create similar pictures.

1. Prepare your picture collection

Let's assume that your photo collection is placed under a directory called "photos". First, create the directory in which metapixel will place the prepared pictures (run all these commands in a terminal):

mkdir metapixel_prepared

Then, ask metapixel to prepare the pictures for you:

metapixel-prepare -r --width=50 --height=50 photos metapixel_prepared

The "-r" tells metapixel to browse through the given repository recursively. The "--width" and "--height" options tell metapixel how big the generated thumbnails should be, in pixels. This depends on how large the picture you want to eventually generate should be: make sure that the thumbnails we're creating here are no smaller than the size you want them (each of the mini pictures) to have in the final picture.

This step may take a lot of time, depending on how many pictures you have in there.

2. Generate the mosaic picture

Place the large picture you want to transform into a mosaic, and the "metapixel_prepared" directory in the same place, change to that directory and run:

metapixel --library=metapixel_prepared -s 4 -a 30 -d 300 --metapixel large_photo.jpg result.jpg

The "-s" option here asks metapixel to multiply the size of large_photo.jpg by 4 before creating the mosaic. Set this to a higher number if your picture is smaller, or to a lower number if it's already really large. The "-a" asks metapixel to "cheat" a little bit by blending 30% of the original picture into the result, you can try different values for this parameter. Finally, the "-d" tells metapixel the minimum distance between two repetitions of the same picture in the result. Set this to a hugh number if you prefer metapixel to favor many different pictures, even though repeating the same picture more often could create a better visual impression.