Re: Reading various HDF files [message #46198] |
Wed, 09 November 2005 05:35  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Nicola writes:
> Actually for the moment I've tried only to read each sds and then to
> extract the let's call 0-zplane. I did not tried for the moment start
> and count which will be me reading just one plane and so I can divided
> for 8 the computational time. I will try..and also I will try mpeg_put
> (although I was not succesfully in creating mpeg file with IDL up to
> now :-( )
Is that because you haven't asked for the free MPEG license? :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
|
Re: Reading various HDF files [message #46200 is a reply to message #46199] |
Wed, 09 November 2005 05:11   |
peter.albert@gmx.de
Messages: 108 Registered: July 2005
|
Senior Member |
|
|
Hi Nicola,
well, it's all there, then. Haven't you used the SDS, START and COUNT
keywords to sds_read yet?
In your case, I'd loop over the files with a command like
sds_read, files[i], $
sds = "the_field_you_want_to_extrasct", $
start = [0, 0, 8], $
count = [64,128, 0], $
data
Then data should be just the field's plane you need for further
processing with e.g. MPEG_PUT.
Cheers,
Peter
|
|
|
|
|
Re: Reading various HDF files [message #46277 is a reply to message #46199] |
Thu, 10 November 2005 11:46  |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
I don't want to complicate things but forget about MPEG. MPEG is most
often a lousy format for scientific animations. I would suggest writing
all of your frames to disk as individual .png files then using another
program to create the animation.
For 8-bit animations, it's tough to beat the FLI/FLC format. Rich
Signell has a page with all you need to know to get started with FLI/FLC
format at: http://woodshole.er.usgs.gov/operations/modeling/flc.html
For 24-bit animations it is a bit more complicated as there are a number
of encoder/decoders out there. I would be happy to advise further if
you want to go this route.
If you just want to stick with MPEG, understand that most MPEG players
only support certain frame sizes and bit rates so to ensure
compatibility you need to stick to them. For frames sizes, I would
stick with D1 (704x480 or 720x480), half D1 (352x480), and quarter D1
(352x240). MPEG-2 will give you better overall quality vs file size but
not all media players play MPEG-2 content (for example, Windows Media
Player requires a special plug-in). MPEG-1 is widely compatible but you
are limited in maximum bit-rate (1856 kbps) and quality vs file size
isn't as good as MPEG-2.
-Rick
Nicola wrote:
> Actually for the moment I've tried only to read each sds and then to
> extract the let's call 0-zplane. I did not tried for the moment start
> and count which will be me reading just one plane and so I can divided
> for 8 the computational time. I will try..and also I will try mpeg_put
> (although I was not succesfully in creating mpeg file with IDL up to
> now :-( )
> thank's a lot
> n
>
|
|
|
Re: Reading various HDF files [message #46297 is a reply to message #46199] |
Wed, 09 November 2005 05:36  |
peter.albert@gmx.de
Messages: 108 Registered: July 2005
|
Senior Member |
|
|
Well, it took me a while to create MPEGs, too, but here is my recipe:
First of all, I let mpeg_put read the individual frames from a direct
graphics window. So you have to subsequently display each frame in a
window.
; In order to get the dimensions right, I'd suggest to display the
first image e.g. like
window, 1, xsize = 600, ysize = 400
tv, data
; First, open the mpeg_file:
mpegID = mpeg_open( $
[!d.x_size, !d.y_s
filename = filename
motion_vec_length = 1, $
iframe_gap = 3, $
quality = 75 $
)
; With the images I wanted to put together, simply specifying
; QUALITY brought horrible results full of
; jpeg artefacts. With MOTION_VEC_LENGTH and
; IFRAME_GAP, everything is just fine. Increasing
; IFRAME_GAP gives better results, but you pay with longer processing
time.
; O.k., now for the individual frames, assuming that you have some code
for
; reading the i-th dataset
for i = 0, n do begin
data = read_the_data(i)
tv, data
mpeg_put, mpegID, $
window = !d.window, $
/color, $
frame = i, $
/order
endfor
; After all this, you have to close the file and let IDL do a lot of
compression:
mpeg_save, mpegID
mpeg_close, mpegID
That's it. In case you have only a small number of images to show, the
MPEG file will be short, given a framerate of 24 frames per second. In
that case you can just repeatedly add one and the same frame with a
second loop, but make sure to correctly count the frame number as
provided via FRAME = i. (i.e. use something like
for j = 0, nframes-1 do begin
f = i * (nframes) + j
...
... FRAMES = f, $
...
endfor
Cheers,
Peter
)
|
|
|