clcclearA=imread('C:\Users\Desktop\3.jpg');f0=0;f1=80;f2=180;f3=255;y0=0;y1=20;y2=240;y3=255;I=double(A);[m,n,o]=size(A)forx=1:mfory=1:nQ(x,y)=0;ifI(x,y)80Q(x,y)=I(x,y)*0.25;elseif(I(x,y)=80)&&(I(x,y)180)Q(x,y)=I(x,y)*2.2-156;elseQ(x,y)=I(x,y)*0.2+204;endendendP=mat2gray(Q);subplot(2,2,1);subimage(A);title('原图');subplot(2,2,2);subimage(P);title('对比度增强');subplot(2,2,3);plot([f0,f1,f2,f3],[y0,y1,y2,y3]);title('灰度映射曲线');