imfilter函式

imfilter函式

imfilter函式是一種計算機函式,也叫做實現線性空間濾波函式,功能是對任意類型數組或多維圖像進行濾波,函式形式是B = imfilter(A,H)。

基本介紹

  • 中文名:imfilter函式
  • 外文名:imfilter
  • 函式形式:B = IMFILTER()
  • 注意事項:To disable IPPL
  • 函式功能:對數組或多維圖像進行濾波
imfilter函式解釋,函式形式,注意事項,舉例,

imfilter函式解釋

用法:B = imfilter(A,H)
B = imfilter(A,H,option1,option2,...)
或寫作g = imfilter(f, w, filtering_mode, boundary_options, size_options)其中,f為輸入圖像,w為濾波掩模,g為濾波後圖像。filtering_mode用於指定在濾波過程中是使用“相關”還是“卷積”。boundary_options用於處理邊界充零問題,邊界的大小由濾波器的大小確定。具體參數選項見下表:
選項
描述
filtering_mode
‘corr’
通過使用相關來完成,該值為默認。
‘conv’
通過使用卷積來完成
boundary_options
‘X’
輸入圖像的邊界通過用值X(無引號)來填充擴展
其默認值為0
‘replicate’
圖像大小通過複製外邊界的值來擴展
‘symmetric’
圖像大小通過鏡像反射其邊界來擴展
‘circular’
圖像大小通過將圖像看成是一個二維周期函式的一個周期來擴展
size_options
‘full’
輸出圖像的大小與被擴展圖像的大小相同
‘same’
輸出圖像的大小與輸入圖像的大小相同。這可通過將濾波掩模的中心點的偏移限制到原圖像中包含的點來實現,該值為默認值。

舉例:originalRGB = imread('peppers.png');
imshow(originalRGB)
h = fspecial('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 outside the bounds of the array
are implicitly assumed 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)

相關詞條

熱門詞條

聯絡我們