I am working on a Photo Mosaic in Java. I have a collection of tiles. I have to process each tile and store its [R,G,B] values in some data structure. Basically, I want it to be in the following form:
for eachTile in Directory:
calculateRGB;
store in HashMap(key is image name, value is a list of R,G,B value) in the form { (image1:[R,G,B]), (image2:[R,G,B], ...}
Once this is done, I have to break the Target Image into say cells. Each cell has the same size as that of the tile. Now, I have to process each cell and calculate its RGB. After this, I have to compare it with the tiles to find the best match.
Now, the matching is tricky because I have calculated the Euclidean metric between each cell and each tile to find the best match. So, if I have n number of tiles and m number of cells, my algorithm will run for n^2.m times.
Is there any better way to do this? or do I have to do the computation intensive algorithm for comparing the images?