概況:
灰度變換通過(guò)對(duì)原圖像素值重新分配實(shí)現(xiàn), 目的是使圖像中表現(xiàn)較暗的像素值, 通過(guò)灰度變換函數(shù)映射的方法使較暗的像素值增大, 這樣圖像的亮度就提高了。增強(qiáng)處理并不能使原始圖像信息增加, 其結(jié)果只能增強(qiáng)對(duì)某種信息的辨別能力, 而這種處理有可能損失一些其他信息。但是, 只要提高了圖像的視覺(jué)特性, 增強(qiáng)圖像的目的就達(dá)到了。
幾個(gè)概念
1、灰度:對(duì)于通常所謂的黑白圖像,把黑色和白色之間按對(duì)數(shù)關(guān)系分為若干等級(jí)稱(chēng)為灰度。灰度分為256階,用灰度表示的圖像稱(chēng)作灰度圖.在圖像中用0~255表示,0是全黑,255是全白
2、對(duì)比度:對(duì)比度值一幅圖像中敏感區(qū)域最亮的白和最暗的黑之間的不同亮度層級(jí)的測(cè)量,差異范圍越大代表對(duì)比月大。好的對(duì)比率120:1就可以容易的顯式生動(dòng)、豐富的色彩,當(dāng)對(duì)比率達(dá)到300:1時(shí)便可以支持各階的顏色。
(1)線(xiàn)性變換:
通過(guò)建立灰度映射來(lái)調(diào)整源圖像的灰度。
k>1增強(qiáng)圖像的對(duì)比度;k=1調(diào)節(jié)圖像亮度,通過(guò)改變d值達(dá)到調(diào)節(jié)亮度目的;0
i = imread('theatre.jpg');
i = im2double(rgb2gray(i));
[m,n]=size(i);
%增加對(duì)比度
Fa = 1.25; Fb = 0;
O = Fa.*i + Fb/255;
figure(1), subplot(221), imshow(O);
title('Fa = 1.25, Fb = 0, contrast increasing');
figure(2),subplot(221), [H,x]=imhist(O, 64);
stem(x, (H/m/n), '.');
title('Fa = 1.25, Fb = 0, contrast increasing');
%減小對(duì)比度
Fa =0.5; Fb = 0;
O = Fa.*i + Fb/255;
figure(1), subplot(222),imshow(O);
title('Fa = 0.5, Fb = 0, contrast decreasing');
figure(2), subplot(222), [H,x] = imhist(O, 64);
stem(x, (H/m/n), '.');
title('Fa = 0.5, Fb = 0, contrast decreasing');
%線(xiàn)性亮度增加
Fa = 0.5; Fb = 50;
O = Fa.*i + Fb/255;
figure(1), subplot(223), imshow(O);
title('Fa = 0.5, Fb = 50, brightness control');
figure(2), subplot(223), [H,x]=imhist(O,64);
stem(x, (H/m/n), '.');
title('Fa = 0.5, Fb = 50, brightness control');
%反相顯示
Fa = -1; Fb = 255;
O = Fa.*i + Fb/255;
figure(1), subplot(224), imshow(O);
title('Fa = -1, Fb = 255, reversal processing');
figure(2), subplot(224),[H,x]=imhist(O, 64);
stem(x, (H/m/n), '.');
title('Fa = -1, Fb = 255, reversal processing');
(2)對(duì)數(shù)變換:
增強(qiáng)低灰度,減弱高灰度值。
i = imread('theatre.jpg');
i = rgb2gray(i);
i = double(i);
out1 = log(1+i)/0.065;
out2 = log(1+i)/0.035;
out1(find(out1>255)) = 255;
out2(find(out2>255)) = 255;
out1 = uint8(out1);
out2 = uint8(out2);
(3)冪次變換:
次數(shù)小于1時(shí),增強(qiáng)低灰度,減弱高灰度;次數(shù)大于1時(shí)增強(qiáng)高灰度,減弱低灰度。
i = rgb2gray(imread('theatre.jpg'));
i = double(i);
y1 = 255*(i/255).^2.5;
y2 = 255*(i/255).^0.4;
y1 = uint8(y1);
y2 = uint8(y2);
(4) 指數(shù)變換:
增強(qiáng)高灰度,減弱低灰度。
i = imread('theatre.jpg');
i = rgb2gray(i);
i = double(i);
y1 = 1.5.^(i*0.070)-1;
y2 = 1.5.^(i*0.050)-1;
y1(find(y1>255)) = 255;
y2(find(y2>255)) = 255;
y1 = uint8(y1);
y2 = uint8(y2);
(5)灰度拉伸:
有時(shí)圖像灰度集中在某小塊區(qū)域,需要改變圖像對(duì)比度。
i = imread('theatre.jpg');
i = rgb2gray(i);
L = imadjust(i,[ ],[50/255;150/255]);
J = imadjust(L,[50/255;150/255 ],[20/255;230/255]);
(6)灰度均衡:
i = rgb2gray(imread('theatre.jpg'));
LC = imadjust(i,[ ],[50/255;150/255]);
HE1 = histeq(LC);%均衡函數(shù)
(7)直方圖規(guī)定化:
實(shí)現(xiàn)局部的灰度均衡。
img = rgb2gray(imread('theatre.jpg'));
img_ref = rgb2gray(imread('rpic.jpg'));%參考圖,按照這個(gè)的的直方圖進(jìn)行規(guī)定化
[hgram, x] = imhist(img_ref);
J = histeq(img, hgram);
評(píng)論
查看更多