`rot90`在Matlab中无法正常工作。

时间:2012-03-04 00:18:02

标签: image matlab rotation image-rotation

IMAGE1

enter image description here

IMAGE2

enter image description here

理想的图片

enter image description here

我正在使用功能flipudrot90 IMAGE1 旋转为 IMAGE2 ,如下所示:

IMAGE2=rot90(flipud(IMAGE1));

然而,不知何故,我没有得到理想的图像所需的结果。谁能找出原因?请忽略期望图像中的侧面图例剪切。

1 个答案:

答案 0 :(得分:1)

以下是2D数组的示例(请参阅注释)

%# create a 2D array (3x3, but it'll work for 50x50 as well)
m = magic(3)
m =
     8     1     6
     3     5     7
     4     9     2

%# flip, then rotate, but rotate clockwise, hence the -1
rot90(flipud(m),-1)
ans =
     8     3     4
     1     5     9
     6     7     2

%# Note that this is the same as taking the transpose
m'
ans =
     8     3     4
     1     5     9
     6     7     2