integer to float? [message #12196] |
Fri, 10 July 1998 00:00  |
Jonas
Messages: 23 Registered: May 1998
|
Junior Member |
|
|
Hi all you IDL'ers
Instead of scanning the manual, I'll present a question here...
I have an image file from our Siemens Magnetom scanner.
the format is stored as bigendian and is originally in 32-bit float format.
Since I'm new at this I would like some guidance in retrieving the pixel
information in a smooth way. I have written some code like this:
Read image information to vector as 32-bit integer
perform byte-swap
save in new file as byte
read new file as 32-bit float and sort the data to a complax array.
It works fine, but I would prefer to convert from integer to float without
having to save to a new file. How is that done?
sincerely
Jonas
|
|
|
Re: integer to float? [message #12310 is a reply to message #12196] |
Tue, 14 July 1998 00:00  |
Jonas
Messages: 23 Registered: May 1998
|
Junior Member |
|
|
menakkis@my-dejanews.com skrev i meddelandet
<6obm1m$dba$1@nnrp1.dejanews.com>...
> "Jonas" <jonas_2@hotmail.com> wrote:
>> Read image information to vector as 32-bit integer
>> perform byte-swap
>> save in new file as byte
>> read new file as 32-bit float and sort the data to a complax array.
> I don't quite see what you are up to here. If I'm reading between the
lines
> correctly, it seems that your image is not actually FLOAT but
> single-precision complex, and you are uncertain about how BYTEORDER will
deal
> with complex. Either way, you can perform the byte re-ordering without
using
> a temporary file. Simply read the original image into an array of the
> correct type (FLOAT or COMPLEX?) and then do:
> BYTEORDER,my_image_array,/LSWAP
>
> This will do the proper byte order reversal (genuine bigendian to genuine
> smallendian) for LONG, FLOAT or (single-precision) COMPLEX.
>
>
> Peter Mason
>
Thanx Peter!
My problem was that I did not realise that the BYTEORDER procedure worked on
single-precision complex. Instead of reading the original file into a
complex array at once and perform BYTEORDER, I used quite a detour:
read the file as long integer, performed the byte swap (using byteorder),
saved as byte, read to vector as float, separated to real and imaginary
arrays, joined to a complex array.
Thanxalot (again), this group is a gold mine for a total newbie like me,
keep up the good work guys...
Jonas
|
|
|
Re: integer to float? [message #12325 is a reply to message #12196] |
Mon, 13 July 1998 00:00  |
menakkis
Messages: 37 Registered: June 1998
|
Member |
|
|
"Jonas" <jonas_2@hotmail.com> wrote:
> I have an image file from our Siemens Magnetom scanner.
> the format is stored as bigendian and is originally in 32-bit float format.
> Since I'm new at this I would like some guidance in retrieving the pixel
> information in a smooth way. I have written some code like this:
> Read image information to vector as 32-bit integer
> perform byte-swap
> save in new file as byte
> read new file as 32-bit float and sort the data to a complax array.
>
> It works fine, but I would prefer to convert from integer to float without
> having to save to a new file. How is that done?
I don't quite see what you are up to here. If I'm reading between the lines
correctly, it seems that your image is not actually FLOAT but
single-precision complex, and you are uncertain about how BYTEORDER will deal
with complex. Either way, you can perform the byte re-ordering without using
a temporary file. Simply read the original image into an array of the
correct type (FLOAT or COMPLEX?) and then do:
BYTEORDER,my_image_array,/LSWAP
This will do the proper byte order reversal (genuine bigendian to genuine
smallendian) for LONG, FLOAT or (single-precision) COMPLEX.
Peter Mason
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
|
|
|