Ask Your Question
0

Mat reshape not reducing channel number

asked 2017-02-20 10:23:02 -0600

ginister gravatar image

updated 2017-02-20 10:46:57 -0600

Hi everyone, I get the error: error: (-215) mask.depth() == CV_8U && (mcn == 1 || mcn == cn) in function copyTo, when the following code runs. Why does reshape() not reduce the number of channels in mask to 1? I need a binary mask to find an object in the scene, however drawcontours() is giving me a grayscale 3 channel image, and my input image is 4 channels hence the error, but I thought reshape would fix this by reducing it to 1 channel. The printout of mcn states Mask has 3 channels.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-02-20 10:40:13 -0600

matman gravatar image

It must be mask = mask.reshape(1);

edit flag offensive delete link more

Comments

Of course! So simple... Thanks for pointing that out!

ginister gravatar imageginister ( 2017-02-20 10:42:45 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-02-20 10:23:02 -0600

Seen: 503 times

Last updated: Feb 20 '17