Facebook Friend Mosaic
I made an application that makes a photo mosaic from Facebook pictures. It uses your friends’ profile pictures as tiles, and the picture formed is your profile picture. Here’s an example:
Unfortunately, the app uses too many resources to feasibly release it to the public on my shared server. It works today, just behind a password wall. If you want to use it and I know you, just email me.
So what good is this private use only app? Well, some open source software is coming out of it:
- I didn’t need the big Python Facebook library, so I made a tiny one that’s suitable for just dropping in to your code. That’s coming later today. (It’s available now if you know where to look.)
- The mosaic code will probably be released next week. I must first make it more generic, and make some human interface, since it won’t be connected to the Facebook app anymore.
Making mosaics turned out to be quite simple. After building an index of tile images and their average colors, the big image is scanned section by section, and the closest-matching tile is pasted over that section. The only interesting question is what closest-matching means, given an average color for the section we are looking at and for each possible tile.
To compare two colors ((R1, G1, B1), (R2, G2, B2)) for closeness, I use the formula (R1 − R2)2 + (G1 − G2)2 + (B1 − B2)2.* Each channel difference is squared because it makes the number positive, and punishes bigger differences in a single channel, so a color which decently matches in all channels will be considered better than a color which matches very well in one channel but poorly in another. Lower numbers mean a better match, with 0 as the best, and 3·0xFF2 as the worst.
This formula was the first thing I tried, and it gave good results, so I didn’t mess with it.
* This mathematical notation is readable without having to think about it much, but the Python is more elegant.
sum(difference ** 2 for difference in (channel - channel for channel in zip(rgb1, rgb2))) expresses the same formula if RGB is used, but it also works on any number of channels, so it can be used as-is with any color mode.
1 comment on Facebook Friend Mosaic
1. Jordan Waddell says:
Hey. Awesome idea. how can i get the mosaic?
Comments on this entry are now closed. Thanks to those who participated. You can still email me.