[gdal-dev] Get real and turf imaginary from complex float...

Frank Warmerdam warmerdam at pobox.com
Fri Apr 17 13:54:04 EDT 2009


Derek Mueller wrote:
> Thank you Frank,
> 
> I think I should have said, how do I get both the real and imaginary 
> numbers out as Float32, since ultimately I do want to calculate 
> magnitude (as you might have guessed). Then I could read the 'real' and 
> 'imaginary' numbers into IDL as 2 separate tiffs do do the calculation. 

Derek,

Currently nothing exists to extract the just imaginary component of a
complex channel to a real channel in any of the utilities.  You would
pretty much need to write a little script or C/C++ program to do it.

> I tried to import the CFloat32 directly into IDL/ENVI but it doesn't 
> like the '64-bit pixel'.  Could there be a workaround by modifying tiff 
> tags to say the CFloat32 data are actually 2 separate 32-bit numbers?

There is no mechanism to do this in TIFF, but you might find you can
export to a raw format and then alter the raw header to describe the
raw file differently.

The only raw format driver I can find that supports complex imagery is
the MFF2 (aka HKV) format.

If I translate a CInt16 dataset to MFF2 format (which creates a directory)
I get an attrib file that looks like:

channel.enumeration = 1
channel.interleave = { *pixel tile sequential }
extent.cols = 2500
extent.rows = 14795
pixel.encoding = { unsigned *twos-complement ieee-754 }
pixel.size = 32
pixel.field = { real *complex }
pixel.order = { *lsbf msbf }
version = 1.1

If I change this to look like:

channel.enumeration = 2
channel.interleave = { *pixel tile sequential }
extent.cols = 2500
extent.rows = 14795
pixel.encoding = { unsigned *twos-complement ieee-754 }
pixel.size = 16
pixel.field = { *real complex }
pixel.order = { *lsbf msbf }
version = 1.1

The the dataset is essentially treated as two Int16 bands.
Note that channel.enumeration was changed to 2, pixel.size was
changed from 32 to 16, and pixel.field now has the star by real
instead of complex.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list