Ask Your Question

Question about Mat::create

asked 2017-11-02 09:15:45 -0500

yode gravatar image

This is my srcImage

image description

When I use this code

Mat srcImage = imread("1.jpg", 0),test;  

I will ge such dstImage

image description

Note the place pointed by yellow arrow. I get so many white noise. It is a intention or a bug of OpenCV?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-11-02 09:28:20 -0500

Tetragramm gravatar image

Create simply allocates memory to hold an image in the size and shape requested. It guarantees nothing about the contents of the memory.

You can either use the constructor with a default value, or the setTo function after the create to set the contents.

edit flag offensive delete link more


It your theory or anywhere you have referenced?

yode gravatar imageyode ( 2017-11-02 11:50:21 -0500 )edit

See the documentation HERE. Note the absence of a step that sets the values. Also note that if it matches the size and shape already, it returns immediately, leaving the existing data intact.

Tetragramm gravatar imageTetragramm ( 2017-11-02 12:36:21 -0500 )edit

Question Tools

1 follower


Asked: 2017-11-02 09:15:45 -0500

Seen: 199 times

Last updated: Nov 02 '17