Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
I need help.

Subject: I need help.

From: Yvonne t

Date: 19 Sep, 2008 19:56:01

Message: 1 of 4

I need help here.

I had images stored in a file with .mat extension.
In the .mat file, there are 3 variables namely a, b and c.
under each variable are my images files which is 512x512x47.
int16.

is there a way to extract all the images out and saved under .jpeg or .tiff or .png?

please help.

Subject: I need help.

From: Yuri Geshelin

Date: 19 Sep, 2008 20:10:03

Message: 2 of 4

"Yvonne t" <lovenpeace03@hotmail.com> wrote in message <gb104h$p02$1@fred.mathworks.com>...
> I need help here.
>
> I had images stored in a file with .mat extension.
> In the .mat file, there are 3 variables namely a, b and c.
> under each variable are my images files which is 512x512x47.
> int16.
>
> is there a way to extract all the images out and saved under .jpeg or .tiff or .png?
>
> please help.

Hi,

you will need to do it in 2 steps.

1) Load the images into RAM by means of 'load' command.
2) Save them as any image files by means of 'imwrite' command.

Read help to these functions.

Yuri

Subject: I need help.

From: Walter Roberson

Date: 19 Sep, 2008 20:16:31

Message: 3 of 4

Yuri Geshelin wrote:
> "Yvonne t" <lovenpeace03@hotmail.com> wrote in message <gb104h$p02$1@fred.mathworks.com>...

>> I had images stored in a file with .mat extension.
>> In the .mat file, there are 3 variables namely a, b and c.
>> under each variable are my images files which is 512x512x47.
>> int16.

>> is there a way to extract all the images out and saved under .jpeg or .tiff or .png?

> you will need to do it in 2 steps.

> 1) Load the images into RAM by means of 'load' command.
> 2) Save them as any image files by means of 'imwrite' command.

512x512x47 suggests that Yvonne has arrays of 47 grayscale or indexed
images. Each of those images will have to be written individually:
imwrite() cannot write multiple images in one call. Thus Yvonne
will need a loop in which the filename is calculated and the appropriate
image written. For example,

nimag = size(b,3);
for K=1:nimag
  outname = sprintf('imageb_%02d.jpg', K);
  imwrite(b(:,:,K), outname);
end

Subject: I need help.

From: Yuri Geshelin

Date: 21 Sep, 2008 03:13:07

Message: 4 of 4

Thanks Walter,

Good point.

Walter Roberson <roberson@hushmail.com> wrote in message <hMTAk.10756$Il.9209@newsfe09.iad>...
> Yuri Geshelin wrote:
> > "Yvonne t" <lovenpeace03@hotmail.com> wrote in message <gb104h$p02$1@fred.mathworks.com>...
>
> >> I had images stored in a file with .mat extension.
> >> In the .mat file, there are 3 variables namely a, b and c.
> >> under each variable are my images files which is 512x512x47.
> >> int16.
>
> >> is there a way to extract all the images out and saved under .jpeg or .tiff or .png?
>
> > you will need to do it in 2 steps.
>
> > 1) Load the images into RAM by means of 'load' command.
> > 2) Save them as any image files by means of 'imwrite' command.
>
> 512x512x47 suggests that Yvonne has arrays of 47 grayscale or indexed
> images. Each of those images will have to be written individually:
> imwrite() cannot write multiple images in one call. Thus Yvonne
> will need a loop in which the filename is calculated and the appropriate
> image written. For example,
>
> nimag = size(b,3);
> for K=1:nimag
> outname = sprintf('imageb_%02d.jpg', K);
> imwrite(b(:,:,K), outname);
> end

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us