ImageVerifierCode 换一换
格式:DOCX , 页数:36 ,大小:337.52KB ,
资源ID:4165757      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-4165757.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(数字图像处理实验报告三四五.docx)为本站会员(b****4)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

数字图像处理实验报告三四五.docx

1、数字图像处理实验报告三四五实验三 图像的几何变换一实验目的及要求掌握图像几何变换的基本原理,熟练掌握数字图像的缩放、旋转、平移、镜像和转置的基本原理及其MATLAB编程实现方法。二、实验内容(一)研究以下程序,分析程序功能;输入执行各命令行,认真观察命令执行的结果。熟悉程序中所使用函数的调用方法,改变有关参数,观察试验结果。1. 图像缩放clear all, close allI = imread(cameraman.tif);Scale = 1.35; % 将图像放大1.35倍J1 = imresize(I, Scale, nearest); % using the nearest neig

2、hbor interpolationJ2 = imresize(I, Scale, bilinear); % using the bilinear interpolationimshow(I), title(Original Image);figure, imshow(J1), title(Resized Image- using the nearest neighbor interpolation );figure, imshow(J2), title(Resized Image- using the bilinear interpolation );% 查看imresize使用帮助help

3、 imresizeCommand窗口显示如下:IMRESIZE Resize image. B = IMRESIZE(A, SCALE) returns an image that is SCALE times the size of A, which is a grayscale, RGB, or binary image. B = IMRESIZE(A, NUMROWS NUMCOLS) resizes the image so that it has the specified number of rows and columns. Either NUMROWS or NUMCOLS m

4、ay be NaN, in which case IMRESIZE computes the number of rows or columns automatically in order to preserve the image aspect ratio. Y, NEWMAP = IMRESIZE(X, MAP, SCALE) resizes an indexed image. Y, NEWMAP = IMRESIZE(X, MAP, NUMROWS NUMCOLS) resizes an indexed image. To control the interpolation metho

5、d used by IMRESIZE, add a METHOD argument to any of the syntaxes above, like this: IMRESIZE(A, SCALE, METHOD) IMRESIZE(A, NUMROWS NUMCOLS, METHOD), IMRESIZE(X, MAP, M, METHOD) IMRESIZE(X, MAP, NUMROWS NUMCOLS, METHOD) METHOD can be a string naming a general interpolation method: nearest - nearest-ne

6、ighbor interpolation bilinear - bilinear interpolation bicubic - cubic interpolation; the default method METHOD can also be a string naming an interpolation kernel: box - interpolation with a box-shaped kernel triangle - interpolation with a triangular kernel (equivalent to bilinear) cubic - interpo

7、lation with a cubic kernel (equivalent to bicubic) lanczos2 - interpolation with a Lanczos-2 kernel lanczos3 - interpolation with a Lanczos-3 kernel Finally, METHOD can be a two-element cell array of the form f,w, where f is the function handle for a custom interpolation kernel, and w is the custom

8、kernels width. f(x) must be zero outside the interval -w/2 = x w/2. Your function handle f may be called with a scalar or a vector input. You can achieve additional control over IMRESIZE by using parameter/value pairs following any of the syntaxes above. For example: B = IMRESIZE(A, SCALE, PARAM1, V

9、ALUE1, PARAM2, VALUE2, .) Parameters include: Antialiasing - true or false; specifies whether to perform antialiasing when shrinking an image. The default value depends on the interpolation method you choose. For the nearest method, the default is false; for all other methods, the default is true. C

10、olormap - (only relevant for indexed images) original or optimized; if original, then the output newmap is the same as the input map. If it is optimized, then a new optimized colormap is created. The default value is optimized. Dither - (only for indexed images) true or false; specifies whether to p

11、erform color dithering. The default value is true. Method - As described above OutputSize - A two-element vector, MROWS NCOLS, specifying the output size. One element may be NaN, in which case the other value is computed automatically to preserve the aspect ratio of the image. Scale - A scalar or tw

12、o-element vector specifying the resize scale factors. If it is a scalar, the same scale factor is applied to each dimension. If it is a vector, it contains the scale factors for the row and column dimensions, respectively. Examples - Shrink by factor of two using the defaults of bicubic interpolatio

13、n and antialiasing. I = imread(rice.png); J = imresize(I, 0.5); figure, imshow(I), figure, imshow(J) Shrink by factor of two using nearest-neighbor interpolation. (This is the fastest method, but it has the lowest quality.) J2 = imresize(I, 0.5, nearest); Resize an indexed image. X, map = imread(tre

14、es.tif); Y, newmap = imresize(X, map, 0.5); imshow(Y, newmap) Resize an RGB image to have 64 rows. The number of columns is computed automatically. RGB = imread(peppers.png); RGB2 = imresize(RGB, 64 NaN); Note - The function IMRESIZE in previous versions of the Image Processing Toolbox used a somewh

15、at different algorithm by default. If you need the same results produced by the previous implementation, call the function IMRESIZE_OLD. Class Support - The input image A can be numeric or logical and it must be nonsparse. The output image is of the same class as the input image. The input indexed i

16、mage X can be uint8, uint16, or double. See also imresize_old, imrotate, imtransform, tformarray. Reference page in Help browser doc imresize执行程序所得结果如下:改变参数Scale =0.5得到图形结果如下:对以上实验结果,分析如下:通过查看命令窗口查看imresize函数的使用方法。本实验中利用了形式B = imresize(A,m,method)。实验中method采用了,nearest(默认值)最近邻插值 方法和bilinear双线性插值方法,由图

17、片显示结果可以看出,双线性插值方法要好于最近邻插值方法。这是由于最近邻插值方法仅是取离其最近的一个像素的像素值,而双线性插值方法采用了其周围的像素值参与计算,所以更能适应图像的局部特征。m为放大倍数,由上面实验结果可以明显看出,放大1.35倍和0.5倍的效果差异。2. 图像旋转clear all, close allI = imread(cameraman.tif);Theta = 45; % 将图像逆时针旋转45。J1 = imrotate(I, Theta, nearest); % using the nearest neighbor interpolation%and enlarge t

18、he output imageTheta = -45; % 将图像顺时针旋转45。J2 = imrotate(I, Theta, bilinear, crop); % using the bilinear interpolation % and crops the output image imshow(I), title(Original Image);figure, imshow(J1), title(Rotated Image- using the nearest neighbor interpolation );figure, imshow(J2), title( Rotated Im

19、age- using the bilinear interpolation );% 查看imrotate使用帮助help imrotateCommand窗口显示如下:IMROTATE Rotate image. B = IMROTATE(A,ANGLE) rotates image A by ANGLE degrees in a counterclockwise direction around its center point. To rotate the image clockwise, specify a negative value for ANGLE. IMROTATE makes

20、the output image B large enough to contain the entire rotated image. IMROTATE uses nearest neighbor interpolation, setting the values of pixels in B that are outside the rotated image to 0 (zero). B = IMROTATE(A,ANGLE,METHOD) rotates image A, using the interpolation method specified by METHOD. METHO

21、D is a string that can have one of the following values. The default value is enclosed in braces (). nearest Nearest neighbor interpolation bilinear Bilinear interpolation bicubic Bicubic interpolation. Note: This interpolation method can produce pixel values outside the original range. B = IMROTATE

22、(A,ANGLE,METHOD,BBOX) rotates image A, where BBOX specifies the size of the output image B. BBOX is a text string that can have either of the following values. The default value is enclosed in braces (). loose Make output image B large enough to contain the entire rotated image. B is generally large

23、r than A. crop Make output image B the same size as the input image A, cropping the rotated image to fit. Class Support - The input image can be numeric or logical. The output image is of the same class as the input image. Example - % This example brings image I into horizontal alignment by % rotati

24、ng the image by -1 degree. I = fitsread(solarspectra.fts); I = mat2gray(I); J = imrotate(I,-1,bilinear,crop); figure, imshow(I), figure, imshow(J) See also imcrop, imresize, imtransform, tformarray. Reference page in Help browser doc imrotate执行程序所得结果如下:改变参数,Theta = 135和-135时,所得结果如下:实验结果分析如下:通过查看命令窗口

25、了解imrotate函数的使用。本实验中采用了函数的两种形式,B = imrotate(A,angle,method)和B = imrotate(A,angle,method,bbox)。实验中,method的设置及其原理同上个实验。实验中,bbox设置为了“crop”,其作用是为了使输出图像和输入图像大小相同,可以看出当设置了该参数是,图像明显被裁减了,这是因为图像旋转后面积变大了,而该参数的设置使图像须保持原来的大小i,因而图像被裁减了,未设置该参数时默认大小可以显示整个旋转后的图像。Angle为旋转角度,分别设置为了45和-45、135和-135,由上面两组图可以看出明显的效果和差异 3

26、图像水平镜象clear all, close allI = imread(cameraman.tif);I1 = flipdim(I,2); I2 = flipdim(I,1);figure(1), subplot(1,2,1), imshow(I);subplot(1,2,2), imshow(I1);figure(2), subplot(2,1,1), imshow(I);subplot(2,1,2), imshow(I2);执行程序,所得结果如下:对实验结果分析如下:flipdim 函数的使用方法如下。B = flipdim(A,dim)沿指定的维翻转矩阵。当dim=1时,行翻转,等同于

27、flipud ,当dim=2时,列翻转,等同于fliplr 。由上图可以看出翻转的效果。(二)用MATLAB编程实现以下图像几何变换1图像平移 程序代码如下: clc,clear all;I = imread(cameraman.tif);rows=size(I,1);cols=size(I,2);movx=50;movy=50;for i=1:rows for j=1:cols Q(i+movx,j+movy)=I(i,j); endendfigure(1);subplot(121);imshow(I);title(origine picture);subplot(122);imshow(Q

28、);title(modified picture);执行程序结果如下:实验分析如下:实验中,每个像素值以及其对应的坐标x和y都被平移了50,表现在整个图像上,即向右下角平移sqrt(50*50+50*50),显示结果如上图所示。2图像转置图像的转置是将给定图像像素的x坐标和y坐标互换的几何变换,设点P0(x0, y0) 转置后的对应点为P(x, y),转置变换可表述为: 或 ,对应的逆变换为: 或 转置后图像的宽、高发生改变,即输出图像的高度为原始图像的宽度,输出图像的宽度为原始图像的高度。 程序代码如下: clc,clear all;I = imread(cameraman.tif);row

29、s=size(I,1);cols=size(I,2);for i=1:rows for j=1:cols Q(j,i)=I(i,j); endendsize(I),size(Q)figure(1);subplot(121);imshow(I);title(origine picture);subplot(122);imshow(Q);title(modified picture); 执行程序,所得结果如下: 实验分析如下: 设图像中某个像素为p(j,i),则其值为被p(i,j)被代替,其中p为整个图像的像素矩阵。对图像中的所有像素.逐列、逐行的进行此计算,即可实现转置。实验结果如上图所示,明显

30、看出,转置后图像的宽、高发生改变,即输出图像的高度为原始图像的宽度,输出图像的宽度为原始图像的高度,整个图像被“转置”了。三、实验设备1PIII以上微机;2MATLAB6.5;四、实验心得与体会实验四 图像形态学处理一实验目的及要求1利用MATLAB研究二值形态学图像处理常用算法;2掌握MATLAB形态学图像处理基本操作函数的使用方法;3了了解形态学的基本应用。二、实验内容(一)研究以下程序,分析程序功能;输入执行各命令行,认真观察命令执行的结果。熟悉程序中所使用函数的调用方法,改变有关参数,观察试验结果。1膨胀与腐蚀(Dilation and Erosion)(1)对简单二值图像进行膨胀与腐蚀clear all, close allBW = zeros(9,10); BW(4:6,4:7) = 1;BW;SE = strel(square,3) BW1 = imdilate(BW,SE)BW2

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2