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

Home » Public Forums » archive » integer to float?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
integer to float? [message #12196] Fri, 10 July 1998 00:00 Go to next message
Jonas is currently offline  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 Go to previous message
Jonas is currently offline  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 Go to previous message
menakkis is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Creating Variables in Programs
Next Topic: Imagemap?

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

Current Time: Wed Oct 08 15:40:08 PDT 2025

Total time taken to generate the page: 0.00641 seconds