实现密茨变换,调整gamma数值,观察图像变化,分析lena图像在不同gamma数值下,图像灰度变化的特点
%幂次变换公式----C*(img .^ X)
A1 = imread('D:\Program\test_matlab\lena.jpg');
A = im2double(A1);
subplot(2,2,1);
imshow(A1);
title('raw');
C = 1
X = 0.5
A2 = C*(A .^ X)
% 图像加亮,减暗
subplot(2,2,2);
imshow(A2);
title(['C:',num2str(C),' X:',num2str(X)])
C = 1
X = 1.5
A3 = C*(A .^ X)
subplot(2,2,3);
imshow(A3);
title(['C:',num2str(C),' X:',num2str(X)])
% 图像减亮,加暗
C = 1
X = 2
A4 = C*(A .^ X)
subplot(2,2,4);
imshow(A4);
title(['C:',num2str(C),' X:',num2str(X)])
% 图像减亮,加暗
%imadjust()
B = A1;
G = 1
B1 = imadjust(B,[0.3,0.5],[0,1],G) %<255*0.3的置为0;>255*0.5的置为255,garmma=1
figure;subplot(2,2,1); %图片对比度增大,灰度扩展
imshow(B1);
title(['G:',num2str(G)])
G=2
B2 = imadjust(B,[0.3,0.5],[0,1],G) %图片相对B1,降低亮度
subplot(2,2,2);
imshow(B2);
title(['G:',num2str(G)])
G=0.5
B3 = imadjust(B,[0.3,0.5],[0,1],G) %图片相对B1,增加亮度
subplot(2,2,3);
imshow(B3);
title(['G:',num2str(G)])
%直方图 imhist()
imshow(A1);
title('source');
figure;
subplot(221);imhist(A1,2); %n缺省的话默认255
subplot(222);imhist(A1,5);
subplot(223);imhist(A1,10);
subplot(224);imhist(A1);
figure;
subplot(121); imhist(A1,10)
[count,x] = imhist(A1,10)
subplot(122);stem(x,count);