making movies in idl [message #10249] |
Wed, 05 November 1997 00:00  |
nospam
Messages: 21 Registered: November 1997
|
Junior Member |
|
|
I have a set of IDL generated images that show how a two-dimensional
system changes as a parameter is varied, and I want to make an
animation that can go on a web page. How would I go about doing that
in IDL? A mult-image gif file would probably work nicely, but IDL's
write_gif routine only makes single image files.
Thanks for you feedback!
scott
--
Scott Stuart
stuart at ll mit edu
|
|
|
|
Re: making movies in idl [message #10312 is a reply to message #10249] |
Fri, 07 November 1997 00:00   |
David Foster
Messages: 341 Registered: January 1996
|
Senior Member |
|
|
Joseph Scott Stuart wrote:
>
> I have a set of IDL generated images that show how a two-dimensional
> system changes as a parameter is varied, and I want to make an
> animation that can go on a web page. How would I go about doing that
> in IDL? A mult-image gif file would probably work nicely, but IDL's
> write_gif routine only makes single image files.
>
> Thanks for you feedback!
>
> scott
Scott:
You can use a WRITE_MPEG routine that I got off this newsgroup
some time ago. You will also need the UNIX utility 'mpeg_encode'
(web site included below):
---------- Cut HERE ------------------------------------------------
; Subject: Re: MPEG creation with IDL
; From: scott@abyss.ATMOS.ColoState.Edu (Scott Denning)
;
; The following idl procedure will produce an mpeg file from a series of
; images stored in a 3D array (width x height x # of frames). It
requires
; the "mpeg_encode" executable to be in the unix search path. This can
be
; obtained from ftp://mm-ftp.cs.berkeley.edu/pub/ .
;
; Multimedia stuff previously at:
; ftp://s2k-ftp.cs.berkeley.edu/pub/multimedia/mpeg/encode.
;
; There are lots of options that can be handled differently, to make
; tradeoffs between image quality, speed, and disk space. See the
; documentation for mpeg_encode for more details.
;
; If your animation is stored in the array "image_array" and you want to
; write it to a file called "movie.mpg," you would do so by typing
;
; WRITE_MPEG, 'movie.mpg', image_array
;
PRO WRITE_MPEG, mpegFileName, image_array
movieSize = SIZE(image_array)
xSize = movieSize(1)
ySize = movieSize(2)
nFrames = movieSize(3)
nDigits = 1+FIX(ALOG10(nFrames))
formatString = STRCOMPRESS('(i'+STRING(nDigits)+'.'+STRING(nDigits)$
+ ')', /REMOVE_ALL)
; Load current color table into byte arrays
TVLCT, red, green, blue, /GET
red = BYTE(red)
green = BYTE(green)
blue = BYTE(blue)
ON_IOERROR, badWrite
; Make a temporary directory if necessary or clear it otherwise'
TMPDIR = '/tmp/idl2mpeg.frames'
SPAWN, 'if (-d ' + TMPDIR + ') echo "exists"', result
dirExists = result(0) EQ 'exists'
IF dirExists THEN command = 'rm ' + TMPDIR + '/*' $
ELSE command = 'mkdir ' + TMPDIR
SPAWN, command
; Write each frame into TMPDIR as an 8-bit .gif image file
FOR frameNum = 0, nFrames-1 DO BEGIN
fileName = TMPDIR + '/frame.' + STRING(frameNum,FORMAT=formatString)$
+ '.gif'
WRITE_GIF, fileName, image_array(*,*,frameNum), red, green, blue
ENDFOR
; Build the mpeg parameter file
paramFile = TMPDIR + '/idl2mpeg.params'
OPENW, unit, paramFile, /GET_LUN
PRINTF, unit, 'PATTERN IBBBBBBBBBBP'
PRINTF, unit, 'OUTPUT ' + mpegFileName
PRINTF, unit, 'GOP_SIZE 12'
PRINTF, unit, 'SLICES_PER_FRAME 5'
PRINTF, unit, 'BASE_FILE_FORMAT PPM'
PRINTF, unit, 'INPUT_CONVERT giftoppm *'
PRINTF, unit, 'INPUT_DIR /tmp/idl2mpeg.frames'
PRINTF, unit, 'INPUT'
PRINTF, unit, '`ls *.gif`'
PRINTF, unit, 'END_INPUT'
PRINTF, unit, 'PIXEL FULL'
PRINTF, unit, 'RANGE 5'
PRINTF, unit, 'PSEARCH_ALG LOGARITHMIC'
PRINTF, unit, 'BSEARCH_ALG SIMPLE'
PRINTF, unit, 'IQSCALE 8'
PRINTF, unit, 'PQSCALE 8'
PRINTF, unit, 'BQSCALE 8'
PRINTF, unit, 'REFERENCE_FRAME DECODED'
PRINTF, unit, 'FORCE_ENCODE_LAST_FRAME'
FREE_LUN, unit
; spawn a shell to process the mpeg_encode command
SPAWN, 'mpeg_encode ' + paramFile
RETURN
badWrite:
alert, 'Unable to write MPEG file!'
END
------------- Cut HERE -----------------------------------------------
Dave
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
|
|
|
|
|
|
Re: Making movies [message #51410 is a reply to message #10249] |
Mon, 20 November 2006 09:06   |
Jeff Hester
Messages: 21 Registered: December 2001
|
Junior Member |
|
|
Kenneth Bowman wrote:
> In article <k-bowman-2F4109.22074918112006@news-new.tamu.edu>,
> "Kenneth P. Bowman" <k-bowman@removethis.tamu.edu> wrote:
>
>
>> First, in IDL, write all the frames into a directory in some
>> obvious sequence like
>>
>> WRITE_PNG, 'frame_' + STRING(i, FORMAT = "(I4.4)") + '.png'
>
>
> I realized this morning that I forgot to include the image in the
> above IDL command (duh), which should look like this:
>
> WRITE_PNG, 'frame_' + STRING(i, FORMAT = "(I4.4)") + '.png', TVRD(TRUE = 1)
>
> I put an expanded version of my earlier message online at
>
> http://idl.tamu.edu/mactips/movies.php
>
> Cheers, Ken
Hi Ken,
Writing the images from IDL I can handle. The problem was selecting a
Mac tool to take the PNG files and string them together into a movie.
Thanks for the pointer to GraphicConverter. I'll give it a try.
Cheers,
Jeff
|
|
|
Re: Making movies [message #51417 is a reply to message #10249] |
Mon, 20 November 2006 06:39   |
K. Bowman
Messages: 330 Registered: May 2000
|
Senior Member |
|
|
In article <k-bowman-2F4109.22074918112006@news-new.tamu.edu>,
"Kenneth P. Bowman" <k-bowman@removethis.tamu.edu> wrote:
> First, in IDL, write all the frames into a directory in some
> obvious sequence like
>
> WRITE_PNG, 'frame_' + STRING(i, FORMAT = "(I4.4)") + '.png'
I realized this morning that I forgot to include the image in the
above IDL command (duh), which should look like this:
WRITE_PNG, 'frame_' + STRING(i, FORMAT = "(I4.4)") + '.png', TVRD(TRUE = 1)
I put an expanded version of my earlier message online at
http://idl.tamu.edu/mactips/movies.php
Cheers, Ken
|
|
|
Re: Making movies [message #51427 is a reply to message #10249] |
Sat, 18 November 2006 20:07   |
Kenneth P. Bowman
Messages: 585 Registered: May 2000
|
Senior Member |
|
|
In article <q6O7h.6144$7G4.5036@newsfe22.lga>,
Jeff Hester <jhester@asu.edu> wrote:
> Does anyone have a preferred solution on a Mac for stringing a bunch of
> frames together to make a movie? I've never really liked the MPEG
> routines in IDL for a variety of reasons (everything from quality of
> output to inconsistencies in the movie headers that can cause them to
> play incorrectly when launched from PowerPoint). Macs are supposed to
> be god's gift to movies, so I am certain that there are 10^4 ways of
> making a movie out of a few hundred TIFF files, but I'd settle for one
> that will make a high quality output with a sensible codec and variable
> frame rate.
>
> Thanks,
> Jeff
I'll try to get around to adding this to the MacTips web page.
http://idl.tamu.edu/mactips.php
Here is the short version.
I don't currently have a good programmatic solution from inside IDL, but
there are at least two easy ways to do it using external apps.
First, in IDL, write all the frames into a directory in some
obvious sequence like
WRITE_PNG, 'frame_' + STRING(i, FORMAT = "(I4.4)") + '.png'
I much prefer PNGs to TIFFs (8- and 24-bit, good lossless compression,
no MPEG artifacts, public domain, ...)
Once the frames are created, use GraphicConverter or QuickTime Pro to
make the frames into a movie.
GraphicConverter is an outstanding shareware program that will convert
between virtually any two graphic formats. Choose Convert & Modify from
the File menu. On the left, navigate to the directory containing the frames.
Select all the frames that you want in the movie. On the right, avigate to
the directory where you want the movie to go. Set the Dest. Format to
QuickTime (.mov). Click the Options button and select the PNG compressor.
Set the frame rate. Turn off Key frames. Click OK to get back to the
Convert & Modify dialog. Click Go. You may need to wait after if finishes
reading the files for the QuickTime movie to be created (depends on number
and size of frames).
Last, pay the shareware fee for GraphicConverter. :-)
You can also do this with Apple's QuickTime, but you have to pay Apple
the $20 or whatever to "upgrade" QuickTime to QuickTime Pro.
Ken Bowman
|
|
|
Re: Making movies [message #51511 is a reply to message #51409] |
Thu, 23 November 2006 10:52  |
Jeff Hester
Messages: 21 Registered: December 2001
|
Junior Member |
|
|
Brian Larsen wrote:
> I have always used quicktime pro with fantastic results and its $30
> which is well worth it. I have also used imagemagick and it works but
> does not do as well.
>
> Cheers,
>
> Brian
>
I may break down and pay Apple the $30. My experience with making
movies with imagemagick mirrors your own. Thanks for the numerous
suggestions.
|
|
|