图像频域高通/低通滤波处理(Matlab)

文章首发及后续更新:https://mwhls.top/2454.html
新的更新内容请到mwhls.top查看。
无图/无目录/格式错误/更多相关请到上方的文章首发页面查看。

目的
  • 使用理想高通/低通滤波器对频域处理。
原理
  • 使用傅里叶变化,转成频域。
  • 将频率低的部分移动至中心。
  • 以中心为原点设定距离阈值。
  • 根据距离阈值进行频率滤波。
  • 滤波后将频率低的部分复位。
  • 使用傅里叶逆变换,得结果。
  • 代码框架:
    • F = fft2(imgGray); %傅里叶变换
    • F1 = fftshift(F); %低频移中心
    • G(u, v) = H(u, v) .* F1(u, v); %滤波函数H与频率域F1点乘
    • G2 = fftshift(G); %低频复位
    • imgResult = ifft2(G2); %傅里叶逆变换
实验结果
代码

clear;
img = imread('lena_color.jpg');
imgGray = rgb2gray(img);
[height, width] = size(imgGray);
histArray = zeros(1, 256);

%The Fourier transform
FTransform = fft2(imgGray);
FTransformCenter = fftshift(FTransform);
%Ideal low-pass
IdealLowPass = zeros(height, width);
IdealHighPass = zeros(height, width);
mid_width = width / 2;
mid_height = height / 2;
DLThreshold = 30;
DLThresholdExp2 = DLThreshold ^ 2;
DHThreshold = 10;
DHThresholdExp2 = DHThreshold ^ 2;
for row = 1:height
    for col = 1:width
        %Ideal low-pass
        temp = ((row - mid_height)^2 + (col - mid_width)^2);
        if temp < DLThresholdExp2
            IdealLowPass(row, col) = 1;
        end
        if temp > DHThresholdExp2
            IdealHighPass(row, col) = 1;
        end
    end
end
DLprocessCenter = IdealLowPass .* FTransformCenter;
DLprocess = fftshift(DLprocessCenter);
ImgDLprocess = uint8(ifft2(DLprocess));
DHprocessCenter = IdealHighPass .* FTransformCenter;
DHprocess = fftshift(DHprocessCenter);
ImgDHprocess = uint8(ifft2(DHprocess));

subplot(1, 3, 1)
imshow(imgGray), title('Origin');
subplot(1, 3, 2)
imshow(ImgDLprocess), title('The Fourier transform base on Ideal low-pass');
subplot(1, 3, 3)
imshow(ImgDHprocess), title('The Fourier transform base on Ideal high-pass');
  • 4
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值