1、实验四 彩色图像处理实验四 彩色图像处理一、 实验目的1、 掌握常见的几种颜色模型及各种颜色空间之间的相互转换。2、 掌握彩色图像处理的方法,如彩色图像增强、彩色图像复原、彩色图像检测与分割等。3、 了解伪彩色处理方法的原理及应用。二、 实验内容1、 读入一幅RGB图像,将其分别转换到CMY空间、HSI空间并显示。2、 利用全彩色图像处理的方法,对彩色图像进行平滑滤波及锐化处理。3、 载入一幅清晰彩色图像,产生运动模糊并添加一定的高斯噪声,采用维纳滤波复原该图像。4、 尝试将一幅单色图像采用密度分层法和灰度级-彩色变换法转化成伪彩色图像。三、 实验步骤1 转换到CMY空间rgb_I=imrea
2、d(peppers.png);cmy_I=imcomplement(rgb_I);imshow(rgb_I);figure;imshow(cmy_I);HSI空间rgb=imread(peppers.png);imshow(rgb);rgb=im2double(rgb);r=rgb(:,:,1);g=rgb(:,:,2);b=rgb(:,:,3);I=(r+g+b)/3;tmp1=min(min(r,g),b);tmp2=r+g+b;tmp2(tmp2=0)=eps;s=1-3.*tmp1./tmp2;tmp1=0.5*(r-g)+(r-b);tmp1=sqrt(r-g).2+(r-b).*(
3、g-b);theta=acos(tmp1./(tmp2+eps);h=theta;h(bg)=2*pi-h(bg);h=h/(2*pi);h(s=0)=0;hsi=cat(3,h,s,I);figure;imshow(h);figure;imshow(s);figure;imshow(I);2、rgb=imread(peppers.png);figure;imshow(rgb);r=rgb(:,:,1); %平滑滤波g=rgb(:,:,2);b=rgb(:,:,3);figure;imshow(r);figure;imshow(g);figure;imshow(b);m=fspecial(av
4、erage);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);figure;imshow(rgb_filtered);lapMatrix=1 1 1;1 -8 1;1 1 1; %锐化i_tmp=imfilter(rgb,lapMatrix,replicate);i_sharped=imsubtract(rgb,i_tmp);figure;imshow(i_sharped);3、i=imr
5、ead(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=
6、size(a);l=256;for i=1:m for j=1:n if a(i,j)l/4 r(i,j)=0; g(i,j)=4*a(i,j); b(i,j)=l; else if a(i,j)=l/2 r(i,j)=0; g(i,j)=l; b(i,j)=-4*a(i,j)+2*l; else if a(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 endendfor i=1:m for j=1:n g2c(i,j,1)=r(i,j); g2c(i,j,2)=g(i,j); g2c(i,j,3)=b(i,j); endendg2c=g2c/256;figure;imshow(g2c);
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1