Pretty interesting to see, I’ve already worked with him on improving the algorithm to generate these mosaics in the past. But next he set me a challenge: Find your own game thumbnail, it is in there somewhere!
This is the screenshot of my game, used as thumbnail:
So I went though the thumbnails, one time.. and a second time… then I decided to solve it like a real programmer:
How does it work? Well it is pretty simple:
- Input #1: mosaic.jpg
- Input #2: Amount of thumbnails width and height
- Input #3: screenshot.png
- The program resizes my game screenshot to the thumbnail size.
- Next it loops over all sub-images of the mosaic.
- For every sub-thumbnail: Calculate the error (+=Math.abs(mosaicPixelValue - screenshotPixelValue) for each color, for each pixel)
- Store the location of the thumbnail with the smallest error!
That is it, solved it in 10 minutes of coding!
(and another 10 minutes to make the visual conformation and make the animated gif).