Filter region of interest (ROI) in image
J = roifilt2(h,I,BW)
J = roifilt2(I,BW,fun)
filters regions of interest (ROIs) in the 2-D image
J = roifilt2(
I using the
2-D linear filter
BW is a binary mask,
the same size as
I, that defines the ROIs in
roifilt2 returns an image that
consists of filtered values for pixels in locations where
1s, and unfiltered values for pixels in locations where
Read an image into the workspace.
I = imread('eight.tif');
Define the vertices of the mask polygon.
c = [222 272 300 270 221 194]; r = [21 21 75 121 121 75];
Create the binary mask image.
BW = roipoly(I,c,r);
Filter the region of the image
I specified by the mask
H = fspecial('unsharp'); J = roifilt2(H,I,BW);
Display the original image and the filtered image.
h— Linear filter
Linear filter, specified as a 2-D numeric matrix.
Mask, specified as a 2-D logical matrix or a 2-D numeric matrix, the same