This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

ROI-Based Processing

Define and operate on regions of interest (ROI)

A region of interest (ROI) is a portion of an image that you want to filter or perform some other operation on. You define an ROI by creating a binary mask, which is a binary image that is the same size as the image you want to process. In the mask image, the pixels that define the ROI are set to 1 and all other pixels set to 0.

You can define more than one ROI in an image. The regions can be geographic in nature, such as polygons that encompass contiguous pixels, or defined by a range of intensities. In the latter case, the pixels are not necessarily contiguous.


roipoly Specify polygonal region of interest (ROI)
poly2mask Convert region of interest (ROI) polygon to region mask
regionfill Fill in specified regions in image using inward interpolation
roicolor Select region of interest (ROI) based on color
roifilt2 Filter region of interest (ROI) in image
imellipse Create draggable ellipse
imfreehand Create draggable freehand region
impoly Create draggable, resizable polygon
imrect Create draggable rectangle
imroi Region-of-interest (ROI) base class


Overview of ROI Filtering

Filtering a region of interest (ROI) is the process of applying a filter to a region in an image, where a binary mask defines the region.

Create Binary Mask From Grayscale Image

This section describes how to create binary masks to define ROIs.

Create Binary Mask Using an ROI Object

You can use the createMask method of the imroi base class to create a binary mask for any type of ROI object — impoint, imline, imrect, imellipse, impoly, or imfreehand.

Create Binary Mask Without an Associated Image

Using the createMask method of ROI objects you can create a binary mask that defines an ROI associated with a particular image.

Create ROI Based on Color Values

You can use the roicolor function to define an ROI based on color or intensity range.

Apply Filter to Region of Interest in an Image

This example shows how to use masked filtering to increase the contrast of a specific region of an image.

Apply Custom Filter to Region of Interest in Image

This example shows how to filter a region of interest (ROI), using the roifilt2 function to specify the filter.

Fill Region of Interest in an Image

This example shows how to use regionfill to fill a region of interest (ROI) in an image.

Was this topic helpful?