Page 1 of 1

possible bug with new string formats in IM 6.4.0-3

Posted: 2008-04-03T18:59:57-07:00
by fmw42
I am seeing a difference in the min and max string formats compared to generating them using bash sed. Here is an example using a grayscale image of lena http://www.fmwconcepts.com/misc_tests/lena2g.jpg in IM 6.4.0-3 Q16:

Old Method using SED:

tmp2="lena2g.jpg"
data=`convert $tmp2 -verbose info:`
min=`echo "$data" | sed -n '/^.*[Mm]in:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
echo $min
max=`echo "$data" | sed -n '/^.*[Mm]ax:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
echo $max
mean=`echo "$data" | sed -n '/^.*[Mm]ean:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
echo $mean
std=`echo "$data" | sed -n '/^.*[Ss]tandard.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
echo $std

from which I get:
min=0.109804
max=0.913725
mean=0.487606
std=0.183302



Using the new string formats and compute the statistics using bc into the same format, I get:

config=`convert -list configure`
quantum=`echo "$config" | sed -n 's/^QuantumDepth[ ]*\([0-9]*\)$/\1/ p'`
qmax=`echo "scale=0; (2^$quantum - 1) / 1" | bc`
echo $qmax
tmp2="lena2g.jpg"
data=`convert $tmp2 -verbose info:`
min=`convert $tmp2 -format "%[min]" info:`
min=`echo "scale=6; $min/$qmax" | bc`
echo $min
max=`convert $tmp2 -format "%[max]" info:`
max=`echo "scale=6; $max/$qmax" | bc`
echo $max
mean=`convert $tmp2 -format "%[mean]" info:`
mean=`echo "scale=6; $mean/$qmax" | bc`
echo $mean
std=`convert $tmp2 -format "%[standard-deviation]" info:`
std=`echo "scale=6; $std/$qmax" | bc`
echo $std

from which I get:
min=0
max=1.000000
mean=.487606
std=0.183302

Note the min and max seem to be at one digit precision.

Have I done something wrong or is this a bug in IM 6.4.0-3 in the min and max string formats?

Thanks

Fred

Re: possible bug with new string formats in IM 6.4.0-3

Posted: 2008-04-03T19:24:02-07:00
by fmw42
Its not in the reporting of -verbose info:. I think it is in the return information from

convert image -format "%[min] info:
convert image -format "%[max] info:


Thanks

Fred

Re: possible bug with new string formats in IM 6.4.0-3

Posted: 2008-04-03T19:48:18-07:00
by magick
We have a patch for the problem you reported in ImageMagick 6.4.0-4 Beta available sometime tomorrow.

Re: possible bug with new string formats in IM 6.4.0-3

Posted: 2008-04-03T19:49:02-07:00
by fmw42
thanks