Rotating DICOM file around z-axis

4 ビュー (過去 30 日間)
Anouk Baeten
Anouk Baeten 2022 年 9 月 8 日
コメント済み: Cris LaPierre 2022 年 9 月 8 日
clear variables
az = 3.1415926536;
Rz = [cos(az) -sin(az) 0; sin(az) cos(az) 0; 0 0 1];
Y = dicomread('C:\Users\20182002\OneDrive - TU Eindhoven\Documents\AFSTUDEREN\Matlab\horizontal_flip\EPI02\IMG-0001-00015.dcm');
Y_rotation = Y*(Rz);
dicomwrite(Y_rotation, ("Image_flip.dcm"));
Hello,
I have a DICOM image (see attachment) which i love to rotate about the Z axis. For this I wrote a code (see above) but when I run it, I get the error: 'MTIMES (*) is not fully supported for integer classes. At least one argument must be scalar.'
So I was looking for a solution and found that you can use double() or single() to fix it. For me it would be double(Rz).
But this don't seem to work for me, can somebody help me?
  4 件のコメント
Stephen23
Stephen23 2022 年 9 月 8 日
"Or how would you do this rotation?"
IMROTATE
Cris LaPierre
Cris LaPierre 2022 年 9 月 8 日
As I said in my answer, you could use double, but that leads to a new error about a dimension mismatch error when multiplying your two arrays.

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

回答 (1 件)

Cris LaPierre
Cris LaPierre 2022 年 9 月 8 日
Y is uint16 while Rz is double. However, converting Y to double will just lead to a dimension error with your matrix multiplication, since Y is 384x384 while Rz is 3x3.
Perhaps you want to use imrotate or imrotate3?
az = 3.1415926536;
Rz = [cos(az) -sin(az) 0; sin(az) cos(az) 0; 0 0 1];
unzip('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1120005/IMG-0001-00015.dcm.zip');
Y = dicomread('IMG-0001-00015.dcm');
imshow(Y,[])
Y_rotation = imrotate(Y,rad2deg(az));
figure
imshow(Y_rotation,[])
  3 件のコメント
Anouk Baeten
Anouk Baeten 2022 年 9 月 8 日
Can you help me with that?
Cris LaPierre
Cris LaPierre 2022 年 9 月 8 日
Where are you putting the Z axis? Whether it's in the center or a corner, I feel like visually the result is the same.

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

カテゴリ

Help Center および File ExchangeDICOM Format についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by