Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are making two mistakes here.</p> <p>While reading the image, you are specifying 1 as input arguments. As explained for <a href="http://docs.opencv.org/doc/tutorials/introduction/display_image/display_image.html#explanation" rel="nofollow">imread</a>, the function can read image in three different formats.</p> <blockquote> <p>CV_LOAD_IMAGE_UNCHANGED (&lt;0) loads the image as is (including the alpha channel if present) CV_LOAD_IMAGE_GRAYSCALE ( 0) loads the image as an intensity one<br> CV_LOAD_IMAGE_COLOR (>0) loads the image in the RGB format</p> </blockquote> <p>for your case you will have to use <code>CV_LOAD_IMAGE_GRAYSCALE</code> as the second argument</p> <p>In the next step where you are using: <code>image.at&lt;unsigned&gt;(0,1);</code> which does not correspond to anything. you use <code>&lt;unsigned&gt;</code> but the compiler says "UNSIGNED? UNSIGNED what???"</p> <p>I believe a better way to do this is to use correct labels like <code>CV_LOAD_IMAGE_COLOR</code> or <code>CV_LOAD_IMAGE_GRAYSCALE</code>. In the example below, I am reading the image into one channel (<code>CV_LOAD_IMAGE_GRAYSCALE</code>), which automatically converts it to grayscale.</p> <pre><code>#include &lt;cv.h&gt; #include &lt;highgui.h&gt; #include &lt;iostream&gt; using namespace std; using namespace cv; int main() { Mat gImg = imread("img.png", CV_LOAD_IMAGE_GRAYSCALE); uchar val; val = gImg.at&lt;uchar&gt;(0,0); cout &lt;&lt; (int)val &lt;&lt; endl; imshow("showImg",gImg); cvWaitKey(0); return 1; } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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