Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 2015-12-11 00:56:47 -0600

Nbb gravatar image

Mat ROI boundary issue

Hello forum,

Given an image of size 100x100, I would like to set a region of size 3x3 to zero. I receive an error when the mid point is designated at (0,0) or the boundary. Can anyone help me on this ? Thanksimage description

Mat ROI boundary issue

Hello forum,

Given an image of size 100x100, I would like to set a region of size 3x3 to zero. I receive an error when the mid point is designated at (0,0) or the boundary. Can anyone help me on this ? Thanksimage description

Mat image = imread("box.jpg");

Point center = Point(0,0);

Point tl = center - Point(1,1);
Point br = center + Point (1,1);

Rect roi = Rect(tl, br);
Mat image_roi = image(roi);
image_roi.setTo(0);

I know it is an error because tl = (-1,-1). What should i include to ensure that the rectangle does not go out of bounds when center = (0,0) ie. roi = Rect(Point(0,0), Point (1,1))

or when center is at the boundary. How does the filter/convolution function in opencv work without going out of bounds ?