Page 1 of 1
6.6.8.5 - enable HDRI forces Q16 ?
Posted: 2011-05-01T11:48:51-07:00
by sparker
I would like HDRI support AND 32-bit quantum depth. Is this not possible at this time? The configure script is hard-wired to force Q16 when HDRI is enabled.
Re: 6.6.8.5 - enable HDRI forces Q16 ?
Posted: 2011-05-01T11:56:03-07:00
by magick
HDRI uses floats for pixels. It does not matter if you set the quantum depth to 16 or 32, you are still using 32-bit float values for each pixel component.
Re: 6.6.8.5 - enable HDRI forces Q16 ?
Posted: 2011-05-01T12:12:46-07:00
by sparker
Thanks for such a quick reply. I guess I'm confused though about what building imagemagick with a fixed quantum depth of 16 means. I'm a 3D artist and work with floating point and 16-bit UINT displacement maps (height field maps essentially) and sometimes I need to convert 32-bit files to 16-bit by performing some offset/normalization routines. What impact does Q16 have on working with floating point files in general?
Re: 6.6.8.5 - enable HDRI forces Q16 ?
Posted: 2011-05-01T13:25:16-07:00
by magick
The quantum depth is used to specify the depth of unsigned pixel components. Once you specify HDRI, pixel components are float so the quantum depth is not relevant other than setting the normalization factor. HDRI @ Q16 normalizes the values from 0 to 65535 but since its floating point that makes no difference what the normalization factor is. Keep in mind that HDRI means the pixel values can go negative and beyond the maximum value (Q16 imples 65535). If you want to clamp values, use -clamp.
Re: 6.6.8.5 - enable HDRI forces Q16 ?
Posted: 2011-05-01T15:42:54-07:00
by sparker
Ok. Maybe I should start a new thread. My main concern is Q32 because of what I'm seeing in the results of some simple pixel arithmetic. HDRI is secondary only in that I have other applications that link to IM and require HDRI enabled. If I trying something like this in my current setup (HDRI/Q16):
convert -define quantum:format=floating-point -evaluate Add 0.5 float32.tif output.tif
I had values of -0.5, I now have values of -0.49999 where I'd expect the resultant pixel value to be ~0.0. I've tried using the -depth flag, tiff-specific options, etc. But what it seems like to me is the 0.5 is being normalized before being added. Will Q32 resolve that? I've had some really strange results disabling HDRI and specifying Q32 and trying the above. In fact, I couldn't load the resulting image into any applications that support floating point tiff. So now I'm back to HDRI/Q16.
I've read everything on this forum pertaining to floating point files and could not find a clear answer. So forgive me if it's been covered and I missed it.
Re: 6.6.8.5 - enable HDRI forces Q16 ?
Posted: 2011-05-01T16:23:30-07:00
by fmw42
Sorry to stick my nose in. But if you don't use HDRI, then you cannot save negative values even with Q32. I get the impression that that is important. But if I am wrong, forgive me.
Also you might try changing your syntax to put the input image first, though it probably won't help.
convert
float32.tif -define quantum:format=floating-point -evaluate Add 0.5 output.tif
Note that in IM, values internally range from 0 to 1 (corresponding to 0 to QuantumRange for the compile). -evaluate add 0.5 with be adding 0.5 in the range of 0 to 65535 (for Q16), whereas -evaluate 50% will be adding mid gray. When you say you have values -.5 in your tiff image, in what range is that. Also how are you determining the values in your output. If using IM -verbose info:, perhaps it is just how many digits that it reports and not the true value
see
http://www.imagemagick.org/Usage/basics/#why
Again sorry if I misunderstand your problem. But perhaps you could post a link to your input image, so the IM developers can verify what you are trying to do. Also it would be helpful if you identify your IM version and platform
Re: 6.6.8.5 - enable HDRI forces Q16 ?
Posted: 2011-05-01T16:50:03-07:00
by sparker
By all means, stick your nose in.
I think the part I was missing is Q32 does not mean single precision float. It means uint32_t. Or is that wrong as well? Admittedly, I was being a 'bit' presumptuous in my original post. Pun intended.
I have textures comprised of signed floating point values that are not relegated to 0.0-1.0f. I wanted perform some -fx expressions on those values without quantization. But I was having issues using -fx (convert would hang indefinitely), so I started trying to use -evaluate for simple testing. And perhaps that is part of the problem too.
MATLAB is what I'm using to inspect values. In a nutshell, I was hoping to pipeline some image ops in floating point using imagemagick on data that is not necessarily color values.
Re: 6.6.8.5 - enable HDRI forces Q16 ?
Posted: 2011-05-01T17:16:24-07:00
by fmw42
My understanding is that Q32 will only save positive, non-fractional values to files and between functions (but internally, I believe everything is done at least at the float level). The issue is saving the results or keeping them the way you want between IM options. So to deal properly with negatives and fractional values, you need to be in HDRI. I have used Q16 successfully (for handling FFT operations), but don't really have a good grasp of the difference between Q16 HDRI and Q32 HDRI except as far as the range of values that can be stored in the file or as IM will look at it when doing calculations. With TIFF files you can also use the define to set the floating point format/depth. However, HDRI will allow values to go beyond the normal QuantumRange of Q16 (0-65535) or Q32 (0-32-bit integer). Any more details or suggestions will need to be answered by Magick or Anthony.
see
http://www.imagemagick.org/Usage/formats/#tiff
http://www.imagemagick.org/script/high- ... -range.php
http://www.imagemagick.org/Usage/basics/#hdri
Re: 6.6.8.5 - enable HDRI forces Q16 ?
Posted: 2011-05-01T17:40:37-07:00
by sparker
I'd like to thank everyone for humoring me. My impatience as well as my assumptions about a library I know very little about, got the best of me. Your responses have been very informative. I basically threw everything out and started over again based on your feedback. This did exactly as I expected with HDRI/Q16 enabled IM:
convert float32.tif -define quantum:format=floating-point -fx "u+0.5" output32.tif
It takes significantly longer than I'd expect for an 'add', but once I actually let it finish - the results were as expected. My images are typically around 4096x4096 btw. I've gotten spoiled by the speed at which some film compositing applications perform these routines. But then again, that's why they cost thousands of dollars.
Anyway, the -fx option is perfect for me and I now have a new found appreciation for the imagemagick library. Your hard work and time are much appreciated.
Re: 6.6.8.5 - enable HDRI forces Q16 ?
Posted: 2011-05-01T17:45:22-07:00
by fmw42
convert float32.tif -define quantum:format=floating-point -fx "u+0.5" output32.tif
This should be the equivalent and faster using -evaluate.
convert float32.tif -define quantum:format=floating-point -evaluate add 50% output32.tif
You might also want to look at the sections following:
http://www.imagemagick.org/Usage/transform/#evaluate
for other expressions that can be used with -evaluate and -function
convert -list evaluate
also will list the operators allowing by -evaluate
Re: 6.6.8.5 - enable HDRI forces Q16 ?
Posted: 2011-05-02T19:51:27-07:00
by anthony
HDRI as people have mentioned causes IM to switch from ints to doubles.
Other than that everything else works exactly the same!
Of course the Q level does have effects on operations that takes a non-percentage value directly EG: -level -evaluate -threshold
As such even in IM HDRI/Q16 -threshold 32768 actually means a 50% threshold.
-fx and -function however only works with normaized values (values are pre-mapped to 0.0 - 1.0 range for the functions purposes. FX is just slow as it is interpreted for each value processed - it is a DIY operation to use when nothing else can do the job.
Of course as numbers are now stored as floats fractional and out-of-bounds values are also preserved. A -clamp is provided to clip out-of-bounds but no 'intergize' type function to remove factions is available in the CLI.
Now for the important note
when saving images -depth can have effects on some image file formats, selecting between float and double values.
See IM Examples, Basics, HDRI, for all the info...
http://www.imagemagick.org/Usage/basics/#hdri