实验一 :熟悉MATLAB的图象处理工具箱

更新时间:2023-11-13 08:51:01 阅读量: 教育文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

实验一 :熟悉MATLAB的图象处理工具箱

一、实验课题: 熟悉MATLAB的图象处理工具箱

二、实验内容: 熟悉Matlab编程,通过调用imread命令读取数字图像,然后进行基本数字图像处理。 三、实验目标:

1. 掌握Matlab图像处理基本函数; 2. 掌握Matlab图像几何变换。 四、实验准备:

1. 了解Matlab帮助信息中数字图像处理的基本函数; 2. 通过查阅资料,搞清楚基本函数实现功能。 五、实验重点: 掌握Matlab图像处理基本函数 六、实验难点: 运用Matlab图像处理基本函数编程 七、实验步骤:

1.启动Matlab,输入help命令,查找帮助信息中有关图像处理的基本函数。 2.输入Demo命令,观察Demo程序所进行图像处理的效果,并学会分析Demo程序。

3.进行几何变换的几种处理变换.

4.采用imread命令,读入一张图片,分析图像读入,并在工作空间分析图像数据。 八、实验程序: 垂直镜像

tic;

x=handles.imdata; [M,N]=size(x);

for i=1:M for j=1:N

y(i,j)=x(M-i+1,j); end end

Time=toc;

set(handles.edit1,'string',Time); if (M<=256)&(N<=256) W=256; else

W=max(M,N); end

extendx=double(zeros([W,W])); for m=1:W

for n=1:W

if (m<=M)&(n<=N) extendx(m,n)=y(m,n); else

extendx(m,n)=realmax; end end end

axes(handles.axes2);

imshow(extendx,[min(min(y)),max(max(y))]); handles.imdata=y;

guidata(hObject, handles); 水平镜像 tic;

x=handles.imdata; [row,col]=size(x); for i=1:row for j=1:col

y(i,j)=x(i,col-j+1); end end

Time=toc; 图像转置 tic;

x=handles.imdata; [row,col]=size(x); for i=1:col for j=1:row

y(i,j)=x(j,i); end end

Time=toc; 图像平移 tic;

x=handles.imdata; [row,col]=size(x);

prompt={'pixels of horizontal displacement:' 'pixels of vertical displacement:'}; name='Input for Geometric Transformation'; numlines=1;

defaultanswer={'50' '50'};

anss=inputdlg(prompt,name,numlines,defaultanswer); x0=str2num(anss{1}); y0=str2num(anss{2});

T=[1 0 0;0 1 0;x0 y0 1]; tform=maketform('affine',T);

g=imtransform(x,tform,'XData',[1 col],'YData',[1 row],'FillValue',0.5); Time=toc; 图像缩放 tic;

x=handles.imdata; [row,col]=size(x);

prompt={'zoom proportion for horizon(positive fraction or integer):' proportion for vertical(positive fraction or integer):'}; name='Input for Geometric Transformation'; numlines=1;

defaultanswer={'0.5' '0.5'};

anss=inputdlg(prompt,name,numlines,defaultanswer); Xratio=str2num(anss{1}); Yratio=str2num(anss{2});

T=[Xratio 0 0;0 Yratio 0;0 0 1]; tform=maketform('affine',T); g=imtransform(x,tform); Time=toc; 图像旋转 tic;

x=handles.imdata;

prompt={'Angle(-360~360):'};

name='Input for Geometric Transformation'; numlines=1;

defaultanswer={'45'};

anss=inputdlg(prompt,name,numlines,defaultanswer); theta=str2num(anss{1});

T=[cos(theta) sin(theta) 0;-sin(theta) cos(theta) 0;0 0 1]; tform=maketform('affine',T); g=imtransform(x,tform); Time=toc;

'zoom

九、实验思考: 调

本文来源:https://www.bwwdw.com/article/icev.html

Top