運用知識點
1、圖像增強可以通過線性、指數變換、直方圖均衡化來對圖像進行增強
2、線性變換可以使的“黑色更黑,白色更白”進而增強圖像的對比度,下面題二就是運用如下圖的折線
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLiAzNfRHLGZkRGZkRfJ3bs92YsYTMfVmepNHLx0EVNFTVq5UeRpHW4Z0MMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2X0hXZ0xCMx81dvRWYoNHLrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnL4UTM3QzNzEjMzIzMwkTMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
3、灰階圖像的直方圖均衡化的步驟如下
一、
P=im2double(rgb2gray(imread('tes6.jpg')));
subplot(321),imshow(P),title('原圖');
subplot(322),imhist(P);
I=imadjust(P,[70/256;180/256],[0/256;70/256]);
subplot(323),imshow(I),title('線性變化');
subplot(324),imhist(I);
J=histeq(I);
subplot(325),imshow(J),title('直方圖均衡化');
subplot(326),imhist(J);
二、将RGB圖像轉換為HSV圖像并對其中的V分量進行直方圖均衡化
1、運用到了一下matlab函數
cat(3,A,B,C); //将ABC三個矩陣合并
histeq(M); //對M進行直方圖均衡化
rgb2hsv(image);
hsv2rgb(image);
P=imread('picture1.png');
R=P(:,:,1);
G=P(:,:,2);
B=P(:,:,3);
[H,S,V]=rgb2hsv(P);
new_v=histeq(V);
new_hsv2rgb=hsv2rgb(cat(3,H,S,new_v));
subplot(141),imshow(P),title('rgb原圖');
subplot(142),imshow(V),title('原圖V分量');
subplot(143),imshow(new_v),title('直方圖均衡化後V分量');
subplot(144),imshow(new_hsv2rgb),title('直方圖均衡化後rgb');
三、将一幅圖像的RGB分量分别進行指數、線性、直方圖均衡化變換再合并
P=imread('picture1.png');
R=P(:,:,1);
G=P(:,:,2);
B=P(:,:,3);
type=3; //選擇變換方式
type2_m=53; //指數變換的系數
type3_a=80/256;type3_b=180/256;type3_c=30/256;type3_d=220/256; //線性變換的系數,參照上圖
switch type
case 1 //直方圖變換
new_r=histeq(R);
new_g=histeq(G);
new_b=histeq(B);
case 2 //指數變換
new_r=type2_m*log(double(R)+1);
new_g=type2_m*log(double(G)+1);
new_b=type2_m*log(double(B)+1);
case 3 //線性變換
new_r=imadjust(R,[0;type3_a],[0;type3_c]);
new_g=imadjust(G,[type3_a;type3_b],[type3_c;type3_d]);
new_b=imadjust(B,[type3_b;1],[type3_d;1]);
end
subplot(231),imshow(R),title('r分量');
subplot(232),imshow(G),title('g分量');
subplot(233),imshow(B),title('b分量');
subplot(234),imshow(uint8(new_r)),title('新r分量');
subplot(235),imshow(uint8(new_g)),title('新g分量');
subplot(236),imshow(uint8(new_b)),title('新b分量');
figure;
subplot(121),imshow(P),title('原圖');
subplot(122),imshow(uint8(cat(3,new_r,new_g,new_b))),title('變換後圖像');
參考文獻:
[1] 蔡利梅 王利娟 數字圖像處理[M]. 中國礦業大學出版社 2014