0

I want a distance measure to find similarity between images. What i have tried till now: 1) I have used low level distance metrics such as Normalized cross correlation (This retrieves similar images based on some threshold values) , but it cant retrieve images which are rotated or shifted. But if brightness of a particular image is reduced, the images are not retrieved even if they were of the same type. 2)Bhattacharya coefficient: It retrieves Rotated or shifted images but doesnot Detect images whose intensity(Brightness) is reduced. 3) Tried with global features like SURF which provide help for rotated(30 degrees) and transformed images , but no help for images with intensity difference.

What i need: I need a distance metric for image similarity which recognizes those images whose brightness are reduced an all images which are Transformed(rotated and shifted). I want combination of these two metrics (Cross correlation) + (Bhattacharya Coefficient). Will Mutual Information help me in this issue?? Or Can anyone Please suggest me a new metric For similarity measurement for this issue. Tried Googling with a wide issue and irrelevant answers. Can anyone guide me in here.Advance Thanks.

Jonas
  • 375
  • 2
  • 6
  • 20
  • 1
    If I understand correctly, you're saying that brightness differences are affecting your similarity metrics? If so, have you considered performing histogram equalisation on both images before doing the comparison? – Roger Rowland May 12 '14 at 10:18
  • Are you trying to find similarities between objects in the images or similarities between the images? I don't think it is clear what you are applying your methods on. Please update your question and include some sample images. Indicate the things you are trying to detect e.g by drawing by hand. Do one specific example to begin with and ask another question about other images. I might be wrong but I get the feeling that you are just trying lots of different techniques you have read about without actually understanding their strenghts and weaknesses. – kkuilla May 12 '14 at 10:39
  • If i have a Image1.jpg, then i reduce just the brightness of that image and name it Image2.jpg, Even though i reduce image brightness i should be able to say image1 and image 2 are similar using some distance metric. – Jonas May 12 '14 at 10:41
  • @kkuilla- i Am trying to find similarity between images and retrieve top related images. – Jonas May 12 '14 at 10:44
  • 1
    Your question is too broad. You still haven't included relevant information in your question. Post example images and relevant (but minimal) code to show what you are doing. It's impossible to help you as it is as. I still think you are just trying to pick a tool at random and hoping that it will work. – kkuilla May 12 '14 at 12:38

1 Answers1

2

I implemented some mututal information and Kullback-Leibler distance to find similarity in Facades. It worked really well, how it works is explaind here:

Image-based Procedural Modeling of Facades

The whole steps are explained in the paper. But they are not for similarity of Images they are for the symmetrie of image parts. But maybe it works well also for Image comparison. Well it is just and idea maybe it works you should try. One think where i really see a problem is the rotation. I don't think this procedure is rotation invariant. Maybe you should look for some Visual Information Retrieval techniques, for your problem.

First you have to compute the mutual Information. For thate you create an accumulator array of the size of 256 x 256. Why that size? First for every gray color so the joint distribution and then for the marginal distribution.

for(int x = 0; x < width;  x++)
   for(int y = 0; y < height; y++)
   {
      int value1 = image1[y *width + x];
      int value2 = image2[y * width + x];

      //so first the joint distribution
      distributionTable[value1][value2]++;

      // and now the marginal distribution
      distributionTable[value1][256]++;
      distributionTable[256][value2]++;
   }

Now you own the distribution table, and now you can compute the Kullback-Leibler distance.

for(int x = 0; x < width;  x++)
   for(int y = 0; y < height; y++)
   {
      int value1 = image1[y *width + x];
      int value2= image2[y * width + x];

      double ab = distributionTable[value1][value2] / size;
      double a = distributionTable[value1][256] / size;
      double b = distributionTable[256][value2] / size;

      //Kullback-Leibler distance
      sum += ab * Math.log(ab / (a * b));  
   }

A smaller sum says you that the similiarity/symmetrie between the two Images/Regions is very high. Should work well if the Image just have a brightness difference. Maybe there are other distances which are inveriant against rotation.

Maybe you shold try to to use SURF, SIFT or something like this. Then you can match the feature points. More higher the match results are so higher is the similarity. I think this is a better approach, because you don't have to care about scale, brightness and rotation difference. And it is also fast implemented with OpenCV

PeterNL
  • 630
  • 6
  • 21
  • @PeterNL- can you show me the piece of code for implementing mutual information or give me details of how you calculated mutual info between two images. – Jonas May 19 '14 at 04:57
  • @kkuilla- I am not using any tools , i want my system to recognize both rotated and images with intensity difference. This is hat i have done with now. – Jonas May 19 '14 at 05:00
  • @kkuilla- I am not using any tools , i want my system to recognize both rotated and images with intensity difference. This is hat i have done with now. I have calculated Normalized cross correlation too, This code is for bhattacharya coeffficient. def bhattacoeff (img1,img2): x1=cv2.calcHist([im1],[0],None,[256],[0,255]) y1=x1/sum(x1) x2=cv2.calcHist([im2],[0],None,[256],[0,255]) y2=x2/sum(x2) B=0.0 for i in range(0,256): B=B+(math.sqrt(y1[i] * y2[i])) return B – Jonas May 19 '14 at 05:10
  • @PeterNL- I have tried down ur advice and it gives good matching as SIFT and SURF provides good matching over all types of differences – Jonas Jun 04 '14 at 11:41