# 《精通Matlab数字图像处理与识别》一6.6 频率域高通滤波器

+关注继续查看

### 6.6.1 高斯高通滤波器及其实现

1．理论基础

2．Matlab实现

function out = imgaussfhpf(I, sigma)
% imgaussfhpf函数            构造频域高斯高通滤波器
% I参数                    输入的灰度图像
% sigma参数                高斯函数的Sigma参数

[M,N] = size(I);
out = ones(M,N);
for i=1∶M
for j=1∶N
out(i,j) = 1 - exp(-((i-M/2)^2+(j-N/2)^2)/2/sigma^2);
end
end


[例6.5]高斯高通滤波实现。

I = imread('coins.png');

% 生成滤镜
ff = imgaussfhpf (I, 20);
% 应用滤镜
out = imfreqfilt(I, ff);

figure (1);
subplot(2,2,1);
imshow(I);
title('Source');

% 计算FFT并显示
temp = fft2(double(I));
temp = fftshift(temp);
temp = log(1 + abs(temp));
figure (2);
subplot(2,2,1);
imshow(temp, []);
title('Source');

figure (1);
subplot(2,2,2);
imshow(out);
title('Gauss HPF, sigma=20');

% 计算FFT并显示
temp = fft2(out);
temp = fftshift(temp);
temp = log(1 + abs(temp));
figure (2);
subplot(2,2,2);
imshow(temp, []);
title('Gauss HPF, sigma=20');

% 生成滤镜
ff = imgaussfhpf (I, 40);
% 应用滤镜
out = imfreqfilt(I, ff);

figure (1);
subplot(2,2,3);
imshow(out);
title('Gauss HPF, sigma =40');

% 计算FFT并显示
temp = fft2(out);
temp = fftshift(temp);
temp = log(1 + abs(temp));
figure (2);
subplot(2,2,3);
imshow(temp, []);
title('Gauss HPF, sigma =40');

% 生成滤镜
ff = imgaussfhpf(I, 60);
% 应用滤镜
out = imfreqfilt(I, ff);

figure (1);
subplot(2,2,4);
imshow(out);
title('Gauss HPF, sigma =60');

% 计算FFT并显示
temp = fft2(out);
temp = fftshift(temp);
temp = log(1 + abs(temp));
figure (2);
subplot(2,2,4);
imshow(temp, []);
title('Gauss HPF, sigma =60');


### 6.6.2 频域拉普拉斯滤波器及其实现

1．理论基础

2．Matlab实现

function out = imlapf(I)
% imlapf函数   构造频域拉普拉斯滤波器
% I参数    输入的灰度图像
[M,N] = size(I);
out = ones(M,N);
for i=1∶M
for j=1∶N
out(i,j) = -((i-M/2)^2+(j-N/2)^2);
end
end

[例6.6] 拉普拉斯滤波实现。

ff = imlapf (I);
out = imfreqfilt(I, ff);

figure (1);
subplot(1,2,1);
imshow(I);
title('Source');

temp = fft2(double(I));
temp = fftshift(temp);
temp = log(1 + abs(temp));
figure (2);
subplot(1,2,1);
imshow(temp, []);
title('Source');

figure (1);
subplot(1,2,2);
imshow(out);
title('Laplace Filter');

temp = fft2(out);
temp = fftshift(temp);
temp = log(1 + abs(temp));
figure (2);
subplot(1,2,2);
imshow(temp, []);
title('Laplace Filter');


38 0

18103 0

24850 0
《MATLAB信号处理超级学习手册》——第2章 时间信号与系统 2.1 离散序列

2036 0
《精通Matlab数字图像处理与识别》一导读

2019 0
+关注

12049

0

OceanBase 入门到实战教程