Ask Your Question
0

GrabCut Sample code in Opencv

asked 2013-06-09 23:09:10 -0500

waqasp gravatar image

C:\fakepath\neckless.jpg

Hello all, I am using grabcut sample code from opencv as a part of my project... the final image which i am getting after using that sample code contain black background... according to me, it is because of the mask....?? i have tried everything to change the background to white or transparent...

what modification should i make to the sample code to get final image with white or transparent background...

thanks,

edit retag flag offensive close merge delete

Comments

anyone ??/

waqasp gravatar imagewaqasp ( 2013-06-10 04:40:54 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
5

answered 2013-06-11 05:09:08 -0500

Vladislav Vinogradov gravatar image

Try to set your background before image copying:

Mat res(image.size(), image.type());

// fill background
res.setTo(Scalar::all(255)); // white

// copy foreground
image.copyTo(res, binMask);
edit flag offensive delete link more

Comments

Thanks alot my friend... really appreciate your support:)

waqasp gravatar imagewaqasp ( 2013-06-11 05:45:53 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-06-09 23:09:10 -0500

Seen: 920 times

Last updated: Jun 11 '13