how can i get the image from .mat file?

my .mat file contains the following data
label: 1
PID: '100360'
image: [512x512 int16]
tumorBorder: [64x1 double]
tumorMask: [512x512 logical]
how can i get image and tumorMask from that .mat file?

1 Comment

I have .mat file how can i retrive images ffrom this data file
images: [50x3072 uint8]
label: [50x1 categorical]
C: {50x1 cell}

Sign in to comment.

Answers (1)

ds = load('NameOfMat.mat');
tumorImage = ds.image;
tumorMask = ds.tumorMask;
We recommend against using image as the name of a variable, as that interferes with the use of the fundamental graphic routine by that name and confuses readers.

11 Comments

Hi, I'm facing the same problem. I have few images in .mat format with the the following data
Capture.JPG
I tired the following code to open the image file
Capture1.JPG
and I'm getting this error
Capture3.JPG
Please help me on this
ds.cjdata.image and ds.cjdata.tumorMask
I have tried ds.cjdata.image and ds.cjdata.tumorMask, but its giving the pixel values in the command window. But i need to plot the image with tumor and do some image processing operations on in.
Semicolon at the end of the assignment lines.
imagesc(tumorImage, [-32768 32767], 'alphadata', double(tumorMask));
colormap(gray(1024))
Really it should be gray(65536) but MS Windows cannot handle colormaps that large.
Do not be surprised if you cannot see much in the way of detail. You have 16 bit signed data so I must assume that you have one of the rare datasets that actually uses 65536 levels. Much more likely is that you have ct data that uses at most -4096 to 4095 or that none of your data is negative at all and that the interesting part of it is in the 6000 to 8500 range but that the data peaks around 12000. Do an image histogram and do contrast adjustment to find the data range that is relevant to your algorithm.
I have attached the file here. Its a brain tumor MRI scan.My aim is to detect the tumor out of the MRI image
Try this:
d = tumorImage;
d(~tumorMask) = 0;
imshow(d)
imcontrast
if it asks you to adjust your display settings, permit that.
Now grab the red edges and slide them to try to figure out what range of data you want. I figure it will probably be something like 425-ish to 1650-ish.
After that you can,
dg = mat2gray(tumorImage, [425, 1650]);
dm = dg; dm(~tumorMask) = nan;
then work with either d or dm depending what you want to do.
These ranges will be subjective, and the only range you can justify mathematically as unbiased is min() of the masked area to max() of the masked area, which in the above would be min(d(:)) to max(d(:))
Hi, I've followed the steps like you said , but I'm not getting the entire MRI scan image with tumor, insted it's showing certain parts of image . I've attached my results please tell me how can i get the entire MRI scan image from that .mat file. Capture.JPG
The final result
Capture3.JPG
imshow(dg)
Your desired output is not really clear. When there is a tumor mask then people usually only want to run analysis on the tumor.
The imcontrast is there for you to explore which ranges you think are best for your purposes. My speculation is that something around 425 to something around 1650 is perhaps what is of interest to you, but you need to use imcontrast to figure out out for yourself and use the numbers you come up with in the mat2gray()
My desired output is to identify the tumor out of MRI scan images using machine learning for that i need data samples. But the samples that I've collected where in .mat format which i was not able to open.result.JPG
After typing imshow(dg) I'm able to see the data samples. And I've attached the file here.
If you are going to use machine learning, then you should just be using
imshow(tumorImage)
to see what is there. It probably won't look like much at all.
imshow(tumorImage, [])
would also be a reasonable thing to do, but you need to be careful with it, as it cannot be compared from image to image.
Amitha
Amitha on 9 Jan 2024
Moved: madhan ravi on 9 Jan 2024
how can we increase the resolution

Sign in to comment.

Categories

Asked:

on 11 Jan 2018

Moved:

on 9 Jan 2024

Community Treasure Hunt

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

Start Hunting!