How to Create Beautiful Photomosaics in Linux Using Metapixel

Printer-friendly versionPDF version
Linux Metapixel

Metapixel is a program for generating photomosaics. It can generate classical photomosaics, in which the source image is viewed as a matrix of equally sized rectangles for each of which a matching image is substitued, as well as collage-style photomosaics, in which rectangular parts of the source image at arbitrary positions (i.e. not aligned to a matrix) are substituted by matching images.

To install metapixel, run the following commands (you will need unrar to extract the wallpaper packs. If you have your own image collection, you do not need to install unrar):

Ubuntu (Tested on11.10): sudo apt-get install metapixel unrar

openSUSE (Tested on 12.1) 32bit: wget http://download.opensuse.org/repositories/openSUSE:/11.4:/Contrib/standard/i586/metapixel-1.0.2-1.2.i586.rpm

sudo zypper install ./metapixel-1.0.2-1.2.i586.rpm unrar

openSUSE (Tested on 12.1) 64bit: wget http://download.opensuse.org/repositories/openSUSE:/11.4:/Contrib/standard/x86_64/metapixel-1.0.2-1.2.x86_64.rpm

sudo zypper install ./metapixel-1.0.2-1.2.x86_64.rpm unrar

In order to use metapixel, you need an image collection and a source image (like the one above, which you can download in the steps below). Metapixel only supports jpeg and png images. If you already have an image collection, you can use it as the source folder, otherwise, here is a collection of wallpapers you can use (thanks to dehx.net for hosting these wallpaper packs):

wget http://www.dehx.net/santod/Ultimate%20Walls/Santods%20Ultimate%20Walls%20Landscape%20%20Pack.rar

This pack has 784 images in it. The reason I chose it for my example is because it's only 127 MB. If you need more images (which you will, if you want a better looking photomosaic), download this wallpaper pack instead:

wget http://www.dehx.net/santod/Ultimate%20Walls/Santods%20Ultimate%20WVGA%20Wallpaper%20pack.rar

Run the following commands to create your metapixel working directories, download the source image, and unpack the wallpaper pack:

mkdir mp mp/small mp/photo

cd mp

wget http://1.bp.blogspot.com/-eIb2BJBJUXI/TVnS1YOyibI/AAAAAAAAAcU/Q4HTp3q-5YQ/s1600/animated+linux+wallpaper.jpg

unrar e ../"Santods Ultimate Walls Landscape  Pack.rar" photo/

Before running metapixel, you must prepare the images:

metapixel-prepare -r ./photo ./small --width=32 --height=32

This takes all the images you unpacked in the photo directory, resizes them to 32x32, and places them in the directory named small. To make a photomosaic of your source image, run the following command:

metapixel --metapixel ./animated+linux+wallpaper.jpg photomosaic.png --library ./small/ --scale=10

photomosaic_metacity_full

This scales the original image by 10, then arranges the 32x32 images to fit inside the scaled up source image. Take a closer look:

photomosaic_metacity

​To make a collage style photomosaic, run the following command:

metapixel --collage --metapixel ./animated+linux+wallpaper.jpg photomosaic2.png --library ./small/ --scale=10

photmosaic_collage_full

As you can see, it's a little more detailed. The 32x32 images overlap each other, providing more depth and clarity. Using the --collage switch will increase the processing time significantly, but it's worth the wait if you want a better quality result. Take a closer look again:

photmosaic_collage

You can also add the --distance=300 option to ensure duplicate images won't be placed near each other. Using the --distance option will also increase the processing time. If you use it, you must make sure that you have a large enough image collection for the spacing to work.

To find out more about metapixel and all of the command line options, check out the readme file and the project's homepage:

https://github.com/schani/metapixel/blob/master/README

http://www.complang.tuwien.ac.at/schani/metapixel/

Thanks to Matthew Gerber, there is a GUI available for metapixel. Check it out here:

http://ptl.sys.virginia.edu/ptl/members/matthew-gerber/software

Hi, you have scaled the original images to 32x32 pixels. Is the aspect ratio kept?
Ciao, Leo

The aspect ratio is not kept. I chose 32x32 because it is so small that you can't really tell the aspect ratio is lost. If you wanted to keep the aspect ratio for the pictures I linked to, you would have to do it like this:

The images are 800x480. To retain the aspect ratio, you would need to make the images 32x19.2. Since metapixel only accepts whole numbers, you would run this command to prepare the images:

metapixel-prepare -r ./photo ./small --width=32 --height=19

Post new comment