matlab imrotate中心,MATLAB imrotate函数的用法

本文介绍了MATLAB中的imrotate函数用于图像旋转的使用方法,包括角度参数、插值方法以及输出图像属性的选择。通过示例展示了不同参数设置下图像旋转的效果,包括完整保留图像的'loose'模式和裁剪后的'crop'模式,并提供了一个创建斜矩形并旋转的实例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

MATLAB imrotate函数的用法2010-12-21 13:17:31

Imrotate 函数用来实现图像旋转: B=imrotate(A,angle, method,bbox);

angle 绕图形中心逆时针旋转的角度(deg)(angle为负值时为顺时针旋转角度)。

method就是你实现旋转用的是什么方法。有三种:最邻近插值法'nearest',双线性插值法'bilinear',三次卷积插值法'bicubic'。不同的插值方法得到的旋转图像有细微的差别。如不选,则matlab默认最邻近插值法。图像旋转后会有一定的失真(因计算每个点的新坐标的时候得到的数值不是整数,要取整造成的)。

Bbox指定输出图像属性。2选择:‘loose’或‘crop’。前者(Matlab默认),图像旋转后系统给予一个‘宽松’的环境去匹配它,得到的图片是完整的(Make output image large enough to contain the entire rotated image. Image B is generally larger than A)。‘crop’(剪切),超过图片原来大小的部分被crop了(Make output image B the same size as the input image A, cropping the rotated image to fit)。

例1:

A=imread('J:\EC_System.jpg'); % A, <325x464 uint8>

subplot(1,3,1)

imshow(A);

B=imrotate(A,30,'bilinear'); % 反时针旋转30 ,默认‘loose’。

subplot(1,3,2) %B, <517x565 uint8>

imshow(B);

C=imrotate(A,30,'bilinear','crop'); % C, <325x464 uint8>

subplot(1,3,3)

imshow(C);

337b484a63fef977a9ba00b1dff05000.png

例2:使用imrotate函数在matlab中产生一个斜矩形:

clear; clc;

w = 640;

h = 640;

A=zeros(h, w);

% create a oblique(45) rectangle in the matrix

x1 = int32(w / 5 * 2); x2 = int32(w / 5 * 3);

y1 = int32(h / 7); y2 = int32(h / 7 * 6);

% 下面这句代码产生一个常规矩形

A(y1:y2, x1:x2) = 1; A

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值