版权所有:caoleiscu欢迎指正:caoleiemail@163
com[filename,pathname]=uigetfile('*
png','输入原图像'); file_name=[pathname filename]; I=imread(file_name);disp('四种基本的灰度变换,请输入选择项');disp('0--图像反转');disp('1--对数变换');disp('2--伽马变换');disp('3--分段线性变换');disp('4--直方图均衡'); d=input('please input you choice(请输入您的选择):');switch d case 0 J=double(I); J=256-1-J; H=uint8(J); subplot(121),imshow(I); subplot(122),imshow(H);case 1 J=log(1+double(I)); subplot(121),imshow(I); subplot(122),imshow(J,[]);case 2 x=0:255; a=80,b=1
009; J=b
*(double(I)-a))-1; y=b
*(x-a))-1; subplot(2,2,1),imshow(I); subplot(2,2,2),imhist(I); subplot(2,2,3),imshow(J); subplot(2,2,4),imhist(J); figure,plot(x,y);case 3 f0=0;g0=0; f1=10;g1=30; f2=220;g2=180; f3=255;g3=255; figure,plot([f0,f1,f2,f3],[g0,g1,g2,g3]); r1=(g1-g0