Ask Your Question
2

Saving an image with unset pixels

asked 2012-07-23 16:58:23 -0600

Pat gravatar image

updated 2016-01-22 16:08:14 -0600

What happens during imwrite if you specify a png image and that the passed mat has unset pixels? Are they treated as no opacity pixels? Because when I save I still get the gray value, so perhaps when I create a cv::Mat is it filled in gray by default?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
5

answered 2012-07-23 20:10:27 -0600

Hi Pat!

When you create a cv::Mat, the required memory is reserved for it and AFAIK that memory is not initialized to any value unless you specify it, with this constructor for example:

Mat::Mat(Size size, int type, const Scalar& s)

The cv::Mat will be initialized with any value that you assign to s. Otherwise the content of the matrix is not guaranteed to have any specific value, so the unset pixels will probably contain garbage (the values left after that memory was last used).

I hope this helps.

edit flag offensive delete link more

Comments

Thanks Martin, this has shed some light and it makes sense. I actually have more questions now though hehe.

Pat gravatar imagePat ( 2012-07-24 20:47:52 -0600 )edit
1

I am glad I could help . If you have more questions this forum is the right place :D The only thing I would recommend you is to post them as "new questions" instead of comments or answers to this one, this way we can keep the forum well organized and the access to info would be much easier for the rest of users.

Martin Peris gravatar imageMartin Peris ( 2012-07-24 20:59:55 -0600 )edit

Question Tools

Stats

Asked: 2012-07-23 16:58:23 -0600

Seen: 641 times

Last updated: Jul 23 '12