图像处理中的卷积---2.高斯卷积

来源:互联网 发布:mysql中文读出来乱码 编辑:程序博客网 时间:2024/05/29 19:34

经过上面一篇博文,介绍了卷积的意义。

那么图像处理中的卷积可以理解为(2D/3D)的函数卷积,也就是在某个移动窗口内的加权(权值由kernel给定)求和。


下面我们给出gaussian kernel做卷积的例子,另附MATLAB实现方法。




sigma = 3;
% you can set the sigma yourselfWx = floor(3*sigma);% Wx 的确定是根据gaussian函数的分布集中在【Mu-3Sigma, Mu+3sigma]内x = -Wx:Wx;g = exp(-(x.^2)/(2*sigma^2));kernel = conv2( g, g');I =  imread( 'cameraman.gif' );I = double( I );Ig = conv2(I, kernel);  %Use kernel to convolution with Input imagefigure(1); subplot(1,3,1); imagesc(I); axis image; colormap(gray);       title('Input Image');subplot(1,3,2); imagesc(kernel); axis image; colormap(gray);  title('Gaussian kernel');subplot(1,3,3); imagesc(Ig); axis image; colormap(gray);      title('Output Image');

0 0
原创粉丝点击