filter2 只能对二维图像(灰度图)进行空间滤波
两个函数结果类型不一样,只需要在I1=filter2(h,I)后面加上I1=uint8(I1)进行类型转换,结果就是一样的。
imfilter
N-D filtering of multidimensional images.
B = imfilter(A,H) filters the multidimensional array A with the
multidimensional filter H. A can be logical or it can be a
nonsparse numeric array of any class and dimension. The result,
Each element of the output, B, is computed using double-precision
floating point. If A is an integer or logical array, then output
elements that exceed the range of the given type are truncated,
and fractional values are rounded. B, has the same size and class as A.
filter2
Two-dimensional digital filter.
Y = filter2(B,X) filters the data in X with the 2-D FIR
filter in the matrix B. The result, Y, is computed
using 2-D correlation and is the same size as X.
Y = filter2(B,X,SHAPE) returns Y computed via 2-D
correlation with size specified by SHAPE: