Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

draw histogram output

Hi

I have got the histogram of Y channel of YCrCb

the output after drawing with this code

 int hist_w = 512; int hist_h = 400;
int bin_w = cvRound( (double) hist_w/histSize );
Mat histImage( hist_h, hist_w, CV_8UC3, Scalar( 0,0,0) );

 normalize(b_hist, b_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat());

// Draw for each channel

for( int i = 1; i < histSize; i++ )

{
line( histImage, Point( bin_w*(i-1), hist_h - cvRound(b_hist.at<float>(i-1)) ) , Point( bin_w*(i), hist_h - cvRound(b_hist.at<float>(i)) ), Scalar( 255, 0, 0), 2, 8, 0 );

}

is :

Output

I want to draw it like this :

another drawing

click to hide/show revision 2
No.2 Revision

draw cumulative histogram output

Hi

I have got the histogram of Y channel of YCrCb

the output after drawing with this code

 int hist_w = 512; int hist_h = 400;
int bin_w = cvRound( (double) hist_w/histSize );
Mat histImage( hist_h, hist_w, CV_8UC3, Scalar( 0,0,0) );

 normalize(b_hist, b_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat());

// Draw for each channel

for( int i = 1; i < histSize; i++ )

{
line( histImage, Point( bin_w*(i-1), hist_h - cvRound(b_hist.at<float>(i-1)) ) , Point( bin_w*(i), hist_h - cvRound(b_hist.at<float>(i)) ), Scalar( 255, 0, 0), 2, 8, 0 );

}

is :

Output

I want to draw it like this :

another drawing

draw cumulative histogram output

Hi

I have got the histogram of Y channel of YCrCb

the output after drawing with this code

 int hist_w = 512; int hist_h = 400;
int bin_w = cvRound( (double) hist_w/histSize );
Mat histImage( hist_h, hist_w, CV_8UC3, Scalar( 0,0,0) );

 normalize(b_hist, b_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat());

// Draw for each channel

for( int i = 1; i < histSize; i++ )

{
line( histImage, Point( bin_w*(i-1), hist_h - cvRound(b_hist.at<float>(i-1)) ) , Point( bin_w*(i), hist_h - cvRound(b_hist.at<float>(i)) ), Scalar( 255, 0, 0), 2, 8, 0 );

}

is :

Output

I want to draw it like this :

another drawing