Ask Your Question
3

Joint histograms

asked 2013-05-07 03:22:22 -0600

I am currently implementing a c++ version of the paper:

Guo, Z., Zhang, L., & Zhang, D. (2010). A completed modeling of local binary pattern operator for texture classification. Image Processing, IEEE Transactions on, 19(6), 1657-1663. PDF

In the final step of the algorithm (page 4), the information of two histograms must be joined. They comment that there are two ways to combine two histograms: in concatenation or jointly:

  • Concatenation: concatenate the two histograms together.
  • Jointly: calculate a joint 2D histogram of the histograms

I don't know if it is possible to do a joint 2D histogram with Opencv. CalcHist function copes with the calculation of the histogram of image(s). It has a parameter accumulate. If it is set, the histogram is not cleared in the beginning. This feature allows user to compute a single histogram from several images. So it would be another way of combining two histograms?

So:

  1. Is it possible to do a joint 2D histogram with Opencv?
  2. If the parameter accumulate on function CalcHist is set to 1, is it equivalent to do a 2D histogram?. If not, would it be a third way of combining two histograms?

I would be thankful, if somebody could help Thanks in advance

edit retag flag offensive close merge delete

Comments

1
  1. no idea
  2. i don't think so. accumulate is for calculating one histogram from several images

concatenating 2 histograms ( after separate calcHist() ) is actually easy, you just insert or push_back() one hist into another, output: one long feature vec that can be used with compareHist() the same way as the single ones

berak gravatar imageberak ( 2013-05-07 04:00:05 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-05-07 04:07:19 -0600

As I understand joint histograms from this paper: Comparing Images Using Joint Histograms, G. Pass and R. Zabih, in Multimedia Systems, 1999 [pdf], it's an histograms of two different features (color and gradient, color and edge, etc.) more or less like in joint probabilities.

The accumulate flag is for computing a unique histograms from many images, or to update it during time (compute histograms for patches of images and sliding to all patches => get the incremental histogram which is equivalent to the histogram of the full image). The concatenation is trivial: H1 of size n, H2 of size m gives H3 of size n+m, specially if the feature are different, if features are the same and n==m, therefore, H3(i) = H1(i)+H2(i), eventually normalize after.

The joint is more complex and probably imply the manual construction of histograms. With the example, H3 is size n*m, therefore, you have to compute your histograms manually for both primitives in parallel. If you want to do that with OpenCV, you probably need a trick...

Let us know if you find a good solution and/or if it could be interesting to integrate it in OpenCV.

edit flag offensive delete link more

Comments

When I put more than one image in the first parameter (because it is a list of images), even though accumulate is true, the function doesn't use the second image, just the first. So I need to run several calcHist statemets. Why is the first parameter a list of images if the calcHist doesn't take in account others images in the list? All examples on the net use just one image inside the list. Try to use 2 images.

I think it's more effective if the functions allow us to compute a list of data instead of just one. Besides calcHist, another example is inRange, which could be executed by using several ranges and several images at once. We can save many loops.

anderflash gravatar imageanderflash ( 2014-11-07 13:56:52 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-05-07 03:22:22 -0600

Seen: 3,468 times

Last updated: May 07 '13