How to rotate an image by applying rotational matrix

I guess rotating 3D image is same as rotating 2D image,right? for example, I have a 240x 240 2D image
R = [0 -1;-1 0]; % rotate 90 degree
Image = imread('pout.tif') % built-in image
Image = Image (1:240,1:240);
Image = reshape(Image , (240*240)/2, 2) * R;
Processed_image = reshape (Image,240,240);
However, It did not work.
Anyone help me?

回答 (1 件)

Matt J
Matt J 2014 年 10 月 12 日
編集済み: Matt J 2014 年 10 月 12 日

0 投票

You can use imrotate to rotate a 2D image, or a 3D stack of 2D images slice-by-slice.
Multiplying the rotation matrix by the pixel values would not be appropriate. The matrix needs to be multiplied with pixel coordinates. Then you have to interpolate the pixel values at the rotated coordinates, as imrotate or imtransform do for you internally.

4 件のコメント

tabw
tabw 2014 年 10 月 13 日
編集済み: tabw 2014 年 10 月 13 日
But in 3D images, I have to rotate angle phi and theta. Rotating a 2D image can only adjust one of these two angle.
only angle theta between x-y axis works. angle phi between y-z axis does not works.
I don't quite understand how imtransform works.
T = marketform('projective',A)
A is that where i should put the rotational matrix?
Matt J
Matt J 2014 年 10 月 13 日
You want 'affine' instead of 'projective'. The top 3x3 matrix in A will contain the rotation matrix.
tabw
tabw 2014 年 10 月 14 日
編集済み: tabw 2014 年 10 月 14 日
Matt, I got a problem using marketform My Rotation Matrix is
R_t =
0.3037 -0.9527 -0.0070
0.9528 0.3037 0
0.0021 -0.0067 1.0000
But it said The final column of A must consist of zeroes, except for a one in the last row.
How to tackle this problem??
It can't only be 0 /1 in the last column. Otherwise, how to rotate the image with certain angle?
rotation matrix from http://en.wikipedia.org/wiki/Rotation_matrix
Matt J
Matt J 2014 年 10 月 14 日
As it says in the documentation, A must be either 4x3 or 4x4. What is the dimension of your A matrix?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeGeometric Transformation and Image Registration についてさらに検索

質問済み:

2014 年 10 月 12 日

コメント済み:

2014 年 10 月 14 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by