Hi, I am new in Matlab. I have saved a 3D CT image data in MAT format and loaded it on Matlab. It shows [1x61x54 uint16] and 'struct' as data type. I need to do segmentation on the image. How can I view the image so that I can work on it? I don't have much idea about data structure. I badly need the solution. Thankyou.

2 commentaires

Walter Roberson
Walter Roberson le 22 Jan 2017
That size could be one single plane of an image but it cannot be an entire 3d image.
Can you attach the mat file?
Ashbub
Ashbub le 22 Jan 2017
Modifié(e) : Ashbub le 22 Jan 2017
Thankyou for your reply. Yes, you are right. I cropped the image in a way so that I can have only one slice to work on it. Here is the file.

Connectez-vous pour commenter.

 Réponse acceptée

Image Analyst
Image Analyst le 22 Jan 2017

0 votes

Try this:
filename = 'trial.mat';
s = load(filename)
% Extract array from structure.
m = s.Avizo_trial_mat;
% Get rid of 1 dimension.
m = squeeze(m);
whos m
% Display the slice:
imshow(m, [], 'InitialMagnification', 500);
axis on;

12 commentaires

Ashbub
Ashbub le 23 Jan 2017
Thanks a lot! Its working.
Melaku Eneayehu
Melaku Eneayehu le 13 Nov 2017
Error Reference to non-existent field 'Avizo_trial_mat'.
blues
blues le 16 Oct 2018
Modifié(e) : blues le 16 Oct 2018
Hello, I am also interested to view different image planes from the .mat data file. The dimension of matrix I have is 256*256*256. Whos function gives: Name Size Bytes Class Attributes
m 256x256x256 134217728 double.
How to display the image slice where (say) x, y or z = 0 or 1?
There is no zero. To display the first slice, you can use
z1 = m(:,:,1);
imshow(z1, []);
To display y or x you'll probably have to use squeeze():
y1 = squeeze(m(1, :, :));
imshow(y1, [])
x1 = squeeze(m(:, 1, :));
imshow(x1, [])
Note, y is the first index, not the second because y is usually rows. x is the second index because x is usually columns.
blues
blues le 22 Oct 2018
Thank you @Image Analyst for your help. I am also wondering about the voxel size information from the .mat file. How to extract voxel (pixel in case of image slice) information from the .mat data file?
I am asking because I am interested to calculate the dimension of (say)brain, where voxel value times # of image slices gives thickness of brain, right?
Walter Roberson
Walter Roberson le 22 Oct 2018
The variable marked as "m 256x256x256 134217728 double" contains no information about voxel sizes. Dimensions and volumes for it can only be calculated in terms of "pixels" unless there is other available information.
DICOM images are good because they almost always have additional information in the headers -- though it can sometimes be a bit tricky to interpret it.
blues
blues le 22 Oct 2018
Thank you @Walter for insight. What is the way to transform 256x256x256 into 86x256x256 matrix?
Walter Roberson
Walter Roberson le 22 Oct 2018
As of R2017a there is imresize3() for the case where the new volume should be formed by interpolation from the old volume.
But typically if you were going from 256 to something that is not 128 or 64 (or perhaps 217), then you would be more likely wanting to crop, or perhaps crop and then resize.
I do not want to resize my matrix but thinking about the following: as my matrix size is 256x256x256, I would like to stack 3 slices together in each step of analysis, so I will have altogether 84 slices. So, my matrix size will remain 256x256x256 but looks like 256x256x84 ( 84*3=256). I am using the following code to display different slices of image, but I want to stack 3 slices together, how to modify the following code for this purpose?
Also, I have 4 different intensity values (0, 0.90, 1.0, 1.40) in this matrix image, I would also like to reassign the pixel intensities to numbers like (1, 2, 3, and 4) so that I can easily visualize which is which, how to do it?
filename = 'xyz.mat'; % this is in class double
storedStructure = load(filename)
imageArray = storedStructure.image; % variable is image
% Plot of first, 2nd, 3rd image slices
image1 = imageArray(:,:,1);
image2 = imageArray(:,:,2);
image3 = imageArray(:,:,3);
subplot(2,2,1), imshow(image1)
subplot(2,2,2), imshow(image2)
subplot(2,2,3), imshow(image3)
Walter Roberson
Walter Roberson le 23 Oct 2018
So you would combine them as if they were rgb?
Note that 256 is a power of 2 and is not divisible by 3.
blues
blues le 25 Oct 2018
Not sure! I want to combine each three slices (say) to make a single slice of thickness 3 mm, so that I can print it.
The matrix I have is 256x256x256 (voxel size 1mm^3) array and would like to transform original matrix into 256x256x84 ( 256/3 approx. 84). The new matrix will have same dimension in x and y but slice thickness will be 3mm.
Based of the code posted above, I can easily see image slices. But I am thinking about to print the image slice with white matter (say, high intensity: 1.0) as 2 mm, gray matter (medium intensity: 0.5) as 1 mm, and background (low intensity part = 0) as 3 mm in a single slice. What is the way to do this? Plan is to make a meaningful stack of image slices to that I could 3d print them.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by