Ask Your Question
0

How to set custom ROI

asked 2013-07-23 15:59:08 -0600

Innam Hunzai gravatar image

Hello I am beginner in OpenCv C++... I want to set custom region of interest for processing.... like my camera is fixed in one place and i want to capture the image of some specific area... it can be of triangle shape... what i want is the rest of image shld be black except tht triangular ROI....

I searched a lot and i found for rectangular region only... :( Thanks

edit retag flag offensive close merge delete

Comments

please mention, how you get your triangle roi (or, whatever shape it is)

berak gravatar imageberak ( 2013-07-23 17:10:44 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-07-23 16:54:03 -0600

berak gravatar image

updated 2013-07-23 17:02:01 -0600

if you can make a mask-image of that "special roi", it's all easy.

many opencv image ops take binary masks (to reduce the processed pixels),

you can even use them directly, i.e :

Mat mask_out = gray_image & mask

would leave only the pixels from gray_image in mask_out, where mask was non-null

edit flag offensive delete link more

Comments

Thanks for reply... I already have sample code for mask also.. but it seems that mask is also of rectangular shape... I want different shape like parallelogram or other thing....

Innam Hunzai gravatar imageInnam Hunzai ( 2013-07-23 18:41:46 -0600 )edit
1

A mask isn't always rectangular, it can be of any shape, since you can manually define the pixel value of each element of the mask, being 0 or 1. This approach works with about every binary mask you can imagine.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-24 08:52:30 -0600 )edit
0

answered 2013-07-23 16:55:28 -0600

The interest of ROI is to speed-up computation, therefore, a triangular ROI seems problematic. But, if you are only interested to have a part of your image, you could create a ROI bounding to your triangular area, and add a mask, of the ROI size, that specify the pixels to keep. After, just copy the ROIed image with the mask as third parameter, you will get the triangular ROI-like. But again, the interest has to be specific (hide parts of the image, prevent from annoying moving background,...) but not speed-up has you involve an extra copy of data.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-07-23 15:59:08 -0600

Seen: 3,441 times

Last updated: Jul 23 '13