Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. Draw your rectangle to new binary image with thickness=CV_FILLED

  2. Invert above binary image and create mask for your inrested 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 dont know what process you are going to do, and if it not use the neighbor pixel like filter, the above may work fine.

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

  2. Invert above binary image and create mask for your inrested 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 dont 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 filtering 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.

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

  2. Invert above binary image and create mask for your inrested 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 filtering 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.