imshow index issues with display

3 次查看(过去 30 天)
I currently have a 423x27x501 3D grayscale image, which I want to view slice by slice. The image is stored in a variable called Cell.
I want imshow to show me the different slices of Cell along the 'xz' plane, so in this case each image would be a 423x501 image. If I want to view slices of the xy plane, I can simply write my code as follows
for i=1:27
figure(i)
imshow(Cell(:,:,i))
end
In each iteration of the above loop, Cell(:,:,i) is stored as a 453x27 uint8 variable, which is friendly to imshow.
However, if I do something similar for the xz plane,
for i=1:27
figure(i)
imshow(Cell(:,i,:))
end
Then instead I get an error complaining about the size of the image. In the second loop, Cell(:,i,:) is stored as a 453x1x501 uint8 variable, which confuses imshow because it thinks of this as a rank 3 tensor instead of a 2D matrix, even though it is essentially a plane.
So, is there a way to get my script to display the relevant planes via use of indexing? Or alternately is there a way to convert from a 453x1x501 variable to a 453x501 variable so that imshow can accept the input?
Thanks in advance!

采纳的回答

Stephen23
Stephen23 2017-4-26
编辑:Stephen23 2017-4-26
"is there a way to convert from a 453x1x501 variable to a 453x501 variable"
squeeze(...)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by