?
Solved

Image retrieval via colour histogram

Posted on 2006-04-19
3
Medium Priority
?
367 Views
Last Modified: 2012-05-05
Hi

I am working on a program which retrieves an image based on the query image.
The images are stored and displayed in a frame and their histograms for each image are also obtained (including the query image).

However I have problem with following part of the program. I need to obtain the distances (of histograms) between the query image and each of the other images. and then display the closest image to the query image.

 for (int b = 0; b < 3; b++) {
               for (int j = 0; j < 256; j++) {   // for RGB 256*3
                  for (int i = 1; i < 11; i++)   // number of images 1 to 11
            {
           
         D1= histogram[0].getFrequency(b, j) - histogram[i].getFrequency(b, j);
       
           Sum += D1*D1;
           if(Sum < Summ){
            Sum = Summ;
          }
           Summ = Sum;
   //       else{
  //           Summ = Sum;
  //       }      
          }  
          }
       
            System.out.println(" Distance " + Sum + "");
     
However 1st of all I don't know how to find the shortest distance
And then how to use the shortest distance to know that which histogram and therefore image it belongs to
and finaly how to use it to retreive that image to display

Thanks for your time    
0
Comment
Question by:khawaib
  • 2
3 Comments
 
LVL 14

Assisted Solution

by:Tommy Braas
Tommy Braas earned 600 total points
ID: 16493490
Feed the following method with your histograms and keep track of which generated the lowest distance value. That one should be the closest match.

   public static int calculateDistance(Histogram histo1, Histogram histo2) {
      int distance = 0;
      for (int b = 0; b < 3; b++) {
       for (int j = 0; j < 256; j++) {   // for RGB 256*3
          int d = histo1.getFrequency(b, j) - histo2.getFrequency(b, j);
          distance += Math.abs(d);
       }
      }
      return distance;
    }
0
 
LVL 2

Accepted Solution

by:
amol_chaudhari earned 600 total points
ID: 16495008
hi,

if u want to retrive image based on histogram, i will suggest u to process gray scale image instead of color one.... but if u want to continue with color one and find out distance do as follw


for(int b = 0;b<3;b++) {
for(int j = 0; j<256; j++) {
 int d = histo1.getFrequency(b,j) - histo2.getFrequencey(b,j);

distance += (d*d);
}
}

after this u need to normalize ur distance based on size of image

distance = ((Math.sqrt(distance)/(npixels1 * npixels2));

(declare distance as double or float)


if u have all images with same size then u need not to normalise the distance.........

hope this will help............
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 16581914
;-D
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month14 days, 15 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question