Error in im2 (line 39) imshow(ImgSg);
Mostrar comentarios más antiguos
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 comentarios
Geoff Hayes
el 5 de Dic. de 2017
Stelios - what is the full error message? What are the dimensions and data type of ImgSg? What is siz_img? Please provide more details so that we can help you determine what to do next.
Stelios Fanourakis
el 5 de Dic. de 2017
Editada: Geoff Hayes
el 5 de Dic. de 2017
Geoff Hayes
el 5 de Dic. de 2017
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
el 6 de Dic. de 2017
Respuestas (1)
Walter Roberson
el 5 de Dic. de 2017
0 votos
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()
Categorías
Más información sobre Convert Image Type en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!