help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I would like to do this, but is not supported


From: taltman
Subject: Re: I would like to do this, but is not supported
Date: Thu, 23 Oct 2003 11:23:10 -0700 (PDT)

Hi Rosario,

First off, if you want to do image processing work, and speed is
critical, then avoid using all of those eval() statements. They're
really slow relative to the other operations. Octave has to take the
time to parse / lex the string, and only then execute its
contents. Think of it as a mini-compile step.

You can get around some of your headaches with the sprintf by
realizing that the format string, just like in C, can be represented
by a string variable ( though in C it is technically a 'const'
variable ) :

-- start octave example ---

octave> printf("%d\n",1);
1
octave> format = "%d\n"
format = %d

octave> printf(format,1);
1

octave> form = "%d"
form = %d
octave> at = "\n"
at = 

octave> strcat(form,at)
ans = %d

octave> printf(strcat(form,at),1);
1

-- end octave example --

Hope this helps!

~Tomer Altman




On Oct 23, 2003 at 3:11pm, charo wrote:

rbalbo >Date: Thu, 23 Oct 2003 15:11:26 -0400
rbalbo >From: charo <address@hidden>
rbalbo >To: address@hidden
rbalbo >Subject: I would like to do this, but is not supported
rbalbo >Resent-Date: Thu, 23 Oct 2003 08:12:07 -0500
rbalbo >Resent-From: address@hidden
rbalbo >
rbalbo >
rbalbo >> Hi all,
rbalbo >> 
rbalbo >> I need to work with movies frames to compute velocity distrib. In 
file 
rbalbo >> 'fileseq' I have each frame calibrated and ready for doing 
computations. 
rbalbo >> I can load the frame as shown in (1), but I cannot save as in (2). I 
rbalbo >> know that this is not trivial to implement, but just one question for 
rbalbo >> you. Is there any scripting languaje that allows this kind of twisted 
rbalbo >> programming? Otherway, I will have to code this frame by frame which 
is 
rbalbo >> very painful for long movies.
rbalbo >> 
rbalbo >> Thanks a lot,
rbalbo >> 
rbalbo >> Rosario
rbalbo >> 
rbalbo >> 
........................................................................
rbalbo >> load fileseq;
rbalbo >> for j=1:sFrame(2)
rbalbo >>    aux=[];
rbalbo >>    for n=1:numFrames
rbalbo >>        fr = eval(sprintf("seq%03i",n)); <------------------- (1)
rbalbo >>        aux=[aux,fr(:,j)];
rbalbo >>    endfor
rbalbo >>    for i=1:sFrame(1)
rbalbo >>        tcFr = getSignedTemporalContrast(aux(i,:));
rbalbo >>        eval(sprintf("tempGrad(%03i,%03i)",i,j))= tcFr; <---- (2)
rbalbo >>    endfor
rbalbo >> endfor
rbalbo >> 
rbalbo >
rbalbo >
rbalbo >
rbalbo >
rbalbo >
rbalbo >-------------------------------------------------------------
rbalbo >Octave is freely available under the terms of the GNU GPL.
rbalbo >
rbalbo >Octave's home on the web:  http://www.octave.org
rbalbo >How to fund new projects:  http://www.octave.org/funding.html
rbalbo >Subscription information:  http://www.octave.org/archive.html
rbalbo >-------------------------------------------------------------
rbalbo >
rbalbo >



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]