- Calculate the hue/sat/value of every tile (use HSV because smaller differences here seem more "natural" to the human eye than in RGB space)
- Now calculate the same values for each n*n tile of your big picture
- Find the tiles with the closest HSV values (minimum of
sqrt((h1-h2)^2 - (s1-s2)^2 - (v1-v2)^)
) and stamp that tile scaled down to n*n into the result.
To find the HSV for a tile, it should be enough to sum up all RGB values and then divide them by the number of pixels and convert that final RGB triple into HSV. But to be save, I suggest that you try that both versions.
See which Wikipedia article for RGB <-> HSV conversions.
To refine the algorithm, you can split every tile into an m*m and calculate the average HSV for each grid element. Then, when you look for a match, divide the big image into as usual but also calculate m*m HSV values. Select which tile matches most of these m*m best. This allows the algorithm to select tiles which have the same structure as the big picture.
For that extra touch, try to create a gigapixel image.