Ask Your Question
1

Question about Mat::create

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

yode gravatar image

This is my srcImage

image description

When I use this code

Mat srcImage = imread("1.jpg", 0),test;  
dstImage.create(srcImage.size(),srcImage.type());

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
3

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

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

Comments

It your theory or anywhere you have referenced?

yode gravatar imageyode ( 2017-11-02 11:50:21 -0600 )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 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 382 times

Last updated: Nov 02 '17