Ask Your Question
2

How to initialize Mat size and fill it with zeros in a class ?

asked 2016-11-16 01:53:49 -0600

Nbb gravatar image

updated 2016-11-16 02:02:11 -0600

How do I initialize a Mat with a certain size and fill it with zeros in a class ? The simple

cv::Mat test(cv::Size(1, 49), CV_64FC1);

does not work. Sorry this worked

cv::Mat texture_ = cv::Mat::zeros(cv::Size(1,49), CV_64FC1);
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
6

answered 2016-11-16 02:00:33 -0600

berak gravatar image
// #1
cv::Mat test(cv::Size(1, 49), CV_64FC1);
test = 0;

// #2
cv::Mat test(cv::Size(1, 49), CV_64FC1, Scalar(0)); 

// #3
cv::Mat test = cv::Mat::zeros(cv::Size(1, 49), CV_64FC1);
edit flag offensive delete link more
0

answered 2020-04-07 02:19:03 -0600

Scott_777 gravatar image

How about this:

Mat new_img = Mat::zeros(1, 49, CV_64FC1);

Or if you wanna create a Mat similar like some existing image:

Mat new_img = Mat::zeros(old_img.rows, old_img.cols, CV_64FC1);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-11-16 01:53:49 -0600

Seen: 122,920 times

Last updated: Nov 16 '16