how to convert a.mat file in to png?

I got a B-mode fatty liver ultrasound images from kaggle dataset.here is the file path for the dataset.I want to convert the images into png format how can I do it?
/kaggle/input/dataset-of-bmode-fatty-liver-ultrasound-images

Answers (1)

Read about volumeViewer
load('dataset_liver_bmodes_steatosis_assessment_IJCARS.mat')
I = data(1).images ;
volumeViewer(I)

5 Comments

I just copied your code on matlab and but It displayes an error message of
"Undefined function 'volumeViewer' for input arguments of type 'double'."
What version you are using?
What does
which volumeViewer
/MATLAB/toolbox/images/imuitools/volumeViewer.m
show up?
The volumeviewer app requires Image Processing Toolbox and R2017a or newer. If you don't have that, there are other viewing tools for volumetric images on the File Exchange:
Otherwise, if you know the slice you want, extract it and reorient it if necessary using permute(), flip(), rot90(), and then write it to a PNG using imwrite(). That said, unless you're blindly slicing the whole volume to images, it's easier to be able to see what you're selecting.
Can you try using the 'imwrite' function in MATLAB to convert a .MAT file to a .PNG image.
Here's an example:
load('yourFile.mat');
im = yourVariable; % substitute "yourVariable" with the name of the variable in your .MAT file
imwrite(im, 'yourFile.png');
Note that the input to the imwrite function should be a 2D or 3D matrix representing an image. If your .MAT file contains other data types, you'll need to extract the image data before passing it to imwrite.
Specifically, it should be a MxNx1 or MxNx3 array to be compatible with imwrite() directly. imwrite() will not accept a volumetric image directly.

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Asked:

on 7 Feb 2023

Commented:

DGM
on 8 Feb 2023

Community Treasure Hunt

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

Start Hunting!