help-octave
[Top][All Lists]
Advanced

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

reading animated gifs on Octave 3.2.3


From: mafaraxas
Subject: reading animated gifs on Octave 3.2.3
Date: Wed, 12 May 2010 19:40:34 -0700 (PDT)

Short version of the question: Is there a way to automatically read all the
frames of an animated gif with built-in functions (e.g. imread() or
__magick_read__()), outside of silly workarounds using for-loops?

For a project I am doing, I need to be able to read an entire arbitrary
animated .gif file into Octave to run my code on it.  I know that:

[image,colormap]=imread('example.gif',i)

will output the i-th frame of my animated image 'example.gif'; the array
"image" will have dimensions M-by-N-by-1.  A quick experiment verifies that
this can be vectorized as well; e.g.

[image,colormap]=imread('example.gif',1:K)

will output the aray "image" with dimensions M-by-N-by-1-by-K, where each
cross-section of the array, image(:,:,:,i), is a frame of my image.

Now the problem is, with an arbitrary .gif file, I have no idea of the
number of frames it actually contains, so vectorizing it as above is
impossible.  Trying to overestimate the number of frames returns an error
and doesn't save anything to the array "image":

octave:1> [image,colormap]=imread('example.gif',1:1e12)
error: invalid range
error: evaluating argument list element number 2
error: evaluating argument list element number 1

I know in MATLAB there is an option with gif images to save all the frames,
i.e.,

[image,colormap]=imread('example.gif','gif','frames','all')

will return the array "image" with all the frames as image(:,:,:,i).  Is
there a similar command hidden somewhere in the functions (probably in
__magick_read__(), if anything) that I haven't found? 

I've also looked at using imfinfo(), but in both trying it firsthand and
looking at the helpfile, there are no parameters that specify the number of
frames in my gif image.

Thanks for your time.
-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/reading-animated-gifs-on-Octave-3-2-3-tp2197086p2197086.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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