Ask Your Question
0

Operation on specific part of image

asked 2014-04-02 11:56:46 -0600

FLY gravatar image

I want to play with the part of the image outside the circle , i want to put some algorithms on image area which is outside the rectangle , Can i do this task and how can i do it , which way i need to follow

image description

And can I apply the same functionalities without drawing rectangle on the image ? mean to say not to draw the rectangle on image and leave that area for further operations , just mention its angle without drawing it

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2014-04-02 13:19:05 -0600

Haris gravatar image

updated 2014-04-02 22:48:08 -0600

  1. Draw your rectangle to new binary image with thickness=CV_FILLED

  2. Invert above binary image and create mask for your interested region.

  3. Copy the source to new Mat and perform your operation.

  4. Finally copy the processed image to your source image using the same mask.

I don't know what process you are going to do, and if it not use the neighbor pixel like filter, the above may work fine.

Edit:

While doing filter operation using above method, the black region in the mask boundary will also consider as a neighbor, so better approach is

  1. Create mask using your Rect.

  2. Copy source to new Mat using above mask((the part you need to exclude).

  3. Process the entire source.

  4. Later copy back the region of exclusion to processed image using above mask.

edit flag offensive delete link more

Comments

yes i have to do filtering like neighbour pixel filtering , i will give shades like gray on remaining image

FLY gravatar imageFLY ( 2014-04-02 13:31:39 -0600 )edit

Thanks ,Can we do this with all type of shapes like circle and ellipse ?

FLY gravatar imageFLY ( 2014-04-03 00:47:34 -0600 )edit

Yes, you can choose any shape, only thing is that mask should same as shape.

Haris gravatar imageHaris ( 2014-04-03 01:00:37 -0600 )edit

but how i can make it work like ellipse const mask(img,Point(20,40), Size(60,40),0,0,360, Scalar(0,0,0));cv::Mat roi = image(mask);

FLY gravatar imageFLY ( 2014-04-03 01:17:42 -0600 )edit

Just use thickness=CV_FILLED as I mentioned above. ellipse(mask,Point(20,40), Size(60,40),0,0,360, Scalar(0,0,255), CV_FILLED, 8,0); go documentation and read parameter for ellipse()

Haris gravatar imageHaris ( 2014-04-03 02:00:37 -0600 )edit

Question Tools

Stats

Asked: 2014-04-02 11:56:46 -0600

Seen: 2,121 times

Last updated: Apr 02 '14