Re: Importing Binary Images [message #29001 is a reply to message #28873] |
Thu, 24 January 2002 09:03   |
Nigel Wade
Messages: 286 Registered: March 1998
|
Senior Member |
|
|
rob schick wrote:
> rschick@neaq.org (rob schick) wrote in message
> news:<240cd6d2.0201180638.46419bb3@posting.google.com>...
>> I'm new to idl, and am trying to import a binary grid that was created
>> on a windows machine into idl on a linux machine. It's least
>> significant byte first, 1561 rows, 2041 cols.
>>
>> I searched the archives and found a thread that suggested used the
>> following syntax:
>>
>> IDL> openr, 1, 'gom15dd.dat'
>> IDL> ms = bytarr(1561, 2041)
>> IDL> readu, 1, ms
>> IDL> tv, ms
>>
>> While this 'works', the image displayed is incorrect - sort of looks
>> like speckled white noise. Any thoughts on what I may be doing wrong.
>> For a newbie, what's the difference between using readu, and
>> read_binary? The online help didn't help. Thanks.
>
> Ok - thanks to all for the replies. The program creating the image, is
> in row-major. I created the image on an NT machine, and am using IDL
> on a linux machine (intel processor).
>
> I tried
> IDL> openr, 1, 'gom15dd.dat', /swap_if_little_endian
> IDL> ms = intarr(2041,1561)
> IDL> readu, 1, ms
> IDL> tvscl, ms
>
> and this looks better. I don't think it's quite correct, so my
> questions as related to the suggestions are:
>
> If my image is indeed not byte, do I do something different, e.g.
> -rw-r--r-- 1 robs robs 12744004 Jan 17 14:38 gom15dd.dat
> that value divided by (1561x2041) = 4 ?
With those figures it appears the data is 32bit. Try lonarr() in place of
intarr(). You should not need to do any byte swapping.
>
> Do I do anything differently to account for the row-major output?
> (specifying columns first in the openr line made the image appear more
> normal...
>
> Thanks, Rob
All you need to do is match the dimensions. Try it with (2041,1561) and
(1561,2041). One will match the vertical/horizontal size of the image. If
the row/column order is not correct I think the image will just appear
rotated - try TRANSPOSE() on the array.
--
-----------------------------------------------------------
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555
|
|
|