evaluate mean

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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

evaluate mean

Post by snibgo »

"-evaluate Mean" gives the wrong result. For example, with the official binary distro v6.8.9-6 for Windows 8.1:

Code: Select all

F:\web\im>%IM%convert xc:rgb(10%,20%,70%) -evaluate Mean 50% txt:

# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (60.0015%,70.0008%,100%)  #999AB333FFFF srgb(60.0015%,70.0008%,100%)
The result should be (30%,35%,60%).

I think the problem is in statistic.c, function ApplyEvaluateOperator:

Code: Select all

    case MeanEvaluateOperator:
    {
      result=(MagickRealType) (pixel+value);
      break;
    }
This is the same code as the AddEvaluateOperator case. This function is also used by EvaluateImages, which for the case of MeanEvaluateOperator divides by the number of images. So the solution isn't a simple patch:

Code: Select all

    case MeanEvaluateOperator:
    {
      result=(MagickRealType) (pixel+value)/2.0;
      break;
    }
"-evaluate Mean" [EDIT: I mean "-evaluate Median"] has a similar problem.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: evaluate mean

Post by fmw42 »

I get the same results in IM 6.8.9.6 Q16 Mac OSX.

Also using -fx

Code: Select all

convert xc:"rgb(10%,20%,70%) -format "%[fx:100*u.r]%% %[fx:100*u.g]%% %[fx:100*u.b]%%" info:
60.0015% 70.0008% 100%

Seems like the code is missing the divide by 2.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: evaluate mean

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.8.6-7 Beta available by sometime tomorrow. Thanks.
Post Reply