Opencv Tutorial: Loading Images and Using Histograms 29 November 2005
Opencv Tutorial: Loading Images and Using Histograms 29 November 2005
Part II
Loading Images and Using Histograms
29 November 2005
Create the Histogram Data //grab the min and max values and their indeces
cvGetMinMaxHistValue( hist, &min_value, &max_value, &min_idx, &max_idx);
Create a Histogram Image and a //scale the bin values so that they will fit in the image representation
cvScale( hist->bins, hist->bins, ((double)histImage->height)/max_value, 0 );
Histogram
//set all histogram values to 255
cvSet( histImage, cvScalarAll(255), 0 );
//create a factor for scaling along the width
bin_w = cvRound((double)histImage->width/hist_size);
Calculate the Histogram
cvNamedWindow("Histogram", 0);
cvShowImage("Histogram", histImage );
Show Images //hold the images until a key is pressed
cvWaitKey(0);
cvNamedWindow creates a container.
The first parameter is the name and the
second declares if the container is to
expand to fit the contents.
//remove windows
cvDestroyWindow("Original");
Destroy Containers cvDestroyWindow("Gray");
cvDestroyWindow("Histogram");