Page 1 of 1

evaluate mean

Posted: 2014-08-08T14:24:35-07:00
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.

Re: evaluate mean

Posted: 2014-08-08T14:44:23-07:00
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.

Re: evaluate mean

Posted: 2014-08-09T07:22:02-07:00
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.