0
votes

I'm trying to create an histogram using opencv. I have an image (32 bit) that came out from a blurring operation, so I just know that the values are in the range [-0.5; 0.5] but I don't know anything else about the starting data.

the problem is that I don't understand how to set the parameters to compute such histogram. the code I wrote is:

int numbins=1000;
float range[]={-0.5, 0.5};
float *ranges[]={range};
CvHistogram *hist=cvCreateHist(1, &numbins, CV_HIST_ARRAY, ranges, 1);
cvCalcHist(&img, hist);

were img is the image I want to get the histogram. if I try to print the histogram I just get a black picture, while with the same function I get a correct histogram if use a grayscale 8bit image.

1

1 Answers

1
votes

Have you looked at the calcHist example? Also, the camshiftdemo makes heavy use of histograms.

Are you normalizing the histogram output with normalize before display (camshiftdemo shows how to do this)? Values near 0 will appear black when displayed, but when normalized between say 0 and 255 will show up nicely.