Page 1 of 1

possible bug -normalize vs -contrast-stretch 2x1%

Posted: 2010-08-21T19:56:35-07:00
by fmw42
According to the options page documents:

"Note that as of ImageMagick 6.4.7-0, -normalize is equivalent to -contrast-stretch 2%x1%. (Before this version, it was equivalent to -contrast-stretch 2%x99%)."

But this does not appear to be the case in IM 6.6.3.8 Q16 HDRI as I am getting different looking images. Here is a simple test.


convert -size 100x100 gradient: gradient.pfm
convert gradient.pfm -normalize gradient_norm.pfm
convert gradient.pfm -contrast-stretch 2x1% gradient_cs2x1.pfm

identify -verbose gradient_norm.pfm
Channel statistics:
Gray:
min: 0 (0)
max: 65535 (1)
mean: 32767.5 (0.5)
standard deviation: 19108.4 (0.291576)
kurtosis: -1.20025


identify -verbose gradient_cs2x1.pfm
Channel statistics:
Gray:
min: 0 (0)
max: 65535 (1)
mean: 32439.8 (0.495)
standard deviation: 19659.6 (0.299987)
kurtosis: -1.20993


P.S The code in normalizeImage shows:

% The NormalizeImage() method enhances the contrast of a color image by
% mapping the darkest 2 percent of all pixel to black and the brightest
% 1 percent to white.

But then:

black_point=(double) image->columns*image->rows*0.0015;
white_point=(double) image->columns*image->rows*0.9995;


which I interpret to mean -contrast-stretch 0.15x0.05%

Using -contrast-stretch 0.15x0.05% DOES seem to match -normalize in my real image.

So testing


convert gradient.pfm -contrast-stretch 0.15x0.05% gradient_cs0p15x0p05.pfm
identify -verbose gradient_cs0p15x0p05.pfm
Channel statistics:
Gray:
min: 0 (0)
max: 65535 (1)
mean: 32767.5 (0.5)
standard deviation: 19108.4 (0.291576)
kurtosis: -1.20025


So -contrast-stretch 0.15x0.05% does match -normalize.

Re: possible bug -normalize vs -contrast-stretch 2x1%

Posted: 2010-08-22T14:49:40-07:00
by fmw42
So the question is what happens in non-HDRI and if -contrast-stretch 0.15x0.05% matches -normalize, then what should be changed -- the code to set -normalize back to 2x1% or the documentation. I think I would leave the code alone and just change the docs. But people's scripts may change behavior. Does anyone else have an opinion? Is 2x1% too harsh? I believe that photoshop may use 0.15% for both high and low clip values, but am not sure?

Was this changed recently to be closer to the GraphicsMagic values of 0.1% for both high and low values from an earlier posting?