1.模糊增强代码
%模糊增强代码function img=FuzzyHE_original(I)%对图像作基于模糊估计和直方图的增强变换m=size(I,1);n=size(I,2);I1=double(I);I2=zeros(m,n);%对图像灰度值的期望M=mean(I1(:));K=128;E=255;%8bit图像for i=1:mfor j=1:nif I1(i,j)<MI2(i,j)=I1(i,j)+I1(i,j)/M*K; %区间[0,M-1]模糊增强elseI2(i,j)=(E-I1(i,j))*(I1(i,j)-K)/(E-M)+E; %区间[M,E]模糊增强endendend%img=I2;%增强结果直接输出,可能出现反色的结果,部分值不在[0,255]之间img=min(255,max(I2,0)); %将像素值修正到区间[0,255]之间End
2.基于幂次变换的图像增强
clear allclose allI{1}=double(imread('L.jpg'));I{1}=I{1}/255;figure(1),subplot(2,4,1),imshow(I{1},[]),hold onI{2}=double(imread('L2.jpg'));I{2}=I{2}/255;subplot(2,4,5),imshow(I{2},[]),hold onfor m=1:2Index=0;for lemta=[0.5 5]Index=Index+1;F{m}{Index}=I{m}.^lemta;subplot(2,4,(m-1)*4+Index+1),imshow(F{m}{Index},[])endend