您的位置:首页 > 编程语言 > MATLAB

roifilt2 在MATLAB中的用法

2017-11-17 11:18 344 查看
roifilt2

Filter region of interest (ROI) in image

collapse all in page
Syntax

J = roifilt2(h, I, BW)
J = roifilt2(I, BW, fun)

Description

J = roifilt2(h, I, BW) filtersthe data in I with the two-dimensional linear filter h. BW isa binary image the same size as I that definesan ROI used as a mask for filtering. roifilt2 returnsan image that consists of filtered values for pixels in locationswhere
BW contains 1's, and unfiltered values forpixels in locations where BW contains 0's. Forthis syntax, roifilt2 calls filter2 toimplement the filter.

J = roifilt2(I, BW, fun) processesthe data in I using the function fun.The result J contains computed values for pixelsin locations where BW contains 1's, and the actualvalues in I for pixels in locations where BW contains0's. fun must be a functionhandle.
Parameterizing Functions,in the MATLAB Mathematics documentation, explains how to provide additionalparameters to the function fun. 

Class Support

For the syntax that includes a filter h,the input image can be logical or numeric, and the output array J hasthe same class as the input image. For the syntax that includes afunction, I can be of any class supported by fun,and the class of J depends on the
class of theoutput from fun.
Examples
This example continues the roipoly example,filtering the region of the image I specified bythe mask BW. The roifilt2 functionreturns the filtered image J, shown in the followingfigure.

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);

figure, imshow(I), figure, imshow(J)

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: