title: countNonZero function gives an assertion error in openCV
body: <p>I tried to get horizontal projection using countNonZero() function as below.</p>
  
  <pre><code>Mat src = imread(INPUT_FILE, CV_LOAD_IMAGE_COLOR);
  Mat binaryImage = src.clone();
  cvtColor(src, src, CV_BGR2GRAY);
  
  Mat horizontal = Mat::zeros(1,binaryImage.cols, CV_8UC1);
  
  for (int i = 0; i&lt;binaryImage.cols; i++)
  {
      Mat roi = binaryImage(Rect(0, 0, 1, binaryImage.rows));
  
      horizontal.at&lt;int&gt;(0,i) = countNonZero(roi);
      cout &lt;&lt; "Col no:" &lt;&lt; i &lt;&lt; " &gt;&gt;" &lt;&lt; horizontal.at&lt;int&gt;(0, i);
  }
  </code></pre>
  
  <p>But an error is occured in the line of calling countonZero() function. Error is as follows. </p>
  
  <pre><code>    OpenCV Error: Assertion failed (src.channels() == 1 &amp;&amp; func != 0) in cv::countNo
      nZero, file C:\builds\2_4_PackSlave-win32-vc12-shared\opencv\modules\core\src\st
      at.cpp, line 549
  </code></pre>
  
  <p>Can somebody please point out the mistake?</p>