CodePudding user response:
Fyi:
//computing image image (s) of the histogram
Void cvCalcHist (IplImage * * image, CvHistogram * hist,
Int the accumulate=0, const CvArr * mask=NULL);
Image
//input image s (although you can also use the CvMat * *).
Hist
//histogram pointer
The accumulate
//the total logo, if set, the histogram in the beginning will not be reset, this characteristic can guarantee for multiple images to calculate a single histogram, or online update histogram,
Mask
//operating mask, determine which pixel of the input image is count
//function cvCalcHist calculation of single channel and multi-channel image histogram, to increase the straight square array elements, can be extracted from the corresponding input images in the same position. The Sample calculation and display of color images of 2 d image
hue, saturation
# include & lt; CV. H>
# include & lt; Highgui. H>
Int main (int arg c, char * * argv)
{
IplImage * SRC;
If (arg c==2 & amp; & (src=https://bbs.csdn.net/topics/cvLoadImage (argv [1], 1)).=0)
{
IplImage * h_plane=cvCreateImage (cvGetSize (SRC), 8, 1);
IplImage * s_plane=cvCreateImage (cvGetSize (SRC), 8, 1);
IplImage * v_plane=cvCreateImage (cvGetSize (SRC), 8, 1);
IplImage * planes []={h_plane, s_plane};
IplImage * HSV=cvCreateImage (cvGetSize (SRC), 8, 3);
Int h_bins=30 s_bins=32;
Int hist_size []={h_bins, s_bins};
/* hue around the from 0 (0 ° ~ red) to 180 (~ 360 ° red again) */
Float h_ranges []={0, 180};
/* saturation around the from 0 (black - gray - white) to 255 (pure spectrum color) */
Float s_ranges []={0, 255};
Float * ranges []={h_ranges, s_ranges};
Int scale=10;
IplImage * hist_img=cvCreateImage (cvSize (h_bins * scale, s_bins * scale), 8, 3);
CvHistogram * hist.
Float max_value=https://bbs.csdn.net/topics/0;
Int h, s,
CvCvtColor (SRC, HSV, CV_BGR2HSV);
CvCvtPixToPlane (HSV, h_plane s_plane v_plane, 0).
Hist=cvCreateHist (2, hist_size, CV_HIST_ARRAY, ranges, 1);
CvCalcHist (planes, hist, 0, 0);
CvGetMinMaxHistValue (hist, 0, & amp; Max_value, 0, 0);
CvZero (hist_img);
For (h=0; H & lt; H_bins; H++)
{
For (s=0; S & lt; S_bins; S++)
{
Float bin_val=cvQueryHistValue_2D (hist, h, s);
Int intensity=cvRound (bin_val * 255/max_value);
CvRectangle (hist_img, cvPoint (scale, h * s * scale),
CvPoint ((h + 1) *, scale - 1 (s + 1) * scale - 1),
CV_RGB (intensity, intensity, intensity),/* graw a grayscale histogram.
If you have the idea how to do it
Nicer let us know */
CV_FILLED);
}
}
CvNamedWindow (" Source ", 1);
CvShowImage (" Source ", SRC);
CvNamedWindow (" H - S Histogram ", 1);
CvShowImage (" H - S Histogram, "hist_img);
CvWaitKey (0);
}
}
CodePudding user response:
Consider first transformed into grayscale and color correctionCodePudding user response:
Dare ask the building Lord, finally USES the what's the solution?