possible bug -normalize vs -contrast-stretch 2x1%
Posted: 2010-08-21T19:56:35-07:00
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.
"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.