第一范文网 - 专业文章范例文档资料分享平台

图像处理三四五实验报告

来源:用户分享 时间:2025/8/31 7:42:23 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

实验三 图像的几何变换

一.实验目的及要求

掌握图像几何变换的基本原理,熟练掌握数字图像的缩放、旋转、平移、镜像和转置的基本原理及其MATLAB编程实现方法。

二、实验内容

(一)研究以下程序,分析程序功能;输入执行各命令行,认真观察命令执行的结果。熟悉程序中所使用函数的调用方法,改变有关参数,观察试验结果。 1. 图像缩放

clear all, close all

I = imread('cameraman.tif');

Scale = 1.35; % 将图像放大1.35倍

J1 = imresize(I, Scale, 'nearest'); % using the nearest neighbor interpolation

J2 = imresize(I, Scale, 'bilinear'); % using the bilinear interpolation imshow(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 imresize

Command窗口显示如下:

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 may 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 method 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-neighbor 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' - interpolation 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 kernel's 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, VALUE1, 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.

'Colormap' - (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 perform 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 two-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 interpolation 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('trees.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 somewhat 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 image X can be uint8, uint16, or double.

See also imresize_old, imrotate, imtransform, tformarray.

Reference page in Help browser doc imresize

执行程序所得结果如下:

搜索更多关于: 图像处理三四五实验报告 的文档
图像处理三四五实验报告.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c9i3rn7nuif9acj39pw8w_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top