原文链接:https://blog.csdn.net/humanking7/article/details/46826105
核心提示
在Matlab中高斯滤波非常方便,主要涉及到下面两个函数:
函数: fspecial
函数: imfilter
代码实现
clear all;
clc;
%----------------------------------------------
%对图像进行高斯滤波,并显示图像
%----------------------------------------------
%读进图像
[filename, pathname] = uigetfile({'*.jpg'; '*.bmp'; '*.gif'; '*.png' }, '选择图片');
%没有图像
if filename == 0
return;
end
Image = imread([pathname, filename]);
[m, n, z] = size(Image);
%转换为灰度图
if z>1
Image = rgb2gray(Image);
end
sigma = 1;
gausFilter = fspecial('gaussian', [5,5], sigma);
gaus= imfilter(Ima