真彩色图像处理文档格式.docx

上传人:b****5 文档编号:16245884 上传时间:2022-11-21 格式:DOCX 页数:11 大小:91.98KB
下载 相关 举报
真彩色图像处理文档格式.docx_第1页
第1页 / 共11页
真彩色图像处理文档格式.docx_第2页
第2页 / 共11页
真彩色图像处理文档格式.docx_第3页
第3页 / 共11页
真彩色图像处理文档格式.docx_第4页
第4页 / 共11页
真彩色图像处理文档格式.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

真彩色图像处理文档格式.docx

《真彩色图像处理文档格式.docx》由会员分享,可在线阅读,更多相关《真彩色图像处理文档格式.docx(11页珍藏版)》请在冰豆网上搜索。

真彩色图像处理文档格式.docx

图4.5是基于matlab以增强亮度和饱和度的方法进行真彩色增强的图像,其代码见附录

图4.4对HSI图像进行增强结果

这是对前两个方法的综合,很显然,图(b)比图(a)要亮,要清晰,视觉效果比以上两种方法分别做要好的多。

2、直接在rgb空间对图像增强

图4.6是基于matlab在rgb空间增强图像,其代码见附录

图4.5对RGB图像进行增强结果

以下是基于matlab以增强亮度的方法进行真彩色增强的代码:

%%彩色图像亮度增强(执行速度较慢)

clc

clear

fc=imread('

E:

\maomao.jpg'

);

figure

(1);

imshow(fc)

title('

原始真彩色(256*256*256色)图像'

fr=fc(:

:

1);

fg=fc(:

2);

fb=fc(:

3);

%imshow(fr)

%title('

红色分量图像'

%imshow(fg)

绿色分量图像'

%imshow(fb)

蓝色分量图像'

h=rgb2hsi(fc);

H=h(:

S=h(:

I=h(:

I=I*1.5;

%imshow(H)

色调分量图像'

%imshow(S)

饱和度分量图像'

%imshow(I)

亮度分量图像'

h=cat(3,H,S,I);

%cat函数是拼接数组的函数,这里将在第3维上进行拼接。

f=hsi2rgb(h);

%增强亮度分量后的rgb图像

f=min(f,1);

%保证元素值最大为1,因为按公式转换为rgb后可能出现大于1的情况

figure

(2);

imshow(f)

仅增强HSI图像的亮度分量所得到的RGB图像'

基于matlab以增强对比度的方法进行真彩色增强代码:

%%例6.8彩色图像亮度增强(执行速度较慢)

I:

S=S*2.0;

增强HSI图像的对比度所得到的RGB图像'

基于matlab以增强亮度和饱和度的方法进行真彩色增强的图像

imshow(fc)

I=I*2.0;

S=S*2.0;

rgb图像转化为hsi图像的代码:

rgb2hsi(rgb)

functionhsi=rgb2hsi(rgb)

%RGB2HSIConvertsanRGBimagetoHSI.

%HSI=RGB2HSI(RGB)convertsanRGBimagetoHSI.Theinputimage

%isassumedtobeofsizeM-by-N-by-3,wherethethirddimension

%accountsforthreeimageplanes:

red,green,andblue,inthat

%order.IfallRGBcomponentimagesareequal,theHSIconversion

%isundefined.Theinputimagecanbeofclassdouble(withvalues

%intherange[0,1]),uint8,oruint16.

%

%Theoutputimage,HSI,isofclassdouble,where:

%hsi(:

:

1)=hueimagenormalizedtotherange[0,1]by

%dividingallanglevaluesby2*pi.

2)=saturationimage,intherange[0,1].

3)=intensityimage,intherange[0,1].

%Copyright2002-2004R.C.Gonzalez,R.E.Woods,&

S.L.Eddins

%DigitalImageProcessingUsingMATLAB,Prentice-Hall,2004

%$Revision:

1.5$$Date:

2005/01/1813:

44:

59$

%Extracttheindividualcomponentimages.

rgb=im2double(rgb);

r=rgb(:

1);

g=rgb(:

2);

b=rgb(:

3);

%Implementtheconversionequations.

num=0.5*((r-g)+(r-b));

den=sqrt((r-g).^2+(r-b).*(g-b));

theta=acos(num./(den+eps));

H=theta;

H(b>

g)=2*pi-H(b>

g);

H=H/(2*pi);

num=min(min(r,g),b);

den=r+g+b;

den(den==0)=eps;

S=1-3.*num./den;

H(S==0)=0;

I=(r+g+b)/3;

%Combineallthreeresultsintoanhsiimage.

hsi=cat(3,H,S,I);

hsi图像转化为rgb图像的代码:

hsi2rgb(hsi)

functionrgb=hsi2rgb(hsi)

%HSI2RGBConvertsanHSIimagetoRGB.

%RGB=HSI2RGB(HSI)convertsanHSIimagetoRGB,whereHSIis

%assumedtobeofclassdoublewith:

1)=hueimage,assumedtobeintherange

%[0,1]byhavingbeendividedby2*pi.

%Thecomponentsoftheoutputimageare:

%rgb(:

1)=red.

2)=green.

3)=blue.

2003/10/1301:

01:

06$

%ExtracttheindividualHSIcomponentimages.

hsi=im2double(hsi);

H=hsi(:

1)*2*pi;

S=hsi(:

I=hsi(:

R=zeros(size(hsi,1),size(hsi,2));

G=zeros(size(hsi,1),size(hsi,2));

B=zeros(size(hsi,1),size(hsi,2));

%RGsector(0<

=H<

2*pi/3).

idx=find((0<

=H)&

(H<

2*pi/3));

B(idx)=I(idx).*(1-S(idx));

R(idx)=I(idx).*(1+S(idx).*cos(H(idx))./cos(pi/3-H(idx)));

G(idx)=3*I(idx)-(R(idx)+B(idx));

%BGsector(2*pi/3<

4*pi/3).

idx=find((2*pi/3<

4*pi/3));

R(idx)=I(idx).*(1-S(idx));

G(idx)=I(idx).*(1+S(idx).*cos(H(idx)-2*pi/3)./...

cos(pi-H(idx)));

B(idx)=3*I(idx)-(R(idx)+G(idx));

%BRsector.

idx=find((4*pi/3<

=2*pi));

G(idx)=I(idx).*(1-S(idx));

B(idx)=I(idx).*(1+S(idx).*cos(H(idx)-4*pi/3)./...

cos(5*pi/3-H(idx)));

R(idx)=3*I(idx)-(G(idx)+B(idx));

%CombineallthreeresultsintoanRGBimage.Clipto[0,1]to

%compensateforfloating-pointarithmeticroundingeffects.

rgb=cat(3,R,G,B);

rgb=max(min(rgb,1),0);

直接在RGB空间进行图像增强

A=imread('

C:

\Users\liuxinju\Desktop\maomao.jpg'

%读入原始RGB图像

whos;

figure;

imshow(A):

originalimage'

%显示图像

[rcd]=size(A);

%计算图像大小

%------计算红色分量并显示分解图------%

red(:

1)=A(:

2)=zeros(r,c);

3)=zeros(r,c);

red=uint8(red*2.0);

imshow(red)

RedComponent'

%-------计算绿色分量并显示分解图-------%

green(:

2)=A(:

1)=zeros(r,c);

green=uint8(green*2.0);

imshow(green)

GreenComponent'

%--------计算蓝色分量并显示分解图-------%

blue(:

3)=A(:

blue=uint8(blue*2.0);

imshow(blue)

BlueComponent'

%------------合成-------------%

B(:

1)=red(:

2)=green(:

3)=blue(:

imshow(B):

compositionimage'

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 学科竞赛

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1