MATLAB中与图像处理有关的函数

来源:互联网 发布:个人怎样加入淘宝直播 编辑:程序博客网 时间:2024/05/01 12:13

1、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)

2、fspecial

功能:创建预定义的二维滤波器,在图像处理中就是一个模板即函数的返回值。
用法:h = fspecial(type)  带默认类型参数
           h = fspecial(type, parameters)  带指定的类型参数:parameters

   TYPE可能的值如下:

'average'   averaging filter,均值滤波器,即H = fspecial('average',HSIZE)参数HSIZE代表模板尺寸,默认值为[33]。
'disk'      circular averaging filter,圆形区域均值滤波器,即H = fspecial('disk',RADIUS),参数radius代表区域半径,默认值为5。
'gaussian'  Gaussian lowpass filter,高斯低通滤波器,即H = fspecial('gaussian',HSIZE,SIGMA),有两个参数,hsize表示模板尺寸,默认值为             [3 3],sigma滤波器的标准差,单位为像素,默认值为0.5。

'laplacian' filter approximating the 2-D Laplacian operator,接近二维拉普拉斯算子的滤波器,即H = fspecial('laplacian',ALPHA),参                 数alpha用于控制算子形状,取值范围为[01],默认值为0.2。
'log'       Laplacian of Gaussian filter,拉普拉斯高斯滤波器,即H = fspecial('log',HSIZE,SIGMA),有两个参数,hsize表示模板尺寸,默认             值为[3 3],sigma为滤波器的标准差,单位为像素,默认值为0.5。

'motion'    motion filter,运动滤波器,即H = fspecial('motion',LEN,THETA),有两个参数,表示摄像物体逆时针方向以theta角度运动了len个像               素,len的默认值为9theta的默认值为0。
'prewitt'   Prewitt horizontal edge-emphasizing filter,Prewitt水平边缘增强滤波器,即H = fspecial('prewitt'),大小为[3 3],无参数。
'sobel'     Sobel horizontal edge-emphasizing filter,Sobel水平边缘增强滤波,即H = fspecial('sobel'),大小为[3 3],无参数。

举例:I = imread('cameraman.tif');
       subplot(2,2,1);imshow(I);title('Original Image'); 
       H = fspecial('motion',20,45);
       MotionBlur = imfilter(I,H,'replicate');
       subplot(2,2,2);imshow(MotionBlur);title('Motion Blurred Image');
       H = fspecial('disk',10);
       blurred = imfilter(I,H,'replicate');
       subplot(2,2,3);imshow(blurred);title('Blurred Image');

0 0
原创粉丝点击