Ask Your Question
0

insert a frame to mat , instead of coloring the whole Mat

asked 2015-11-06 18:34:10 -0600

215 gravatar image

I know that to retrieve a ROI from the image you would usually do something like

Mat image(Rect(x,y,sx,sy))

And to color at the rectangle you would just

Mat image(Rect(x,y,sx,sy)) = 255

But if only want to create a frame with that pixelvalue such that some of the center elements isn't touched.. what shall i do?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-11-07 02:16:09 -0600

LBerger gravatar image

May be like this using mask and function setTo :

Mat im=Mat::zeros(512,512,CV_8UC1);
Rect r(200,200,100,100);
Mat mask=Mat::zeros(512,512,CV_8UC1);
mask(r)=255;

bitwise_not(mask,mask);
im.setTo(255,mask);
imshow("mask ",im);
waitKey();
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-11-06 18:34:10 -0600

Seen: 959 times

Last updated: Nov 07 '15