Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

histogram matching

Hi,

   Can anyone please provide me a source code for histrogram matching.

 

Thank you

0 Kudos
Message 1 of 10
(6,283 Views)

Hello john1188,

 

the code i am attaching uses four different metrics to perform histogram matching. It is based on openCV and called as a DLL in labview. You would need to install openCV (i have 2.4.5 version).

 

I hope it helps you.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 2 of 10
(6,263 Views)

The OpenCV solution is a good one, but may be more complex than you need for a simple greyscale image.  It is pretty simple to write your own:

 

1) Compute the cumulative histogram H0 (or histogram integral) of the histogram that you want to use and normalise

2) Compute the cumulative histogram H1 of the image you want to match

3) For each value in H1, threshold H0 to find the matching index

4) Compute new image values from the matching indices

 

HistogramMatching.png

 

You could of course compute the histogram of a second image if that's what you want to match to.  I've used this technique to "equalize" the histograms of a large number of images to the mean cumulative histogram of all of the images.

0 Kudos
Message 3 of 10
(6,253 Views)

Hi Klemen,

               i am using only 2011 version,can you convert it to lower version from 2012.

and also whether it works for color image histogram matching.

 

Thank you

0 Kudos
Message 4 of 10
(6,241 Views)

Hi,

    I am using  2011 version,can you please convert it into lower version from 2012.

and also whether it works for color image histogram matching?. if not can you provide me for color image histogram matching.

 

Thank you

 

 

0 Kudos
Message 5 of 10
(6,240 Views)

Hello,

 

please see the attachment, saved for lv2011.

 

The input is indeed a color image.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 6 of 10
(6,234 Views)

Hello,

 

please use the attached DLL and labview vi, since i have made some mistakes in the previous code. This code should now be ok!

 

Sorry for the inconvenience.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 7 of 10
(6,193 Views)

Hi Klemen,

               Things which you have given works fine.

What i want is, in the ouput image there must be overlay(higlight) the identical objects when comparing the given input images(similar input image in both the base image and test image) using histogram intersection method.can you help in creating the source for this.

 

Thank you

 

0 Kudos
Message 8 of 10
(6,152 Views)
Sorry,i do not fully understand your problem.
Please provide an example of such images and provide description of what you need to achieve.

Best regards,
K

https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 9 of 10
(6,129 Views)

Hi Klemen,

               

Histogram matching
Many similarity measures between two histograms, such as
the quadratic distance, Chi-square distance and histogram
intersection can be used [1]. In the experiments, we used
histogram intersection due to its computational
inexpensiveness. The histogram intersection between two
histograms can be calculated as follows:
Histogram intersection.png
where H 1 and H2 represent two histograms and K is the
number of bins in the histogram.
During this coarse target object detection step, a small
number of target object candidates with high histogram
matching scores were generated. These target object candidates
represent the input of the precise target object detection step.

0 Kudos
Message 10 of 10
(6,122 Views)