基于直方圖修改的彩色圖像增強(qiáng)

對(duì)上述圖像進(jìn)行增強(qiáng)、主要增強(qiáng)兩方面,一方面是圖像的亮度,另一方面就是圖像的對(duì)比度。

第一種方法:將RGB格式的圖像轉(zhuǎn)為HSV或者HSI格式,對(duì)于亮度值進(jìn)行修改。主要是對(duì)V值直方圖進(jìn)行均衡化。

clear all;

close all;

RGB=imread('test.jpeg');

HSV=rgb2hsv(RGB);

H=HSV(:,:,1);

S=HSV(:,:,2);

V=HSV(:,:,3);

figure;

subplot(1,3,1),imhist(H);

subplot(1,3,2),imhist(S);

subplot(1,3,3),imhist(V);

V=histeq(V);

figure,imhist(V);

HSV(:,:,1)=H;

HSV(:,:,2)=S;

HSV(:,:,3)=V;

RGB_1=hsv2rgb(HSV);

figure;

subplot(1,2,1),imshow(RGB);

subplot(1,2,2),imshow(RGB_1);

最后的效果如下圖:




白云、山脈、河流有了亮度和對(duì)比度提升。

第二種方法就是對(duì)RGB三個(gè)通道直接進(jìn)行直方圖均衡化。

clear all;

close all;

RGB=imread('test.jpeg');

R=double((RGB(:,:,1)))/255;

G=double((RGB(:,:,2)))/255;

B=double((RGB(:,:,3)))/255;

figure;

subplot(1,3,1),imshow(R);

subplot(1,3,2),imshow(G);

subplot(1,3,3),imshow(B);

R=histeq(R);

G=histeq(G);

B=histeq(B);

RGB_1(:,:,1)=R;

RGB_1(:,:,2)=G;

RGB_1(:,:,3)=B;

figure;

subplot(1,2,1),imshow(RGB);

subplot(1,2,2),imshow(RGB_1),brighten(0.6);

figure;

subplot(1,3,1),imhist(R);

subplot(1,3,2),imhist(G);

subplot(1,3,3),imhist(B);

這個(gè)處理效果如下:


由上圖可以看出、圖像的色調(diào)已經(jīng)被修改、這也是RGB值修改的一個(gè)缺點(diǎn)。

第三種方法就是目前我采用的,根據(jù)HE、BBHE、DSIHE、所采用的一種圖像增強(qiáng)方法。其原理簡(jiǎn)單介紹如下:

首先將RGB圖像轉(zhuǎn)為灰度圖像、那么每個(gè)灰度圖像像素的數(shù)值根據(jù)最大值法即:max(R,G,B)來(lái)確定,最大值法(圖4)與加權(quán)平均(圖2)、平均法處理(圖3)的對(duì)比圖如下所示:

由上圖可以看出、最大值處理的灰度圖像較其余兩幅圖的亮度有較大的提升。

接著處理灰度圖像的直方圖、找出該圖像的平均值、將直方圖劃分為兩部分、接著分別對(duì)兩部分的直方圖進(jìn)行均衡化處理。

在處理完成之后、對(duì)圖像進(jìn)行恢復(fù)、即將灰度圖像轉(zhuǎn)化成RGB圖像,找出處理之后的圖像與之前圖像的數(shù)值比例關(guān)系、然后將其與圖像想乘,即得到R、G、B三個(gè)分量的數(shù)值。最后的對(duì)比圖如下:

clear all;

close all;

clc;

RGB=imread('test.jpeg');

[row,column,n]=size(RGB);

R=RGB(:,:,1);

G=RGB(:,:,2);

B=RGB(:,:,3);

for i=1:row

for j=1:column

juzhen=[R(i,j),G(i,j),B(i,j)];

intensity_1(i,j)=0.2989*R(i,j)+0.587*G(i,j)+0.114*B(i,j);

intensity_2(i,j)=1/3*(R(i,j)+G(i,j)+B(i,j));

intensity_3(i,j)=max(juzhen);

end

end

figure,

subplot(2,2,1),imshow(rgb2gray(RGB));

subplot(2,2,2),imshow(intensity_1);

subplot(2,2,3),imshow(intensity_2);

subplot(2,2,4),imshow(intensity_3);

Pre_image=intensity_3;

figure;

subplot(2,2,1),imshow(intensity_3);

subplot(2,2,2),imhist(intensity_3);

subplot(2,2,3),imshow(Pre_image);

subplot(2,2,4),imhist(Pre_image);

Pre_image=im2uint8(Pre_image);

[height,width]=size(Pre_image);

XT=round(mean(mean(Pre_image)));

h = zeros(1,256);%統(tǒng)計(jì)各灰度數(shù)目,共256個(gè)灰度級(jí)

for m = 1:height

for n = 1: width

h(Pre_image(m,n) + 1) = h(Pre_image(m,n) + 1) + 1;%對(duì)應(yīng)灰度值像素點(diǎn)數(shù)量增加一

end

end

SH1=0;

SH2=0;

for x=0:XT

SH1=SH1+h(x+1);

end

for x=(XT+1):255

SH2=SH2+h(x+1);

end

N=height*width;

RSH1=SH1/N;

RSH2=SH2/N;

SEP_P=round(255*RSH1);

DRH1_start=0;

DRH1_end=SEP_P;

DRH2_start=SEP_P+1;

DRH2_end=255;

sum1=0;

CH1=zeros(1,256);

for x_1=0:XT

sum1=sum1+h(x_1+1);

CH1(x_1+1)=sum1/SH1;

end;

sum2=0;

CH2=zeros(1,256);

for x_2=(XT+1):255

sum2=sum2+h(x_2+1);

CH2(x_2+1)=sum2/SH2;

end

for i=1:height

for j=1:width

if Pre_image(i,j)

h(Pre_image(i,j)+1)=DRH1_start+(DRH1_end-DRH1_start)*CH1(Pre_image(i,j)+1);

else

h(Pre_image(i,j)+1)=DRH2_start+(DRH2_end-DRH2_start)*CH2(Pre_image(i,j)+1);

end

end

end

for i=1:height

for j=1:width

Aft_image(i,j)=h(Pre_image(i,j)+1);

end

end

Aft_image=uint8(Aft_image);

subplot(1,2,1),imhist(Aft_image);

subplot(1,2,2),imshow(Aft_image);

for i=1:height

for j=1:width

Alpha(i,j)=double(Aft_image(i,j))./double(intensity_3(i,j));

end

end

intensity_R=Alpha.*double(R);

intensity_G=Alpha.*double(G);

intensity_B=Alpha.*double(B);

RGB_1(:,:,1)=intensity_R;

RGB_1(:,:,2)=intensity_G;

RGB_1(:,:,3)=intensity_B;

figure,

subplot(1,2,2),imshow(uint8(RGB_1));

subplot(1,2,1),imshow(RGB);

這種方法對(duì)于圖像增強(qiáng)的細(xì)節(jié)有較好的增強(qiáng)作用。

接下來(lái)是通過(guò)HSI方面對(duì)圖像進(jìn)行增強(qiáng)。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容