"-clamp" doesn't always clamp
Posted: 2015-07-13T15:17:48-07:00
Blurring makes an HDRI whiter than white, and "-clamp" before writing MIFF doesn't always cure it.
Windows 8.1, IM v6.9.0-0, compiled with Cygwin. Commands are Windows BAT syntax.
The following problem occurs with HDRI Q32, but not with HDRI Q16 or HDRI Q8.
Blurring makes an HDRI whiter than white:
This is a small arithmetical glitch that I can live with, and fixed by "-clamp". This is fine.
But "-clamp" sometimes gives a value that is too large. For example, deliberately create an image that is white than white:
The numbers output are correct, and what I would expect. But what value is in m5.miff?
The value is exactly one too large.
If we convert to another HDRI miff, clamping, we still get the problem:
I get exactly the same results when using TIFF files.
I conclude that something is wrong with "-clamp" at Q32 HDRI.
(I have found no corresponding problem at the black end. )
Windows 8.1, IM v6.9.0-0, compiled with Cygwin. Commands are Windows BAT syntax.
Code: Select all
Version: ImageMagick 6.9.0-0 Q32 x86_64 2015-02-28 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC HDRI Modules OpenMP
Delegates (built-in): bzlib fontconfig freetype fpx jbig jng jpeg lcms ltdl lzma png tiff x zlib
Blurring makes an HDRI whiter than white:
Code: Select all
%IM_HDRI%convert ^
-size 1x1 xc:White ^
-precision 25 -format "%%[maxima]\n" +write info: ^
-blur 0x0.5 ^
-precision 25 -format "%%[maxima]\n" +write info: ^
-clamp ^
-precision 25 -format "%%[maxima]\n" +write info: ^
m4.miff
4294967295
4294967295.000001430511475
4294967295
But "-clamp" sometimes gives a value that is too large. For example, deliberately create an image that is white than white:
Code: Select all
%IM_HDRI%convert ^
-size 1x1 xc:White ^
-evaluate Add 111 ^
-precision 25 -format "%%[maxima]\n" +write info: ^
-clamp ^
+depth -define quantum:format=floating-point ^
-clamp ^
-precision 25 -format "%%[maxima]\n" +write info: ^
-clamp ^
m5.miff
4294967406
4294967295
Code: Select all
%IM_HDRI%convert m5.miff -precision 25 -format "%%[maxima]\n" info:
4294967296
If we convert to another HDRI miff, clamping, we still get the problem:
Code: Select all
%IM_HDRI%convert ^
m5.miff ^
-clamp ^
+depth -define quantum:format=floating-point ^
-clamp ^
m6.miff
%IM_HDRI%convert m6.miff -precision 25 -format "%%[maxima]\n" info:
4294967296
I conclude that something is wrong with "-clamp" at Q32 HDRI.
(I have found no corresponding problem at the black end. )