Negative floats

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
seanburke1979

Negative floats

Post by seanburke1979 »

Hey all.
I am working with Fred Weinhaus on the Fourier routines and I have hit another snag. (Fred caught this one...).
A standard Fourier transform will produce positive *and* negative values. I assume that any Float/Double image I create with ConstituteImage will lose its negative values. This is definitely the case for a non-HDRI build. Do any of you HDRI gurus know whether sign is preserved with ConstitueImage? If not, should I scale it and pass back a different structure (eg. one that could hold a "min" and "max" value? The other option is to just return a double array and pass the problem on to the next developer. :)

Any thoughts?

Sean Burke
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Negative floats

Post by magick »

ConstituteImage() accepts doubles and floats and should preserve negative values as long as HDRI is enabled. To keep the negative values when writing to an external format on disk you would need a HDRI format such as EXR, PFM, TIFF, or MIFF to preserve values outside the normal range of [0 .. QuantumRange]. If you are using the ImageMagick MagickCore or MagickWand API's it would be more efficient to call one of the direct pixel methods such as SetImagePixels() rather than calling ConstituteImage().
Post Reply