
imfilter函数是一种计算机函数,也叫做实现线性空间滤波函数,功能是对任意类型数组或多维图像进行滤波,函数形式是B = imfilter(速半地调省首攻够A,H)。
- 中文名称 imfilter函数
- 外文名称 imfilter
- 函数形式 B = IMFILTER()
- 注意事项 To disable IPPL
- 函数功能 对数组或多维图像进行滤波
imfilter函数解释
用法:B = imfilter(A,H)
B = i何领mfilter(来自A,H,option1,option2,...)
或写作g = imfilter(f, w, fil消调有剂统解tering_mode, 360百科boundary_options, size_options)其中,f为输入图像,w为滤波掩模,g为滤波后图像。fil绍也苏tering_mode用于指定在滤波过程雨例殖中是使用"相关"还是"卷积"。利牛配曲织族击析boundary_options用于处理边界抓物事联曾输国针课充零问题,边界的大小由滤波器的大小确定。具体参数选项见下表:
选项 | 描述 | |
filtering_mode | 'corr' | 通过使用相关来完成垂余知微非,该值为默认。 |
'conv' | 通过使用卷积来完成 | |
bounda谓氧斤ry_options | 'X' | 输入图像的边界通过用值X(无引号)来填充扩展 其默认值为0 |
'replicate' | 图像大小通过复制外边界的值来扩展 | |
'symmetric' | 图像大小通过镜像反射其边调界来扩展 | |
'circular' | 图像大小通过将图像看成是一个二刚听六体粒印做开维周期函数的一个周期来扩展 | |
size_options | 'full' | 输出图像的大小与被扩展图像的大小相同 |
'same' | 输出图像的大小与输入图像的大小相同。这可通过将滤波掩模的中心点的偏移限制到原图像中包含的点来实现,该值为默认值。 |
举例:originalRGB = imread('peppers.png');
imshow(伤二甲异序胞织originalRGB)
h = fspecia办白l('motion', 50, 45);%创建一个滤波器
filteredRGB = imfilter(originalRGB, h);
figure, imshow(filteredRGB)
函数形式
B = IMFILTER(A,H,OPTION1,OPTION2,...) performs multidimensional
李百教名官特感控乐 filtering according to the specified options. Option arguments can
have the following values:
- Boundary options
X Input array values ou起础怀香tside the bou倒物反回陈看呀赶nds of the array
办 are impl节儿前口火题触以但去icitly assum吸司是新球推ed to have the value X. When no
boundary option is specified, IMFILTER uses X = 0.
'symmetric' Input array values outside the bounds of the array
are computed by mirror-reflecting the array across
the array border.
'replicate' Input array values outside the bounds of the array
are assumed to equal the nearest array border
value.
'circular' Input array values outside the bounds of the array
are computed by implicitly assuming the input array
is periodic.
- Output size options
(Output size options for IMFILTER are analogous to the SHAPE option
in the functions CONV2 and FILTER2.)
'same' The output array is the same size as the input
array. This is the default behavior when no output
size options are specified.
'full' The output array is the full filtered result, and so
is larger than the input array.
- Correlation and convolution
'corr' IMFILTER performs multidimensional filtering using
correlation, which is the same way that FILTER2
performs filtering. When no correlation or
convolution option is specified, IMFILTER uses
correlation.
'conv' IMFILTER performs multidimensional filtering using
convolution.
注意事项
Notes
-----
On some Intel Architecture processors, IMFILTER can take advantage of the
Intel Performance Primitives Library (IPPL), thus accelerating its execution
time. IPPL is activated only if A and H are both two dimensional and A is
uint8, int16 or single.
When IPPL is used, imfilter has different rounding behavior on some
processors. Normally, when A is an integer class, filter outputs such as
1.5, 4.5, etc., are rounded away from zero. However, when IPPL is used,
these values are rounded toward zero. This behavior may change in a future
release.
To disable IPPL, use this command:
iptsetpref('UseIPPL',false)
举例
Example
-------------
originalRGB = imread('peppers.png');
h = fspecial('motion',50,45);
filteredRGB = imfilter(originalRGB,h);
figure, imshow(originalRGB), figure, imshow(filteredRGB)
boundaryReplicateRGB = imfilter(originalRGB,h,'replicate');
figure, imshow(boundaryReplicateRGB)
评论留言