IM 6.6.3.2 Q16 Mac OSX Tiger
If one uses string formats to get the global std of an image with constant color, then it is not zero as it should be.
Example:
convert -size 100x100 xc:"rgb(230,246,255)" -depth 8 color_230_246_255.gif
convert color_230_246_255.gif -format "%[standard_deviation]" info:
2657.05
I think this is because all channels are combined and global stats are found. This makes sense for min, max and mean (as they are linear functions and can be combine this way), but not for std, which I believe is now generally incorrect in all if not most cases.
I believe that a correct formula is:
std=sqrt(variance_red + variance_green + variance_blue)
where variance for a given channel can be computed as the (mean of the square of the channel values) less the (square of the mean of the channel values), i.e.
channel variance = mean(channel*channel) - mean(channel)*mean(channel)
or (since variance = std^2):
std = sqrt( red_std^2 + green_std^2 + blue_std^2)
Thus a workaround is as follows:
convert image -format \
"%[fx: sqrt(standard_deviation.r^2 + standard_deviation.g^2 + standard_deviation.g^2)]" info:
If the developers decide to leave the string format computation for std as is, so as to keep all computations done in a consistently simplistic manner, then it might be a good idea to post some note about this issue with the std.
If the developers decide not to change the way the std string format works, then I would be willing to post some notes. Let me know.
misleading string format for standard_deviation
Re: misleading string format for standard_deviation
We can reproduce the problem you posted and have a patch in ImageMagick-6.6.3-4 Beta available by sometime tomorrow. Thanks.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: misleading string format for standard_deviation
Thanks. This now works in IM 6.6.3.4
convert -size 100x100 xc:"rgb(230,246,255)" -depth 8 color_230_246_255.gif
convert color_230_246_255.gif -format "%[standard_deviation]" info:
0
convert -size 100x100 xc:"rgb(230,246,255)" -depth 8 color_230_246_255.gif
convert color_230_246_255.gif -format "%[standard_deviation]" info:
0
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: misleading string format for standard_deviation
I think this change is related but am not certain.
Previously this example (from IM Examples, Compare)
produced...
Now I don't know what kurtosis actuall really means, but the fact that the value changes means one of them was wrong. It isn't even a 'normalized' difference.
So the question is... Is it now right, or is it now wrong?
Previously this example (from IM Examples, Compare)
Code: Select all
convert granite: granite.jpg
convert granite.jpg -solarize 50% -colorspace Gray granite_bw_test.png
identify -verbose -alpha off granite_bw_test.png | \
sed -n '/Histogram/q; /Colormap/q; /statistics:/,$ p' > granite_stats.txt
Now it producesChannel statistics:
gray:
min: 56 (0.219608)
max: 106 (0.415686)
mean: 77.8123 (0.305146)
standard deviation: 7.88841 (0.0309349)
kurtosis: -0.2523
skewness: 0.298392
note the change in the kurtosis value.Channel statistics:
Gray:
min: 56 (0.219608)
max: 106 (0.415686)
mean: 77.8123 (0.305146)
standard deviation: 7.88841 (0.0309349)
kurtosis: 39049.1
skewness: 0.298392
Now I don't know what kurtosis actuall really means, but the fact that the value changes means one of them was wrong. It isn't even a 'normalized' difference.
So the question is... Is it now right, or is it now wrong?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: misleading string format for standard_deviation
Anthony:
In IM 6.6.3.6 Q16 (HDRI), it now shows:
Channel statistics:
Gray:
min: 56 (0.219608)
max: 106 (0.415686)
mean: 77.8123 (0.305146)
standard deviation: 7.88841 (0.0309349)
kurtosis: -0.2523
skewness: 0.298392
In IM 6.6.3.6 Q16 (HDRI), it now shows:
Channel statistics:
Gray:
min: 56 (0.219608)
max: 106 (0.415686)
mean: 77.8123 (0.305146)
standard deviation: 7.88841 (0.0309349)
kurtosis: -0.2523
skewness: 0.298392
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: misleading string format for standard_deviation
Looks like it has returned to the old result.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/