I want to do a feature extraction from an image to a 3D histogram in the RGB colorspace. I have the following python code which I want to do it under c++:
hist = cv2.calcHist([image], [0, 1, 2], None, self.bins, [0, 256, 0, 256, 0, 256])
hist = cv2.normalize(hist)
return hist.flatten()
I did something like this:
float range[] = { 0, 255 } ;
const float* histRange = { range };
int channels[] = {0};
cv::calcHist( &image, 1, channels, cv::Mat(), r_hist, 1, &sizeVector[0], &histRange);
channels[0] = 1;
cv::calcHist( &image, 1, channels, cv::Mat(), g_hist, 1, &sizeVector[0], &histRange);
channels[0] = 2;
cv::calcHist( &image, 1, channels, cv::Mat(), b_hist, 1, &sizeVector[0], &histRange);
But then I found that they are not the same since in python the histogram is counting in 3D-based, how to convert the code to c++?