The code below causes an exception. Why?
#include
#include
using namespace cv;
using namespace std;
void mai
You can use this to fill zeroes in a Mat object already containing data:
image1 = Scalar::all(0);
For eg, if you use it this way:
Mat image,image1;
image = imread("IMG_20160107_185956.jpg", CV_LOAD_IMAGE_COLOR); // Read the file
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
cvtColor(image,image1,CV_BGR2GRAY);
image1 = Scalar::all(0);
It will work fine. But you cannot use this for uninitialised Mat. For that you can go for other options mentioned in above answers, like
Mat drawing = Mat::zeros( image.size(), CV_8UC3 );