comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Byte to Real conversion
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Byte to Real conversion [message #14339 is a reply to message #14334] Fri, 19 February 1999 00:00 Go to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
Michael A. Wirth wrote:
> I am reading some data in from an Magnetic Resonance image which stores
> information about the image in
> a 14336 byte header. I want to extract some of the data from this header
> and am having a problem
> with converting data to integers and reals. The integers are 2-bytes and
> the reals 4-bytes in length. How does
> one convert 4 bytes into a real number?

An easy way is to use a structure. For example, let's say the header
format is:
Bytes 0:9 are junk
Bytes 10:11 are a signed 16 bit integer
Bytes 12:15 are a 32 bit float
Bytes 16:14335 are junk

To read the header:

header = { junk1 : bytarr( 10 ), $ ; array of 10 bytes
word1 : 0, $ ; short integer
word2 : 0L, $ ; long integer
junk2 : bytarr( 14320 ) } ; array of 14320 bytes
openr, lun, 'mri.dat', /free_lun
readu, lun, header
free_lun, lun
help, header.word1, header.word2

Cheers,
Liam.

---
Liam E. Gumley
http://cimss.ssec.wisc.edu/~gumley
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: IDL 5.2 loses shared object lib.
Next Topic: Re: How do I prevent underflow errors?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 13:36:25 PDT 2025

Total time taken to generate the page: 0.40011 seconds