Neighborhood Processing 119
and the window size of the filter is automatically generated from the σ values.
5.10 Region of Interest Processing
Often we may not want to apply a filter to an entire image, but only to a s mall region
within it. A non-linear filter, for example, may be too computationally expensive to apply
to the entire image, or we may only be interested in the small region. Such small regions
within an image are called regions of interest or ROIs, and their processing is called region
of interest processing.
Regions of Interest in MATLAB
Before we can process a ROI, we have to define it. There are two ways: by listing the
coordinates of a polygonal region; or interactively, with the mouse. For example, suppose
we take part of a monkey image:
MATLAB/Octave
>> m2 = imread(’monkey.png’);
>> m = m2(56:281,221:412);
and attempt to isolate its head. If the image is viewed with impixelinfo, then the co-
ordinates of a hexagon that enclose the head can be determined to be ( 60, 14), (27, 38),
(14, 127), (78, 177), ( 130, 160) and (139, 69), as shown in Figure 5.25. We can then define a
region of interest using the
roipoly f unction:
MATLAB/Octave
>> xi = [60 27 14 78 130 139]
>> yi = [14 38 127 177 160 69]
>> roi=roipoly(m,yi,xi);
Note that the ROI is defined by two sets of coordinates: first the columns and then the
rows, taken in order as we traverse the ROI from vertex to vertex. In general, a ROI mask
will be a binary image the same size as the original image, with 1s for the ROI, and 0s
elsewhere. The function
roipoly can also be used interactively:
MATLAB/Octave
>> roi=roipoly(m);
This will bring up the monkey image (if it isn’t shown already). Vertices of the ROI can be
selected with the mouse: a left click selects a new vertex, backspace or delete removes the
most recently chosen vertex, and a right click finishes the selection.
Region of Interest Filtering
One of the simplest operations on a ROI is spatial filtering; this is implemented with the
function
roifilt2. With the monkey image and the ROI found above, we can experiment: