Page 1 of 1

%[max] and %[fx:maxima]

Posted: 2010-12-02T18:31:52-07:00
by GreenKoopa
What is the difference between %[max] and %[fx:maxima]?


> convert out.png -format "%[max] %[fx:maxima]" info:
39321 0

Re: %[max] and %[fx:maxima]

Posted: 2010-12-02T19:04:34-07:00
by fmw42
GreenKoopa wrote:What is the difference between %[max] and %[fx:maxima]?


> convert out.png -format "%[max] %[fx:maxima]" info:
39321 0
The former gives results in the range of 0 to QuantumRange (255 for Q8 and 65535 for Q16)

The latter gives values in the range of 0 to 1.

I am not sure you can apply both at the same time as you are getting 0 for maxima, but it may be an IM issue. What version are you using?

For IM 6.6.6.2, I get


convert rose: -format "%[max]" info:
65535

convert rose: -format "%[fx:maxima]" info:
1

convert rose: -format "%[max] %[fx:maxima]" info:
65535 1

Re: %[max] and %[fx:maxima]

Posted: 2010-12-02T20:10:32-07:00
by GreenKoopa
Maybe this is caused by trying something I wasn't supposed to. I have reproduced it using two recent versions.

Code: Select all

> convert -version
Version: ImageMagick 6.6.5-8 2010-11-10 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

> convert -size 100x256 gradient:#000-#999 in.png

> convert in.png -set option:a "%[max]" -evaluate Set %[a] out.png

> convert in.png -format "%[max] %[fx:maxima]" info:
39321 0.6

> convert out.png -format "%[max] %[fx:maxima]" info:
39321 0


> convert -version
Version: ImageMagick 6.6.6-3 2010-12-01 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

> convert -size 100x256 gradient:#000-#999 in.png

> convert in.png -set option:a "%[fx:maxima]" -evaluate Set %[a] out.png

> convert in.png -format "%[max] %[fx:maxima]" info:
39321 0.6

> convert out.png -format "%[max] %[fx:maxima]" info:
0 0.6


> convert -version
Version: ImageMagick 6.6.6-3 2010-12-01 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

> convert -size 100x256 gradient:#000-#999 in.png

> convert in.png -evaluate Set %[max] out.png

> convert in.png -format "%[max] %[fx:maxima]" info:
39321 0.6

> convert out.png -format "%[max] %[fx:maxima]" info:
0 0

Re: %[max] and %[fx:maxima]

Posted: 2010-12-02T21:15:53-07:00
by fmw42
6.6.6.3 results (39321 0.6) look correct, but I don't see any 6.6.6.3 release unless it is beta.

39321/65535 = 0.6

I suspect the other results are from difference in older versions where %{fx:maxima] was only looking at the red channel and %[max] was from all channels combined.

see http://www.imagemagick.org/script/changelog.php

2010-11-08 6.6.5-8 Cristy <quetzlzacatenango@image...>
%[fx:mean] is the mean of the default channels (all but opacity) (reference viewtopic.php?f=1&t=17432).

which I suspect was changed for minima, maxima and mean

Re: %[max] and %[fx:maxima]

Posted: 2010-12-02T21:52:37-07:00
by GreenKoopa
fmw42 wrote:I don't see any 6.6.6.3 release unless it is beta.
I got it from http://www.imagemagick.org/script/binar ... hp#windows today. It is mislabeled.
fmw42 wrote:6.6.6.3 results (39321 0.6) look correct
Please see 6.6.6.3 result (0 0.6)
fmw42 wrote:I suspect the other results are from difference in older versions where %{fx:maxima] was only looking at the red channel and %[max] was from all channels combined.
That was my first IM bug find. However for this test I show generating a grayscale gradient.

Re: %[max] and %[fx:maxima]

Posted: 2010-12-03T10:05:29-07:00
by fmw42
convert in.png -set option:a "%[fx:maxima]" -evaluate Set %[a] out.png

I don't know if this is valid. I don't know if IM allows such construct in -evaluate set "%[a]". But try with quotes. If that does not work, then you need to confirm with Anthony or Magick if that is a valid construct.

Though I must admit that 0 0.6 is not consistent for the out.png result. So there does seem to be some kind of bug here.

Re: %[max] and %[fx:maxima]

Posted: 2010-12-03T11:24:17-07:00
by GreenKoopa
fmw42 wrote: convert in.png -set option:a "%[fx:maxima]" -evaluate Set %[a] out.png

I don't know if this is valid. I don't know if IM allows such construct in -evaluate set "%[a]". But try with quotes. If that does not work, then you need to confirm with Anthony or Magick if that is a valid construct.
I verified with Anthony that this is not yet supported here: viewtopic.php?f=1&t=17578
fmw42 wrote: Though I must admit that 0 0.6 is not consistent for the out.png result. So there does seem to be some kind of bug here.
Looks inconsistent to me too. I don't need anything; it just seemed worth sharing.

Re: %[max] and %[fx:maxima]

Posted: 2010-12-05T19:25:34-07:00
by anthony
fmw42 wrote:I don't know if IM allows such construct in -evaluate set "%[a]". But try with quotes. If that does not work, then you need to confirm with Anthony or Magick if that is a valid construct.
At this time -evaluate does not understand percent escapes, nor does -function, though both could easilly be modified to do so, just as -disort and -sparse-colors was modified in this way when I added that to the CLI.

You can check by looking in the source file "wand/mogrify.c", and searching for the quoted option name. It will list each option twice, once is as a syntax check, the other for the Command Line Interface call.

Stop the press! It can be done for -function, but not for -evaluate, At least not until the geometry/percent proposal is resolved. -evaluate uses percents for some things, such as color value "add" method. As such it needs to preserve percents as described in another forum discussion (where is it?). Or see...
http://www.imagemagick.org/Usage/bugs/future/#settings