clear all?
clc
I=imread('photography.bmp');
subplot(121),imshow(I);
title('原图')
I=double(I);
[M,N]=size(I);
rL=0.3;
rH=2.0;%可根据需要效果调整参数
c=2;
d0=10;
I1=log(I+1);%取对数
FI=fft2(I1);%傅里叶变换
n1=floor(M/2);
n2=floor(N/2);
for i=1:M
for j=1:N
D(i,j)=((i-n1).^2+(j-n2).^2);
H(i,j)=(rH-rL).*(exp(c*(-D(i,j)./(d0^2))))+rL;%高斯同态滤波
end
end
I2=ifft2(H.*FI);%傅里叶逆变换
I3=real(exp(I2));
subplot(122),imshow(I3,[]);
title('同态滤波增强后')
figure
Fc=fftshift(H);
mesh(H(1:10:1024,1:10:1024));
axis([0 102 0 102 0 2]);
% figure
% hist1=imhist(I);
% p1=hist1/(M*N);
% hist2=imhist(I3);
% p2=hist2/(M*N);
% subplot(121),imhist(I),title('原图像的直方图');
% subplot(122),imhist(I3),title('同态滤波后图像的直方图');