title: cvtColor assertion failed ( OpenCV with C++ )
body: <p>I have a</p>
  
  <pre><code>cv::Mat image;
  </code></pre>
  
  <p>object, which I loaded an image to from a file, it reads it correctly and all.</p>
  
  <p>Now I have written a function to transform it to grey color.</p>
  
  <pre><code>cv::cvtColor(image, image, CV_RGB2GRAY);
  </code></pre>
  
  <p>And this error comes up:</p>
  
  <pre><code>OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /build/buildd/opencv-2.3.1/modules/imgproc/src/color.cpp, line 2834
  terminate called after throwing an instance of 'cv::Exception'
    what():  /build/buildd/opencv-2.3.1/modules/imgproc/src/color.cpp:2834: error: (-215) scn == 3 || scn == 4 in function cvtColor
  </code></pre>
  
  <p>what could be the problem?</p>
  
  <p>This is how I read the image (through an imagehandler class which has a member cv::Mat m_image)</p>
  
  <pre><code>imagehandler::imagehandler(const std::string&amp; fileName)
  : m_image(imread(fileName, CV_LOAD_IMAGE_COLOR))
  {
          if(!m_image.data)
  {
      cout &lt;&lt; "Failed loading " &lt;&lt; fileName &lt;&lt; endl;
  }
  
  }
  </code></pre>