gusucode.com > 二进小波和非线性变换的图像增强matlab源码程序 > NonlinearEnhancement.m
% IEEE Image Processing, vol.9, No.6, 2000. %--------- 滤波器对图像作增强提高视觉质量------- clear all; % C=double(imread('t1.bmp'));%cameraman.tifSAR01.bmpBARB.BMP;5-51fft6649-060-1.tifmed01.jpg C=double(imread('lena.bmp')); h=[1,1,1;1,1,1;1,1,1]./9; B=C(:,:,1); %B=imfilter(B,h,'replicate'); S=size(B);H=S(1,1);W=S(1,2); %%%%%%%%%%%%%%%%% CDF9/7 t=0.75;%0.730174; h0 = (8*t*t*t-6*t*t+3*t)/(1+2*t)*(1/32); h1 = (-16*t*t*t+20*t*t-12*t+3)/(1+2*t)*(1/32); h2 = (2*t-3)/(1+2*t)*(1/8.); h3 = (16*t*t*t-20*t*t+28*t+5)/(1+2*t)*(1/32.); h4 = (-8*t*t*t+6*t*t+5*t+20)/(1+2*t)*(1/16.); hL=[h0,h1,h2,h3,h4,h3,h2,h1,h0]; g0=-t/16; g1=(1-2*t)/16; g2=(t+4)/16; g3=(3+2*t)/8; hH=[-g0,g1,-g2,g3,-g2,g1,-g0]; %%%%%%%%%%%%%%%%%%%%%%%%%%%% % 对淹没在噪声中的SAR图像首先用Wiener滤波法自适应去噪 %Idenoise= medfilt2(B(:,:,1),[3 3]);%中值滤波 %Idenoise = wiener2(B(:,:,1),[5 5]);%自适应滤波 %Idenoise=double(Idenoise); Idenoise=B;%imresize(B,[512,510]); % 用多分辨分解法提取高频边缘BI hL=[1/16,1/4,3/8,1/4,1/16]; for i=1:length(hL) for j=1:length(hL) hL2D(i,j)=hL(i)*hL(j); end end L0=imfilter(Idenoise,hL2D,'replicate');%低频近似图像L0 L0=double(L0); L0max=max(max(L0)); c=0.3;s=2; T1 = 0; T2 = (1-c)*L0max; k1=0.6; k2=s; BI = Idenoise-L0;% 第一层高频边缘BI % 对BI作非线性插值后得到newBI newBI=BI; for i=1:H for j=1:W if abs(BI(i,j))<=T1 newBI(i,j)=k1*BI(i,j); else if (abs(BI(i,j))>T1)&(abs(BI(i,j))<=T2) newBI(i,j)=sign(BI(i,j))*(k2*abs(BI(i,j))+T1*(k1-k2)); end end end end %newBI=s*newBI; % 对newBI作高通滤波得到增强后的高频边缘BI hH=[-1/16,1/4,-3/8,1/4,-1/16];%[-1,2,-1]/2; for i=1:length(hH) for j=1:length(hH) hH2D(i,j)=hH(i)*hH(j); end end BI=imfilter(newBI,hH2D,'replicate');%修正后的边缘 %BI=newBI-double(imfilter(newBI,hL2D,'replicate')); BI=double(BI); Irecover=newBI+L0; for i=1:H for j=1:W if Irecover(i,j)<0 Irecover(i,j)=0; else if Irecover(i,j)>255 Irecover(i,j)=255; end end end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EP1D=[-0.15,0.25,0.7,0.25,-0.15]; %EP1D=[-0.05,0.15,-0.25,0.3,0.9,0.3,-0.25,0.15,-0.05]./1.2 for i=1:length(EP1D) for j=1:length(EP1D) EP2D(i,j)=EP1D(i)*EP1D(j); end end Irepro = imfilter(Irecover,EP2D,'replicate'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %figure,imshow((100*BI)./255,[]);%imfilter(B,hH2D,'replicate') figure,imshow(uint8(B),[]); title('原图'); %subplot(122); figure,imshow(uint8(Irecover),[]); title(['高频非线性增强后的图像']); figure,imshow(uint8(Irepro),[]); title(['非线性增强后再补偿的图像']);