Image Processing Toolbox User's Guide |
Filter a region of interest in an image
Syntax
Description
J = roifilt2(h,I,BW)
filters the data in I
with the two-dimensional linear filter h
. BW
is a binary image the same size as I
that is used as a mask for filtering. roifilt2
returns an image that consists of filtered values for pixels in locations where BW
contains 1's, and unfiltered values for pixels in locations where BW
contains 0's. For this syntax, roifilt2
calls filter2
to implement the filter.
J = roifilt2(I,BW,fun)
processes the data in I
using the function fun
. The result J
contains computed values for pixels in locations where BW
contains 1's, and the actual values in I
for pixels in locations where BW
contains 0's.
fun
must be a function handle.
Class Support
For the syntax that includes a filter h
, the input image can be logical or numeric, and the output array J
has the same class as the input image. For the syntax that includes a function, I
can be of any class supported by fun
, and the class of J
depends on the class of the output from fun
.
Example
This example continues the roipoly
example.
I = imread('eight.tif'); c = [222 272 300 270 221 194]; r = [21 21 75 121 121 75]; BW = roipoly(I,c,r); h = fspecial('unsharp'); J = roifilt2(h,I,BW); imshow(J), figure, imshow(J)
See Also
imfilter
, filter2
, function_handle
, roipoly
roifill | roipoly |
© 1994-2005 The MathWorks, Inc.