Note that there are some explanatory texts on larger screens.

plurals
  1. POMake histogram graph using 3 channel using opencv
    primarykey
    data
    text
    <p>I tried to plot histogram of a 3 channel image and "Unhandled exception at 0x752e812f in opencv_tut.exe: Microsoft C++ exception: cv::Exception at memory location 0x0019ef5c.." it keep getting this error. Cant even debug it keep getting into assembly.</p> <p>The problem is in the line drawing part in the histogram others just works fine.</p> <p>Here is the code:</p> <p>void colorHistogram(){</p> <pre><code>Mat image = imread("c:/aaa.jpg"); vector&lt;Mat&gt; bgr_planes; split(image, bgr_planes); if(!image.data){ cout&lt;&lt;"No image"&lt;&lt;endl; } int histSize = 256; float range[] = {0, 256}; const float* histRange = {range}; Mat b_hist, g_hist, r_hist; calcHist(&amp;bgr_planes[0], 1, 0, Mat(), b_hist, 1, &amp;histSize, &amp;histRange, true, false); calcHist(&amp;bgr_planes[1], 1, 0, Mat(), g_hist, 1, &amp;histSize, &amp;histRange, true, false); calcHist(&amp;bgr_planes[2], 1, 0, Mat(), r_hist, 1, &amp;histSize, &amp;histRange, true, false); 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()); normalize(g_hist, g_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat()); normalize(r_hist, r_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat()); for(int i=0; i&lt;histSize; i++){ line( histImage, Point( bin_w*(i-1), hist_h - cvRound(b_hist.at&lt;float&gt;(i-1))) , Point( bin_w*(i), hist_h - cvRound(b_hist.at&lt;float&gt;(i))), Scalar( 255, 0, 0), 2, 8, 0 ); line( histImage, Point( bin_w*(i-1), hist_h - cvRound(g_hist.at&lt;float&gt;(i-1))), Point( bin_w*(i), hist_h - cvRound(g_hist.at&lt;float&gt;(i))), Scalar( 0, 255, 0), 2, 8, 0 ); line( histImage, Point( bin_w*(i-1), hist_h - cvRound(r_hist.at&lt;float&gt;(i-1))) , Point( bin_w*(i), hist_h - cvRound(r_hist.at&lt;float&gt;(i))), Scalar( 0, 0, 255), 2, 8, 0 ); } namedWindow("Histogram", CV_WINDOW_AUTOSIZE); imshow("Histogram", histImage); </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload