%[max] and %[fx:maxima]

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

%[max] and %[fx:maxima]

Post by GreenKoopa »

What is the difference between %[max] and %[fx:maxima]?


> convert out.png -format "%[max] %[fx:maxima]" info:
39321 0
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

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

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

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

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply