title: Trying to manipulate the saturation on a image on OpenCV
body: <p>I'm trying to create a Lpr algorithm in Opencv. I'm applying to the image things like grayscale and canny; but also I need to apply saturation to the image, and that is my issue:</p>
  
  <p>This is the code (I extract this code from this page <a href="http://hasanaga.info/tag/opencv-saturation/" rel="nofollow">http://hasanaga.info/tag/opencv-saturation/</a>):</p>
  
  <pre><code>void saturation(cv::Mat &amp;img)
  {
      Mat imagen;
      cvtColor(img,imagen,CV_RGB2HSV);
  
      for(int y=0; y&lt;imagen.cols; y++)
      {
          for(int x=0; x&lt;imagen.rows; x++)
          {
              int cur2 = imagen.at&lt;Vec3b&gt;(Point(y,x))[1];
              cur2 += 41;
              if(cur2 &lt; 0) cur2= 0; else if(cur2 &gt; 255) cur2 = 255;
              imagen.at&lt;Vec3b&gt;(Point(y,x))[1] = cur2;
          }
      }
  
      cvtColor(imagen,img,CV_HSV2RGB);
  
  }
  </code></pre>
  
  <p>(I change a little bit the code, cause I don't need to change the other parameters)</p>
  
  <p>But when I try to create the executable, this happen:</p>
  
  <blockquote>
    <p>OpenCV Error: Assertion failed ((scn == 3 || scn == 4) &amp;&amp; (depth == CV_8U || depth == CV_32F)) in cvtColor, file /home/guerrero/opencv2.4.9/opencv-2.4.9/modules/imgproc/src/color.cpp, line 3959
    terminate called after throwing an instance of 'cv::Exception'
      what():  /home/guerrero/opencv2.4.9/opencv-2.4.9/modules/imgproc/src/color.cpp:3959: error: (-215) (scn == 3 || scn == 4) &amp;&amp; (depth == CV_8U || depth == CV_32F) in function cvtColor</p>
  </blockquote>
  
  <p>May I know what cause the error?</p>