1、直方图均衡化
函数histeq,实现对输入图像的直方图均衡化
语法格式:略
I = imread('tire.tif');
J = histeq(I);
subplot(221),imshow(I),title('原始图像');
subplot(222),imshow(J),title('直方图均衡图像');
subplot(223),imhist(I),title('原始图像直方图');
subplot(224),imhist(J),title('均衡化图像直方图');
I=imread('tire.tif');
[J,T]=histeq(I);
figure,plot((0:1:255),T);
效果图如下:
2、gamma校正
imadjust函数中有一个可选参数gamma,指定了变换曲线的形状。通常,当gamma>1时,图像变暗;当gamma<1时,图像变亮。
[X,map]=imread('forest.tif');
I=ind2gray(X,map);
J1=imadjust(I,[],[],0.5);
J2=imadjust(I,[],[],1);
J3=imadjust(I,[],[],2);
subplot(221),imshow(I),title('原始图像');
subplot(222),imshow(J1),title('gamma为0.5的变换');
subplot(223),imshow(J2),title('gamma为1的变换');
subplot(224),imshow(J3),title('gamma为2的变换');
效果图如下:
3、直方图规定化
函数histeq(I,hgram),来实现直方图规定化
其中hgram是用户指定的 向量
I = imread('tire.tif');
hgram=0:255;
J = histeq(I,hgram);
subplot(221),imshow(I),title('原始图像');
subplot(222),imshow(J),title('直方图规定化后图像');
subplot(223),imhist(I),title('原始图像直方图');
subplot(224),imhist(J),title('规定化后图像直方图');
效果图如下: