简体   繁体   中英

MATLAB imshow for 3D color image

I have a medical imaging matrix of size [200x200x200].

In order to display it, I am currently using imshow3D function, which is an excellent tool, built by Maysam Shahedi. This tool displays the 3D image slice by slice, with mouse based slice browsing

In my current project, I generate an RGB image for each z-layer from the original input image. The output is a 3D color image of size [200x200x200x3] (each layer is now represented by 3 channels).

The imshow3D function works great on grayscale images. Is it possible to use it to display RGB images?

I took a look at this nice imshow3D function from Matlab FileExchange, and it is quite straight-forward to change it to allow working with a stack of RGB images.

The magic part of the function is

imshow(Img(:,:,S))

which displays the slice S of the image Img . We can simply change it to show all 3 channels of image S by changing this to Img(:,:,S,:) . The result will be of size 200-by-200-by-1-by-3 , while MATLAB expects RGB images to be of size 200-by-200-by-3 . Simply squeeze this image to get the correct dimension. This results in:

imshow(squeeze(Img(:,:,S,:))

So to show RGB images, do a search-and-replace inside the function imshow3D , to replace all occurrences of Img(:,:,S) with squeeze(Img(:,:,S,:)) and it works!

结果

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM