Error in im2 (line 39) imshow(ImgSg);

2 次查看(过去 30 天)
ImgAx = siz_img;
if verLessThan('matlab', '8')
ImgSg = flipdim(permute(siz_img, [3 1 2 4]),1); % Sagittal view image
ImgCr = flipdim(permute(siz_img, [3 2 1 4]),1); % Coronal view image
else
ImgSg = flip(permute(siz_img, [3 1 2 4]),1); % Sagittal view image
ImgCr = flip(permute(siz_img, [3 2 1 4]),1); % Coronal view image
end
figure
imshow(ImgSg);
figure
imshow(ImgCr);
Why is this error?
  4 个评论
Geoff Hayes
Geoff Hayes 2017-12-5
Stelios - having the full code does not necessarily help as it is the dicom images that may be needed to solve this problem.... Without them, I still won't be able to determine the dimensions or data type of siz_img...
Stelios Fanourakis
Stelios Fanourakis 2017-12-6
they are foot slices 255x255, int16 slices. 25 images in total

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2017-12-5
siz_img is a row vector of dimensions of image Z01 . The assignment ct3d(:,:,1) = img would not work if img was more than 2D, so siz_img is a row vector of length 2. When you permute(siz_img, [3 1 2 4]) then the second dimension would move to the third dimension, so the output would be 1 x 1 x length(siz_img) = 1 x 1 x 2. You then try to imshow() that 1 x 1 x 2, which fails because imshow() can only handle arrays that are either 2D or 3D with the third dimension being length 3.
It would probably make more sense to be permuting the ct3d instead. However, when you do so, unless the original image just happened to be 3 pixels wide, you are going to encounter the same problem with imshow()
The only built-in MATLAB function for displaying volumes is the R2017a and later volumeViewer()

类别

Help CenterFile Exchange 中查找有关 DICOM Format 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by