i'd like to create a photomosaic generator. the difficult part is to determine the best matching picture (from a database of pictures) to replace a tiled section of the original picture. given tile, pic0, pic1 (all bufferedimage objects of the same dimension), determine whether pic0 or pic1 is a better replacement for tile.
0. compare* (details below) tile with pic0 pixel by pixel and sum up the differences (call it s0).
1. compare* (details below) tile with pic1 pixel by pixel and sum up the differences (call it s1).
2. replace tile with pic0 if s0 <= s1, otherwise replace it with pic1.
0. extract the rgb components of the corresponding pixels.
1. abs(tilePix.red - picPix.red) + abs(tilePix.green - picPix.green) + abs(tilePix.blue - picPix.blue).
results: the same picture is always used as a replacement.
using the distance formula on rgb doesn't work either:
sqrt(sqr(tilePix.red - picPix.red) + sqr(tilePix.green - picPix.green) + sqr(tilePix.blue - picPix.blue).