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:
loop

Subject: loop

From: Teoh

Date: 23 Nov, 2010 17:36:04

Message: 1 of 5

Hi people out there,

i'm doing a image process from a video but i have break them down into indivial frame, let say if i have Frame 0001 - Frame 0100 store in my C:\Users\Ren\Desktop

when i want to do imread, i have to type

Pic0001 = IMREAD('C:\Users\Ren\Desktop\Frame 0001.png');
Pic0002 = IMREAD('C:\Users\Ren\Desktop\Frame 0002.png');
:
:
:
Pic0100 = IMREAD('C:\Users\Ren\Desktop\Frame 0100.png');

is it possible to create a loop for this? help mi.....

Subject: loop

From: Sean de

Date: 23 Nov, 2010 17:53:04

Message: 2 of 5

"Teoh " <lirenteoh@hotmail.com> wrote in message <icgu24$rvn$1@fred.mathworks.com>...
> Hi people out there,
>
> i'm doing a image process from a video but i have break them down into indivial frame, let say if i have Frame 0001 - Frame 0100 store in my C:\Users\Ren\Desktop
>
> when i want to do imread, i have to type
>
> Pic0001 = IMREAD('C:\Users\Ren\Desktop\Frame 0001.png');
> Pic0002 = IMREAD('C:\Users\Ren\Desktop\Frame 0002.png');
> :
> :
> :
> Pic0100 = IMREAD('C:\Users\Ren\Desktop\Frame 0100.png');
>
> is it possible to create a loop for this? help mi.....

A few helpful hints for you:

http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F

http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F

Subject: loop

From: Teoh

Date: 24 Nov, 2010 06:33:04

Message: 3 of 5

thank i got it...

but the frame picture is at another file. if i place my code in the same folder as the picture

 a = sprintf('Frame %4.4d.png', k);

i can get it when i place it in another file

 a = sprintf('C:\Users\Ren\Desktop\simulation\'Frame %4.4d.png', k);

it is unable to read as after the C: there is a \ is there a way to solve this problem?

Subject: loop

From: Walter Roberson

Date: 24 Nov, 2010 06:35:25

Message: 4 of 5

On 24/11/10 12:33 AM, Teoh wrote:
> thank i got it...
> but the frame picture is at another file. if i place my code in the same
> folder as the picture
>
> a = sprintf('Frame %4.4d.png', k);
>
> i can get it when i place it in another file
>
> a = sprintf('C:\Users\Ren\Desktop\simulation\'Frame %4.4d.png', k);
>
> it is unable to read as after the C: there is a \ is there a way to
> solve this problem?

a = sprintf('C:\\Users\\Ren\\Desktop\\simulation\\Frame %4.4d.png', k);

Or alternately,

a = sprintf('C:/Users/Ren/Desktop/simulation/Frame %4.4d.png', k);

Subject: loop

From: Teoh

Date: 16 Jan, 2011 15:50:04

Message: 5 of 5

problem solve thank you...

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