I'm trying to create a blank image (later to be filled) using OpenCV, but it has to be in the same size with the predefined image as a new image. I tried the following code:
(image would be the picture of lena which is successfully displayed)
Mat lena1(Size(image.cols,image.rows),CV_8UC1);
namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
//imshow( "Display Image", image );
imshow("blank", lena1);
But for some reason, it still shows "image" and not lena1 (that would be the blank image with the same sizes of the predefined image).
Thank you!
imshow
displays blank picture.lena1(Size(image.cols,image.rows),CV_8UC1);
is not correct way to create blank image. It initializes image with random values or perhaps we should say it leaves image as uninitialized, you should use overload takingScalar
with all components set to 0:lena1(Size(image.cols,image.rows),CV_8UC1,cv::Scalar());