G=imread('aini555.jpg'); I=rgb2gray(G); J=histeq(I); %直方圖均衡化,這一個函數就可以做到均衡化的效果 figure, subplot(121),imshow(uint8(I)); title('原圖') subplot(122),imshow(uint8(J)); title('均衡化后') figure, subplot(121),imhist(I,64); title('原圖像直方圖'); subplot(122),imhist(J,64); title('均衡化后的直方圖');
matlab程序如上,結果如下: