# Revision history [back]

### Perform functions on a ROI

Hi everyone!

I'm working on a project and I want to select a ROI with my mouse.

Then I want to do the following things:

• Make everything on the outside of the rectangle zero/black.
• Perform some thresholding functions in the ROI.
• Put it back in to the original image.

I don't know how to achieve this. Here's some pseudo code:

for loop to iterate through image{
{
if(point x and y are not the same as the roi x and y ){
make the pixel black
}
}

..perform some thresholding on ROI..

//copy roi back to image
image.copyTo(result, roi);


Can someone help me out here?

Thanks.

 2 retagged

### Perform functions on a ROI

Hi everyone!

I'm working on a project and I want to select a ROI with my mouse.

Then I want to do the following things:

• Make everything on the outside of the rectangle zero/black.
• Perform some thresholding functions in the ROI.
• Put it back in to the original image.

I don't know how to achieve this. Here's some pseudo code:

for loop to iterate through image{
{
if(point x and y are not the same as the roi x and y ){
make the pixel black
}
}

..perform some thresholding on ROI..

//copy roi back to image
image.copyTo(result, roi);


Can someone help me out here?

Thanks.