How to rotate an image by applying rotational matrix
조회 수: 3 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (1개)
Matt J
2014년 10월 12일
편집: Matt J
2014년 10월 12일
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
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?
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!