2、—~0,1,2,...,L—1n通过转换公式获得:sk=T(rk)=Xa^)=X—k=0,1,2,…,L—1y=oy=on三、实验步骤启动MATLAB程序,对以下多种灰度变换方法分别各选取一个合适的图像进行处理,记录灰度变换前后的图像、直方图以及相关参数。(1)灰度反转(2)对数变换(3)伽马校正(4)分段线性变换(5)直方图均衡化2记录和整理实验报告四、实验报告内容(1)灰度反转1=imread(’1•jpg’);I=rgb2gray(I);H=imadjust(I,[01],[10]);subplot(1,2,1);imshow(I);title('原图');
3、subplot(1,2,2);imshow(H);title(1反转剛象’)(1)对数变换I=imread(•2.jpg’);subplot(1,2,1);imshow(I);title('灰度阁像');g=im2uint8(mat2gray(log(1+double(I))));subplot(1,2,2);imshow(g);title(1对数变换图像”;細權对数麵聰(2)伽马校正i=imread(’1•jpg’);i=rgb2gray(i);g=imadjust(i,stretchlim(i),[]);subplot(1,2,1);imshow(i);xla
4、bel(1a).OriginalImage1);subplot(1,2,2);imshow(g);xlabel(1b).GammaTransformations1);(1)分段线性变换I=imread(’1•jpg’);subplot(2,2,1);imshow(I);title(1原始图像1);II=rgb2gray(I);subplot(2,2,2);imshow(Il);title('灰度阁像•);%局部拉伸,把[0.10.5]内的灰度拉伸为[01]J=imadjust(Ilz[0.10.5],[]);subplot(2,2,3);imshow(J);tit
5、le(1线性变换图像[0.10.5]');%局部拉伸,把[0.30.7]内的灰度拉伸为[01]K=imadjust(Ilz[0.30.7],[]);subplot(2,2,4);imshow(K);title(1线性变换图像[0.30.7]’);原$台图像灰度图像线十半•炎換:图像[0.3O.7]线十牛变换图<象[0.1o.g(2)直方阁均衡化I=imread(•1•jpg’);I=rgb2gray(I);figure;subplot(2,2,1);imshow(I);title(•原网’)subplot(2,2,2);imhist(I);title(•原图直方图
6、•)Il=histeq(I);subplot(2,2,3);imshow(Il);title(1直方图均衡化1)subplot(2,2,4);imhist(II);title(1直方图均衡化后的直方图1〉原图n方图0100200