标签:
这一节主要讲了滤波器:巴特沃思滤波器,高斯滤波器,理想滤波器(高通滤波器,低通滤波器)
在MATLAB里的代码实现:
function HPFilter (image , D0 , n);
%image = ‘lena_noise.bmp‘;
f = imread(image);
[u,v] = size(f);
mid_x = u/2;
mid_y = v/2;
%D0 = 50;
%----------------------------------------------------------
%高通滤波器的设计
%----------------------------------------------------------
figure;
subplot(2,2,1);
imshow(f);
title(‘原图‘);
%-------------------------------
%理想高通滤波器(ILPF)
%-------------------------------
H = zeros(u,v);
for i = 1:u
for j = 1:v
if(sqrt((i-mid_x)^2+(j-mid_y)^2) > D0)
H(i,j) = 1;
end
end
end
g = myfilter (f, H, D0);
subplot(2,2,2);
imshow(g);
title(‘理想高通滤波‘);
%-------------------------------
%巴特沃思高通滤波器(BLPF)
%-------------------------------
for i = 1:u
for j = 1:v
H(i,j) = (1+(D0^2/(i^2+j^2))^n)^-1;
end
end
g = myfilter (f, H, D0);
subplot(2,2,3);
imshow(g);
title(‘巴特沃思高通滤波‘);
%-------------------------------
%指数高通滤波器(elpf)
%-------------------------------
for i = 1:u
for j = 1:v
H(i,j) = exp(-(D0^2/(i^2+j^2))^n);
end
end
g = myfilter (f, H, D0);
subplot(2,2,4);
imshow(g);
title(‘指数高通滤波‘);
明天附上运行图片
标签: