图像卷积和滤波的区别
http://blog.csdn.net/zouxy09/article/details/49080029
clear,close all, clc
%% readimage
image =imread('test.jpg');
%% definefilter
% -----Identity filter -----
kernel =[0, 0, 0
0, 1, 0
0, 0, 0];
% -----Average Blur -----
kernel =[0, 1, 0
1, 1, 1
0, 1, 0] / 5;
% -----Gaussian Blur -----
kernel =fspecial('gaussian', 5 , 0.8);
% -----Motion Blur -----
kernel =[1, 0, 0, 0, 0
0, 1, 0, 0, 0
0, 0, 1, 0, 0
0, 0, 0, 1, 0
0, 0, 0, 0, 1] / 5;
% -----Edges Detection -----
kernel =[-1, -1, -1
-1, 8, -1
-1, -1, -1];
% -----Sharpen filter -----
kernel =[-1, -1, -1
-1, 9, -1
-1, -1, -1];
% -----Emboss filter -----
kernel =[-1, -1, 0
-1, 0,1
0, 1,1];
%% convolethe image with defined kernel or filter
result =zeros(size(image));
result(:,:, 1) = conv2(double(image(:, :, 1)), double(kernel), 'same');
result(:,:, 2) = conv2(double(image(:, :, 2)), double(kernel), 'same');
result(:,:, 3) = conv2(double(image(:, :, 3)), double(kernel), 'same');
%% showthe result
imshow(image);
figure
imshow(uint8(result))
- %实验步骤二:用系统预定义滤波器进行均值滤波
- n=input('请输入均值滤波器模板大小\n');
- A=fspecial('average',n); %生成系统预定义的3X3滤波器
- Y=filter2(A,g)/255; %用生成的滤波器进行滤波,并归一化
- figure,imshow(Y),title('用系统函数进行均值滤波后的结果'); %显示滤波后的图象
滤波操作不改变原图像的大小,而卷积则改变原图像的大小。
关于图像卷积和滤波的区别参考的博文还有:
http://blog.csdn.net/haoji007/article/details/53911940