数字图像实验六彩色图像处理.docx

上传人:b****4 文档编号:3934764 上传时间:2022-11-26 格式:DOCX 页数:10 大小:3.30MB
下载 相关 举报
数字图像实验六彩色图像处理.docx_第1页
第1页 / 共10页
数字图像实验六彩色图像处理.docx_第2页
第2页 / 共10页
数字图像实验六彩色图像处理.docx_第3页
第3页 / 共10页
数字图像实验六彩色图像处理.docx_第4页
第4页 / 共10页
数字图像实验六彩色图像处理.docx_第5页
第5页 / 共10页
点击查看更多>>
下载资源
资源描述

数字图像实验六彩色图像处理.docx

《数字图像实验六彩色图像处理.docx》由会员分享,可在线阅读,更多相关《数字图像实验六彩色图像处理.docx(10页珍藏版)》请在冰豆网上搜索。

数字图像实验六彩色图像处理.docx

数字图像实验六彩色图像处理

实验六彩色图像处理

一、实验目的

1、掌握常见的几种颜色模型及各种颜色空间之间的相互转换。

2、掌握彩色图像处理的方法,如彩色图像增强、彩色图像复原、彩色图像检测与分割等。

二、实验内容

1、读入一幅RGB图像,将其分别转换到CMY空间、HSI空间并显示。

2、利用全彩色图像处理的方法,对彩色图像进行平滑滤波及锐化处理。

3、载入一幅清晰彩色图像,产生运动模糊并添加一定的高斯噪声,采用维纳滤波复原该图像。

4、载入图片并进行边缘检测和图像分割。

三、实验步骤

1读入一幅RGB图像,转换到CMY空间并显示,再转换到HSI空间,同时显示其三个分量。

rgb=imread('peppers.png');

cmy=imcomplement(rgb);

subplot(231);

imshow(rgb);

title('原图');

subplot(232);

imshow(cmy);

title('CMY中的图');

cmy=im2double(cmy);

r=cmy(:

:

1);

g=cmy(:

:

2);

b=cmy(:

:

3);

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

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

m2=r+g+b;

m2(m2==0)=eps;

s=1-3.*m1./m2;

m1=0.5.*((r-g)+(r-b));

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

n=acos(m1./(m1+eps));

h=n;

h(b>g)=2*pi-h(b>g);

h=h/(2*pi);

h(s==0)=0;

hsi=cat(3,h,s,i);

subplot(233);

imshow(hsi);

title('HSI中的图');

subplot(234);

imshow(h);

title('H分量');

subplot(235);

imshow(s);

title('S分量');

subplot(236);

imshow(i);

title('I分量');

2读入一幅图片,先对其进行平滑,再进行锐化处理,并显示。

注意请分别在GRB空间和HSI空间进行,然后在对两个空间中的结果进行比较,给出结论。

rgb=imread('peppers.png');

r=rgb(:

:

1);

g=rgb(:

:

2);

b=rgb(:

:

3);

%subplot(231);

%imshow(r);

%subplot(232);

%imshow(g);

%subplot(233);

%imshow(b);

m=fspecial('average');

r_filtered=imfilter(r,m);

g_filtered=imfilter(g,m);

b_filtered=imfilter(b,m);

rgb_filtered=cat(3,r_filtered,g_filtered,b_filtered);

subplot(221);

imshow(rgb_filtered);

title('RGB空间平滑');

lapMatrix=[111;1-81;111];

i_tmp=imfilter(rgb_filtered,lapMatrix,'replicate');

i_sharped=imsubtract(rgb,i_tmp);

subplot(222);

imshow(i_sharped);

title('RGB空间平滑+锐化');

rgb=im2double(rgb);

r=rgb(:

:

1);

g=rgb(:

:

2);

b=rgb(:

:

3);

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

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

m2=r+g+b;

m2(m2==0)=eps;

s=1-3.*m1./m2;

m1=0.5.*((r-g)+(r-b));

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

n=acos(m1./(m1+eps));

h=n;

h(b>g)=2*pi-h(b>g);

h=h/(2*pi);

h(s==0)=0;

hsi=cat(3,h,s,i);

m=fspecial('average');

r_filtered=imfilter(h,m);

g_filtered=imfilter(s,m);

b_filtered=imfilter(i,m);

rgb_filtered=cat(3,r_filtered,g_filtered,b_filtered);

subplot(223);

imshow(rgb_filtered);

title('HSI空间平滑');

lapMatrix=[111;1-81;111];

i_tmp=imfilter(rgb,lapMatrix,'replicate');

i_sharped=imsubtract(rgb_filtered,i_tmp);

subplot(224);

imshow(i_sharped);

title('HSI空间平滑+锐化');

3载入一幅清晰彩色图像,产生运动模糊并添加一定的高斯噪声,采用维纳滤波复原该图像。

4读入工具箱中others\rose.jpg图片,进行边缘检测,并将花朵分割出来

 

3、

i=imread('peppers.png');

figure;

imshow(i);

m=fspecial('motion',20,45);

i2=imfilter(i,m,'circular');

noise=imnoise(zeros(size(i)),'gaussian',0,0.05);

figure;

imshow(noise);

i3=double(i2)+noise;

i3=uint8(i3);

figure;

imshow(i3);

i4=deconvwnr(i3,m);

figure;

imshow(i4);

4、

a=imread('liftingbody.png');

figure;

imshow(a);

a=double(a);

[m,n]=size(a);

l=256;

fori=1:

m

forj=1:

n

ifa(i,j)

r(i,j)=0;

g(i,j)=4*a(i,j);

b(i,j)=l;

elseifa(i,j)<=l/2

r(i,j)=0;

g(i,j)=l;

b(i,j)=-4*a(i,j)+2*l;

elseifa(i,j)<=3*l/4

r(i,j)=4*a(i,j)-2*l;

g(i,j)=l;

b(i,j)=0;

else

r(i,j)=l;

g(i,j)=-4*a(i,j)+4*l;

b(i,j)=0;

end

end

end

end

end

fori=1:

m

forj=1:

n

g2c(i,j,1)=r(i,j);

g2c(i,j,2)=g(i,j);

g2c(i,j,3)=b(i,j);

end

end

g2c=g2c/256;

figure;

imshow(g2c);

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

当前位置:首页 > PPT模板

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

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