matlab图像的几何变换与彩色处理.docVIP

  • 7
  • 0
  • 约4.61千字
  • 约 10页
  • 2017-02-07 发布于重庆
  • 举报
matlab图像的几何变换与彩色处理

实验四、图像的几何变换与彩色处理 实验目的 1理解和掌握图像的平移、垂直镜像变换、水平镜像变换、缩放和旋转的原理和应用; 2熟悉图像几何变换的MATLAB操作和基本功能 3 掌握彩色图像处理的基本技术 实验步骤 1 启动MATLAB程序,读入图像并对图像文件分别进行平移、垂直镜像变换、水平镜像变换、缩放和旋转操作 %%%%%%平移 flowerImg=imread(flower.jpg); se=translate(strel(1),[100 100]); img2=imdilate(flowerImg,se); subplot(1,2,1); 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(水平镜像); 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 实验如下操作: 改变图像缩放比例 f= imread(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=maketform(affine,T); [g3,xdata3,ydata3]=imtransform(f,tform,FillValue,255); hold on imshow(g3,XData, xdata3, YData, ydata3) hold on imshow(g2,XData, xdata2, YData, ydata2) hold on imshow(g1,XData, xdata1, YData, ydata1) axis auto axis on 改变图像的旋转角度, 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,T); [g4,xdata4,ydata4]=imtransform(f,tform,FillValue,255); imshow(f); hold on imshow(g3,XData, xdata3, YData, ydata3) hold on imshow(g4,XData, xdata4, YData, ydata4) axis auto axis on 观察变换结果,要求把经过不同类型几何变换的图像和原图像在同一坐标系内显示输出 (请参考课件或教材上的代码) 3 读入一幅彩色图像,进行如下图像处理: 在RGB彩色空间中对图像进行模糊和锐化处理 rgb= imread(flo

文档评论(0)

1亿VIP精品文档

相关文档