title: OpenCV for Android: Error when i convert color image to grayscale
body: <p>I want to convert color image to grayscale. For that I am using cvtColor() method of openCV but its giving following error:</p>
  
  <p><code>OpenCV Error: Assertion failed (scn == 1 &amp;&amp; (dcn == 3 || dcn == 4)) in void cv::cvtColor(cv::InputArray, cv::OutputArray, int, int), file /home/reports/ci/slave_desktop/50-SDK/opencv/modules/imgproc/src/color.cpp, line 3789</code></p>
  
  <p>This is my code :</p>
  
  <pre><code>img= Highgui.imread(pathToImage);
  
      /*Mat convert= new Mat(img.size(), CvType.CV_8UC3);
  converted=new Mat(img.size(), CvType.CV_8UC3, new Scalar(255,
          255, 255));*/
      Imgproc.cvtColor(img,img,Imgproc.COLOR_GRAY2RGBA,0); 
  
  
  
      Imgproc.threshold(finalresult, converted, 254, 255, 1 /* THRESH_BINARY_INV */);     
  
      bitmap1=Bitmap.createBitmap(finalresult.cols(), finalresult.rows(), Bitmap.Config.ARGB_8888);
  
      System.out.println(""+finalresult);
  
      Utils.matToBitmap(finalresult, bitmap1);
  
      canvas = new Canvas(bitmap1);
  
      iv.setImageBitmap(bitmap1);
      }catch(Exception e)
      {
          System.out.println(e.toString());
      }
  </code></pre>