2

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?

Intern
  • 327
  • 1
  • 7
  • 23
  • 1
    You already asked about comparing images here http://stackoverflow.com/questions/12773925/compare-rgb-of-2-images-in-java – dngfng Oct 08 '12 at 07:33
  • is it just me or doesn't the title match the question?.. – Qnan Oct 08 '12 at 08:00
  • 1
    @dngfng That's a different question and no duplicate. This question is about comparing a large number of images (the question would work with any object), whereas the other question is about how to compare exactly two images. – Ocaso Protal Oct 08 '12 at 08:21

1 Answers1

2

You can build an Octree http://en.wikipedia.org/wiki/Octree, or a KD-tree http://en.wikipedia.org/wiki/Kd-tree, to find the nearest neighbor efficiently.

digitalvision
  • 2,552
  • 19
  • 23