roifilt2 在MATLAB中的用法

本文介绍MATLAB中roifilt2函数的应用,该函数能够针对图像中的指定区域进行过滤处理。通过使用二进制掩模定义感兴趣区域,并结合线性过滤器或自定义函数实现精确过滤效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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)



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值