File Exchange

image thumbnail

imshow3D

version 1.6.1.0 (4.21 KB) by Maysam Shahedi
imshow3D:(3D imshow) Displays 3D images slice by slice.Intensity adjusting & slice browsing by mouse

140 Downloads

Updated 29 Oct 2018

View License

imshow3D displays 3D grayscale or RGB images in a slice by slice fashion with mouse-based slice browsing and window and level adjustment control, and auto slice browsing control.
Usage:
imshow3D ( Image )
imshow3D ( Image , [] )
imshow3D ( Image , [LOW HIGH] )
imshow3D ( Image , [] , initsn )

Image: 3D image MxNxKxC (K slices of MxN images) C is either 1 for grayscale images) or 3 (for RGB images)
[LOW HIGH]: display range that controls the display intensity range of a grayscale image (default: the broadest available range)
initsn: The slice number to be displayed initially (default: mid-slice number)
Use the scroll bar or mouse scroll wheel to switch between slices. To adjust window and level values keep the mouse right button pressed, and drag the mouse up and down (for level adjustment) or right and left (for window adjustment). Window and level adjustment control works only for grayscale images.
"Play" button displays all the slices as a sequence of frames. The time interval value can also be adjusted (default time interval is 100 ms).
"Auto W/L" button adjust the window and level automatically for grayscale images.

While "Fine Tune" checkbox is checked the window/level adjustment gets 16 times less sensitive to mouse movement, to make it easier to control
display intensity rang.

Note: The sensitivity of mouse-based window and level adjustment is set based on the user-defined display intensity range; the wider the range, the more sensitivity to mouse drag.

Note: IMSHOW3DFULL is a newer version of IMSHOW3D (also available on MathWorks) that displays 3D grayscale or RGB images from three perpendicular views (i.e., axial, sagittal, and coronal).

Example
--------
% To display an image (MRI example)
load mri
Image = squeeze(D);
figure,
imshow3D(Image)

% To display the image, and adjust the display range
figure,
imshow3D(Image,[20 100]);

% To define the initial slice number
figure,
imshow3D(Image,[],5);

Cite As

Maysam Shahedi (2019). imshow3D (https://www.mathworks.com/matlabcentral/fileexchange/41334-imshow3d), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (58)

JoaquinB

Good job!

Fiona Gong

Really good code, easy to use perfect!!! Thanks!

Shujaat Khan

welldone

Kyrie long

ryyan

Doaa Mousa

LMZ

Fereshteh

Hi Adam,
My suggestion is to modify imshow3D code and make your own version of imshow3D. You can add the plot command within the code.
Hope it helps.

adam

Hello,
I am fairly new to MATLAB, and I am using the 'imshow3D' GUI for displaying 3D images and using the slider to switch through each slices. I wish to plot points on specific slices.

Each points have an X,Y, and Z component (Z being the slice number). I have tried using the code below;

[I,J,Z] = ind2sub(size(Eroded_EntropyFilterQ_3D_n16_pt3_Filter5_Struct_pt31012),cursor_info1(:,3))
figure,imshow3D(Eroded_EntropyFilterQ_3D_n16_pt3_Filter5_Struct_pt31012)
hold on
plot(J,I,'ro')
The points do plot in the slice viewer, however I get an error when switching through the slices, and the points appear on every slices.

Is there a way to fix this problem?

Thank you so much!

Hi,
You can send me your questions about the function via the email address I have provided (mshahedi@gmail.com).
Thank you!

Sigal Cohen

Hello,
It's my first time using Matlab and I'm having a difficult time trying to understand the function you wrote regarding imshow3D. Do you have any advice for me how to get to the bottom of it?
Thank you,
Sigal.

My apology if the name was misleading to you. I called it imshow3D because, as I mentioned in the subtitle, it displays "3D images" slice-by-slice. I also wanted to make it similar to imshow command of Matlab.

Faranak

I don't understand why you call it 3d show while it is showing 2d images and show slice by slice?

The accepted data type for imwrite is unsigned integer (e.g. uint16). Try
imwrite(im2uint16(image(:,:,150)), 'raw3D.jpg','BitDepth',16);
for 'jpeg' format or
imwrite(im2uint16(image(:,:,150)), 'raw3D.png');
for png format.
Hope it helps

thanks again Maysam. i tried saving one of the slice like
imwrite(image(:,:,150),'raw3D.jpg'); but it says that this is int16 and can't save as jpg or png.
can you help

try this
figure, imshow3D(img, [])
and see if it helps to see the images in full dynamic range or not.

For saving the image, if you use the figure menu bar you will get a snapshot of the whole GUI and you need to crop it. To avoid that you can try saving your image using "imwrite" command.

Hope it helps

thanks. i wrote this code which help to see every image but the image looks like binary whereas my format is uint16
fid=fopen('VESSEL12_21.raw');
W=fread(fid,512*512*459,'uint16');
fclose(fid);
W=reshape(W,[512 512 459]);
W=imrotate(W,-90);
img=squeeze(W);
figure; imshow3D(img);
moreover when i try to store image as jpg,full screen is getting saved, not just image

It does not matter what is the image file format. What you need to do is read the 3D image and store it as a 3D matrix, then call imshow3D("matrix_name").

does this work on raw file. i wrote load('......raw') but not working

Laila

Ran Kafri

Ander Biguri

FAS

can help me how imshow image 3D on ghraphic interface (GUI) just code simple .
thank you answer me please on this mail: mounaho@gmail.com

faisal aziz

i need a code to 3d visualization from brain mri multiple slices can any one help me??

MB

Just a waste of time. Better use figure;imagesc.

Michael

how can i get this file please ??

Awesome!

Fereshteh

Hi Matthew,
Thank you for your interest in imshow3D. You need to input your image as a 3D matrix (e.g. Img) as follows:

imshow3D(Img)

You can also follow this example in Matlab to test it:

load mri
Image = squeeze(D);
figure,
imshow3D(Image)

Hope it works for you
Maysam

I am new to Matlab and I'm having difficulty using this function. where exactly do I input my image? I keep getting 'undefined function or variable 'Img''.

Zahra

Great work! thanks!

Erfaneh

Thank you, It was very useful for me.

Erfaneh

Lukas

simplest usage and absolute intuitive! Very nice, thank you very much!

Fantastic work! Very useful~

Nathan

Well done, I have tried it and it is awsome

Hi Mohammad,

if you mean to control the display intensity range of the image, yes, you can do it by pressing the right button of the mouse on the image and dragging the mouse to left and right or up and down.

By the way, in the next update (in few days) an option will be added to the function for calling the function with a specific display intensity range, similar to what we have for "imshow" function.

Hope it addressed your question. Please feel free to contact me if you have any further question about it.

is there a way to scale matrices in color map using this function?

Updates

1.6.1.0

Bug fixed; the previous figure is now cleared before displaying a new image.

1.6.0.0

An auto sequential display option has been added.

1.5.0.0

Title revised

1.5.0.0

Now it can also display 3D RGB images.

1.4.0.0

New Version of imshow3D has been released under imshow3Dfull name. It displays 3 orthogonal views (axial, sagittal, and coronal views) one by one.

1.3.0.0

Display intensity range option has been added.
Minor bugs have been fixed.
It is more similar to Matlab imshow function now.
One example has been added to the help page.

1.1.0.0

This function needs image processing toolbox too.

MATLAB Release Compatibility
Created with R2017b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Acknowledgements

Inspired: Visualize 3D data