HDRI statistics

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Locked
snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

HDRI statistics

Post by snibgo »

"-statistic ABC nxm" returns the wrong values for HDRI.

For example, we create two HDRI images, and find minima and maxima:

Code: Select all

f:\web\im>%IMG7%magick xc:srgb(10.001%,20.002%,30.003%) xc:srgb(40.004%,50.005%,60.006%)  txt:
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (6554.16,13108.3,19662.5)  #199A33344CCE  srgb(10.001%,20.002%,30.003%)
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (26216.6,32770.8,39324.9)  #66698003999D  srgb(40.004%,50.005%,60.006%)

f:\web\im>%IMG7%magick xc:srgb(10.001%,20.002%,30.003%) xc:srgb(40.004%,50.005%,60.006%) -statistic Minimum 2x2 txt:
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (6554,13108,19662)  #199A33344CCE  srgb(10.0008%,20.0015%,30.0023%)
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (26217,32771,39325)  #66698003999D  srgb(40.0046%,50.0053%,60.0061%)

f:\web\im>%IMG7%magick xc:srgb(10.001%,20.002%,30.003%) xc:srgb(40.004%,50.005%,60.006%) -statistic Maximum 2x2 txt:
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (6554,13108,19662)  #199A33344CCE  srgb(10.0008%,20.0015%,30.0023%)
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (26217,32771,39325)  #66698003999D  srgb(40.0046%,50.0053%,60.0061%)
Note that all inputs have fractions but all outputs are integers.

The problem is statistic.c, functions GetMeanPixelList() to GetStandardDeviationPixelList(). These assume pixel values are integers, type size_t. They also return values via unsigned short, like this:

Code: Select all

  *pixel=ScaleShortToQuantum((unsigned short) sqrt(sum));
The functions should also be correct for input values outside 0 to QuantumRange.

Tested with pre-built IM v7.0.8-64 Q64 HDRI on Windows 8.1.
snibgo's IM pages: im.snibgo.com

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

Re: HDRI statistics

Post by magick »

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ https://www.imagemagick.org/download/beta/ by sometime tomorrow.

Locked