Reputation: 622
I want to calculate the color histogram of an image but only taking into account specific pixels (whose 2D coordinates I know).
Is it possible to use calcHist specifying that only these concrete pixels should be taken into consideration (instead of the whole cv::Mat and all the pixels in it)? If not, is it possible to create a new Mat including only those specific pixels at known positions, and how? (Considering that for a histogram the pixel coordinates do not matter, could they be added to a (1 x number_of_specific_pixels)-dim Mat keeping the original type of the Mat?)
Thanks a lot in advance!
Upvotes: 1
Views: 576
Reputation: 20324
The third parameter of clalHist is called Mask
.
So, you create a new single channel 8 bit cv::Mat
that has the same size of your input image. It should contain 255's
where you want to calculate the histogram and 0's
where you do not. Then, pass it as Mask
.
Upvotes: 2