Thursday, 17 December 2009

Photo Mosaic creation tips

Related to my previous post, I spent some time figuring out how to get a good photo mosaic. Basically I wanted to create a Mosaic of a family picture, where the "metapixels" (i.e. the small images) would be pictures of the members of the family. The resulting image (about 75cmx100cm) was to be framed and put up at our home, in a corridor with maximum viewing distance of around 5.5 metres. And basically I wanted to make sure that the family picture could be properly appreciated when viewed from a distance, but also that the "metapixels" could be seen when looking at it close-up. So, I had to follow these steps:

1. Select all possible metapixel images (this is trivial but it takes some time: I wanted to make sure that all metapixels were related to the bigger images).

2. I found that many of my images had spaces in their names, which the metapixel software didn't like, so I substituted the spaces with underscores:

rename -v 's/\ /\_/g' *

3. I don't want the metapixels to be streched (metapixel will only work with one metapixels size) so I find for my set of images which sizes they have and how many I have of each size:

angelv@palas:~/Mosaic$ for img in `ls Mosaic-Original/` ; do identify -format "%wx%h" Mosaic-Original/$img ; done > sizes.txt

4. I find how many of them have a 3x4 ratio, and how many a 4x3 ratio. In my case, these numbers are very similar: 1089 (4x3) vs. 1051 (3x4)

5. Despite the number of landscape images being a little bit larger, I decide to build the mosaic out of the portrait ones, since portrait images are usually close-ups, and will be appreciated better when very small. To copy all the 3x4 images I use:

#!bin/bash

find Mosaic-Original/ -exec identify "{}" \; |awk '{
split($3,arr,"x")
split($1,name,"/")
if ( arr[1] < arr[2] ) { cmd = "cp " $1 " Mosaic-Original-3x4/"name[2] system(cmd) } }'


6. So now I can create the thumbnails with the correct ratio:

angelv@palas:~/Mosaic$ metapixel-prepare -r Mosaic-Original-3x4 Mosaic-Thumbs --width=96 --height=128

7. And now I can prepare the final mosaic image, but with the right ratio for the thumbnails:

metapixel --metapixel mosaico_in.jpg mosaico_out_cheat40.png --library Mosaic-Thumbs/ --scale=5 --distance=5 --width=48 --height=64 --cheat=40

The numbers are important...

* As I mentioned, the final picture has to be 75x100. My original image was 1857x2476 pixels. When asking metapixel to scale it by 5, the resulting mosaic has 12384x9280 pixels, so for 100cm (or 39.37 inches), this image can be printed at 314 dpi (300 dpi is considered a very good quality for printing).

* At the same time, each row of the mosaic will have 258 metapixels (12384/48), so each metapixel will be 3.87mm wide, which is small, but definitely viewable when you get close enough.

* A 40% cheating is quite large, but my set of images was not very large, and the distribution of colours was not very good, so when no cheating was used, the resulting image was very poor in colours, so I modified the original image to make its colours brighter, and I used a 40% cheat percentage, so the resulting image can be easily viewed from a distance, and it has plenty of colours. The artifact can be appreciated when getting close to the picture, but I think this is better than having a resulting mosaic with very poor colours.

The resulting image looks very nice, and I sent it yesterday to develop it (which is cheaper than I thought, just about 30 Euros).

1 comment:

Anonymous said...

Excelent !!!
Thanks.-