Butterworth高通滤波器matlab程序(原创)
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
用matlab编写的Butterworth高通滤波程序,可以运行,结果如截图源代码:
clear all;
close all;
P=input('input image data:');
subplot(221);imshow(P);
title('原始图像');
d=size(P);
if(d(3)>1)
P=rgb2gray(P);
end
subplot(222);imshow(P);
title('灰度图像');
f=double(P);
g=fft2(f);%傅里叶变换
g=fftshift(g);%转换数据矩阵
[M,N]=size(g);
% D0=input('input nonnegative dhreshold D0=');
% n=input('input the order of filtering n=');
D0=10;
n=3;
n1=fix(M/2);
n2= fix(N/2);
for i=1:M
for j=1:N
d=sqrt((i-n1)^2+(j-n2)^2);
h=1/(1+(D0/d)^(2*n));
result(i,j)=h*g(i,j);
end
end
result=ifftshift(result);
X2=ifft2(result);
X3=uint8(real(X2));
subplot(223)
imshow(X3);
title('Butterworht高通滤波结果');
subplot(224);
imshow (X3+P);
title('Butterworth高通滤波增强所得图像');
运行结果截图