Reputation:
I am using the calcHist function to calculate color histograms of images. I am working on a simple image matching application and I am trying to use color histograms as image descriptor to find similar images.
This is the definition:
void calcHist(const Mat* images, int nimages, const int* channels, InputArray mask, OutputArray hist, int dims, const int* histSize, const float** ranges, bool uniform=true, bool accumulate=false )
My question is regarding the dims parameter. This is from the OpenCV documentation:
dims – Histogram dimensionality that must be positive and not greater than CV_MAX_DIMS (equal to 32 in the current OpenCV version).
This might be a dummy question, but what is the difference between the results if I set dims as 1 or 3? If I set dims=1 am I only getting histogram for a single channel in the image or is this a histogram that represents all channels in 1D vector?
Upvotes: 1
Views: 1980
Reputation: 20160
Example:a 4x4 HS(V) Image:
Hue channel:
1 170 33 14
15 133 33 7
122 90 100 142
1 170 33 14
Saturation channel:
25 33 33 45
25 55 255 255
25 33 255 255
10 55 255 255
now assume 3 histogram BINS per channel:
HA = [0..60]
HB = [60..120]
HC = [120..180]
for H channel
SA = [0..80]
SB = [80..160]
SC = [160..255]
for S channel
now the difference:
dim = 1 would make a 1D histogram for each channel:
#HA = 9
#HB = 2
#HC = 5
and
#SA = 10
#SB = 0
#SC = 6
if you use dim = 2 you get the inter-channel histogram:
- HA HB HC
SA 5 1 4
SB 0 0 0
SC 4 1 1
which is a more detailed information.
Hope this is the answer to your question.
Upvotes: 1
Reputation: 1686
dims parameter is used to indicate the count of features that you're interested. it can be 1 for "intesity" and more for "gradients, directions" etc.
Upvotes: 0