matlab图像的几何变换与彩色处理_第1页
matlab图像的几何变换与彩色处理_第2页
matlab图像的几何变换与彩色处理_第3页
matlab图像的几何变换与彩色处理_第4页
matlab图像的几何变换与彩色处理_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、实验四、图像的几何变换与彩色处理一、实验目的1理解和掌握图像的平移、垂直镜像变换、水平镜像变换、缩放和旋转的原理和应用;2熟悉图像几何变换的MATLAB操作和基本功能3 掌握彩色图像处理的基本技术二、实验步骤1 启动MATLAB程序,读入图像并对图像文件分别进行平移、垂直镜像变换、水平镜像变换、缩放和旋转操作%平移>> flowerImg=imread('flower.jpg'>> se=translate(strel(1,100 100;>> img2=imdilate(flowerImg,se;>> subplot(1,2,1

2、;>> imshow(flowerImg;>> subplot(1,2,2;>> imshow(img2; I1=imread('flower.jpg'I1=double(I1;H=size(I1;I2(1:H(1,1:H(2,1:H(3=I1(H(1:-1:1,1:H(2,1:H(3; I3(1:H(1,1:H(2,1:H(3=I1(1:H(1,H(2:-1:1,1:H(3; Subplot(2,2,1;Imshow(uint8(I1;Title('原图'Subplot(2,2,2;Imshow(uint8(I3;Title

3、('水平镜像'Subplot(2,2,3;Imshow(uint8(I2;Title('垂直镜像' img1=imread('flower.jpg'figure,imshow(img1;%缩放img2=imresize(img1,0.25;figure,imshow(img2;imwrite(img2,'a2.jpg'%旋转img3=imrotate(img1,90; figure,imshow(img3; imwrite(img3,'a3.jpg' 2 实验如下操作:(1改变图像缩放比例f= imread(

4、9;flower.jpg'T= 0.5 0 0; 0 0.5 0; 0 0 1;tform=maketform('affine',T;g1,xdata1,ydata1=imtransform(f,tform,'FillValue',255;T= 1 0 0; 0 1 0; 0 0 1;tform=maketform('affine',T;g2,xdata2,ydata2=imtransform(f,tform,'FillValue',255;T= 1.5 0 0; 0 1.5 0; 0 0 1;tform=maketfor

5、m('affine',T;g3,xdata3,ydata3=imtransform(f,tform,'FillValue',255;hold onimshow(g3,'XData', xdata3, 'YData', ydata3hold onimshow(g2,'XData', xdata2, 'YData', ydata2hold onimshow(g1,'XData', xdata1, 'YData', ydata1axis autoaxis on (2改变图像

6、的旋转角度,f= imread('flower.jpg'theta=3*pi/4;T=cos(theta sin(theta 0; -sin(theta cos(theta 0; 0 0 1; tform=maketform('affine',T;g3,xdata3,ydata3=imtransform(f,tform,'FillValue',255; theta=pi;T=cos(theta sin(theta 0; -sin(theta cos(theta 0; 0 0 1; tform=maketform('affine',

7、T;g4,xdata4,ydata4=imtransform(f,tform,'FillValue',255; imshow(f;hold onimshow(g3,'XData', xdata3, 'YData', ydata3hold onimshow(g4,'XData', xdata4, 'YData', ydata4axis autoaxis on 观察变换结果,要求把经过不同类型几何变换的图像和原图像在同一坐标系内显示输出(请参考课件或教材上的代码3 读入一幅彩色图像,进行如下图像处理:(1在RGB彩色空

8、间中对图像进行模糊和锐化处理rgb= imread('flower.jpg'figure; imshow(rgb; title('原图'%平滑滤波r=rgb(:,:,1;g=rgb(:,:,2;b=rgb(:,:,3;m=fspecial('average',8,8;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

9、_filtered; title('模糊后'imwrite(rgb_filtered, 'RGB彩色空间模糊后.jpg'%拉普拉斯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; title('锐化后' imwrite(i_sharped, 'RGB彩色空间锐化后.jpg' (2在HSI彩色空间中,对H分量图像进行模

10、糊和锐化处理,转换回RGB格式并观察效果(3在HSI彩色空间中,对S分量图像进行模糊和锐化处理,转换回RGB格式并观察效果(4在HSI彩色空间中,对I分量图像进行模糊和锐化处理,转换回RGB格式并观察效果fc = imread('flower.jpg'h = rgb2hsi(fc;H = h (:,:,1;S = h (:,:,2;I = h (:,:,3;subplot(3,3,1;imshow(fc; title('原图'%平滑滤波m=fspecial('average',8,8;h_filtered=imfilter(H,m;img_h_f

11、iltered = cat(3,h_filtered,S,I;rgb_h_filtered = hsi2rgb(img_h_filtered;subplot(3,3,2;imshow(rgb_h_filtered; title('H分量模糊后'imwrite(rgb_h_filtered, 'H分量模糊后.jpg'%拉普拉斯lapMatrix=1 1 1;1 -8 1;1 1 1;i_tmp=imfilter(H,lapMatrix,'replicate'H_sharped=imsubtract(H,i_tmp;img_h_sharped = c

12、at(3,H_sharped,S,I;rgb_h_sharped = hsi2rgb(img_h_sharped;subplot(3,3,3; imshow(rgb_h_sharped; title('H分量锐化后' imwrite(rgb_h_sharped, 'H分量锐化后.jpg'subplot(3,3,4;imshow(fc; title('原图'%平滑滤波m=fspecial('average',8,8;s_filtered=imfilter(S,m;img_s_filtered = cat(3,H,s_filtered

13、,I;rgb_s_filtered = hsi2rgb(img_s_filtered;subplot(3,3,5;imshow(rgb_s_filtered; title('S分量模糊后' imwrite(rgb_s_filtered, 'S分量模糊后.jpg'%拉普拉斯lapMatrix=1 1 1;1 -8 1;1 1 1;i_tmp=imfilter(S,lapMatrix,'replicate's_sharped=imsubtract(S,i_tmp;img_s_sharped = cat(3,H,s_sharped,I;rgb_s_sh

14、arped = hsi2rgb(img_s_sharped;subplot(3,3,6; imshow(rgb_s_sharped; title('S分量锐化后' imwrite(rgb_s_sharped, 'S分量锐化后.jpg'subplot(3,3,7;imshow(fc; title('原图'%平滑滤波m=fspecial('average',8,8;i_filtered=imfilter(I,m;img_i_filtered = cat(3,H,S,i_filtered;rgb_i_filtered = hsi2rgb(img_i_filtered;subplot(3,3,8;imshow(rgb_i_filtered; title('I分量模糊后' imwrite(rgb_i_filtered, 'I分量模糊后.jpg'%拉普拉斯lapMatrix=1 1 1;1 -8 1;1 1 1;i_tmp=imfilter(I,lapMatrix,'replicate'

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论