diff --git a/MagickCore/fx.c b/MagickCore/fx.c
index b845f0b..63a5edc 100644
--- a/MagickCore/fx.c
+++ b/MagickCore/fx.c
@@ -1128,9 +1128,12 @@
return(y);
}
-static MagickRealType FxChannelStatistics(FxInfo *fx_info,const Image *image,
+static MagickRealType FxChannelStatistics(FxInfo *fx_info,Image *image,
PixelChannel channel,const char *symbol,ExceptionInfo *exception)
{
+ ChannelType
+ channel_mask;
+
char
key[MaxTextExtent],
statistic[MaxTextExtent];
@@ -1141,24 +1144,30 @@
register const char
*p;
+ channel_mask=UndefinedChannel;
for (p=symbol; (*p != '.') && (*p != '\0'); p++) ;
if (*p == '.')
- switch (*++p) /* e.g. depth.r */
{
- case 'r': channel=RedPixelChannel; break;
- case 'g': channel=GreenPixelChannel; break;
- case 'b': channel=BluePixelChannel; break;
- case 'c': channel=CyanPixelChannel; break;
- case 'm': channel=MagentaPixelChannel; break;
- case 'y': channel=YellowPixelChannel; break;
- case 'k': channel=BlackPixelChannel; break;
- default: break;
+ ssize_t
+ option;
+
+ option=ParseCommandOption(MagickPixelChannelOptions,MagickTrue,p+1);
+ if (option >= 0)
+ {
+ channel=(PixelChannel) option;
+ channel_mask=(ChannelType) (channel_mask | (1 << channel));
+ SetPixelChannelMapMask(image,channel_mask);
+ }
}
(void) FormatLocaleString(key,MaxTextExtent,"%p.%.20g.%s",(void *) image,
(double) channel,symbol);
value=(const char *) GetValueFromSplayTree(fx_info->symbols,key);
if (value != (const char *) NULL)
- return(QuantumScale*StringToDouble(value,(char **) NULL));
+ {
+ if (channel_mask != UndefinedChannel)
+ SetPixelChannelMapMask(image,channel_mask);
+ return(QuantumScale*StringToDouble(value,(char **) NULL));
+ }
(void) DeleteNodeFromSplayTree(fx_info->symbols,key);
if (LocaleNCompare(symbol,"depth",5) == 0)
{
@@ -1223,6 +1232,8 @@
(void) FormatLocaleString(statistic,MaxTextExtent,"%g",
standard_deviation);
}
+ if (channel_mask != UndefinedChannel)
+ SetPixelChannelMapMask(image,channel_mask);
(void) AddValueToSplayTree(fx_info->symbols,ConstantString(key),
ConstantString(statistic));
return(QuantumScale*StringToDouble(statistic,(char **) NULL));
diff --git a/MagickCore/property.c b/MagickCore/property.c
index cef97d0..e02a1c8 100644
--- a/MagickCore/property.c
+++ b/MagickCore/property.c
@@ -3673,8 +3673,8 @@
(LocaleCompare("min",property) == 0) ||
(LocaleCompare("min",property) == 0) )
{
- (void) ThrowMagickException(exception,GetMagickModule(),
- OptionError,"SetReadOnlyProperty","'%s'",property);
+ (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
+ "SetReadOnlyProperty","'%s'",property);
status=MagickFalse;
break;
}
diff --git a/MagickCore/statistic.c b/MagickCore/statistic.c
index 71e16df..14130fa 100644
--- a/MagickCore/statistic.c
+++ b/MagickCore/statistic.c
@@ -1180,8 +1180,8 @@
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% GetImageMean() returns the mean and standard deviation of one or more
-% image channels.
+% GetImageMean() returns the mean and standard deviation of one or more image
+% channels.
%
% The format of the GetImageMean method is:
%
@@ -1202,15 +1202,15 @@
MagickExport MagickBooleanType GetImageMean(const Image *image,double *mean,
double *standard_deviation,ExceptionInfo *exception)
{
+ double
+ area;
+
ChannelStatistics
*channel_statistics;
register ssize_t
i;
- size_t
- area;
-
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
@@ -1218,7 +1218,7 @@
channel_statistics=GetImageStatistics(image,exception);
if (channel_statistics == (ChannelStatistics *) NULL)
return(MagickFalse);
- area=0;
+ area=0.0;
channel_statistics[CompositePixelChannel].mean=0.0;
channel_statistics[CompositePixelChannel].standard_deviation=0.0;
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
@@ -1528,10 +1528,10 @@
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% GetImageStatistics() returns statistics for each channel in the
-% image. The statistics include the channel depth, its minima, maxima, mean,
-% standard deviation, kurtosis and skewness. You can access the red channel
-% mean, for example, like this:
+% GetImageStatistics() returns statistics for each channel in the image. The
+% statistics include the channel depth, its minima, maxima, mean, standard
+% deviation, kurtosis and skewness. You can access the red channel mean, for
+% example, like this:
%
% channel_statistics=GetImageStatistics(image,exception);
% red_mean=channel_statistics[RedPixelChannel].mean;
@@ -1582,9 +1582,6 @@
ChannelStatistics
*channel_statistics;
- double
- area;
-
MagickStatusType
initialize,
status;
@@ -1613,11 +1610,7 @@
(void) ResetMagickMemory(channel_statistics,0,(MaxPixelChannels+1)*
sizeof(*channel_statistics));
for (i=0; i <= (ssize_t) MaxPixelChannels; i++)
- {
channel_statistics[i].depth=1;
- channel_statistics[i].maxima=0.0;
- channel_statistics[i].minima=0.0;
- }
initialize=MagickTrue;
for (y=0; y < (ssize_t) image->rows; y++)
{
@@ -1683,17 +1676,18 @@
channel_statistics[channel].sum_cubed+=(double) p[i]*p[i]*p[i];
channel_statistics[channel].sum_fourth_power+=(double) p[i]*p[i]*p[i]*
p[i];
+ channel_statistics[channel].area++;
}
p+=GetPixelChannels(image);
}
}
- area=(double) image->columns*image->rows;
for (i=0; i < (ssize_t) MaxPixelChannels; i++)
{
- channel_statistics[i].sum/=area;
- channel_statistics[i].sum_squared/=area;
- channel_statistics[i].sum_cubed/=area;
- channel_statistics[i].sum_fourth_power/=area;
+ if (channel_statistics[i].area != 0.0)
+ channel_statistics[i].sum/=channel_statistics[i].area;
+ channel_statistics[i].sum_squared/=channel_statistics[i].area;
+ channel_statistics[i].sum_cubed/=channel_statistics[i].area;
+ channel_statistics[i].sum_fourth_power/=channel_statistics[i].area;
channel_statistics[i].mean=channel_statistics[i].sum;
channel_statistics[i].variance=channel_statistics[i].sum_squared;
channel_statistics[i].standard_deviation=sqrt(
diff --git a/MagickCore/statistic.h b/MagickCore/statistic.h
index 4fd9cd2..1a39b65 100644
--- a/MagickCore/statistic.h
+++ b/MagickCore/statistic.h
@@ -28,6 +28,7 @@
depth;
double
+ area,
minima,
maxima,
sum,
diff --git a/MagickWand/identify.c b/MagickWand/identify.c
index f294c9a..95f5c4d 100644
--- a/MagickWand/identify.c
+++ b/MagickWand/identify.c
@@ -132,6 +132,7 @@
"-interlace type type of image interlacing scheme",
"-interpolate method pixel color interpolation method",
"-limit type value pixel cache resource limit",
+ "-mask filename associate a mask with the image",
"-monitor monitor progress",
"-ping efficiently determine image attributes",
"-quiet suppress all warning messages",
@@ -678,6 +679,15 @@
}
case 'm':
{
+ if (LocaleCompare("mask",option+1) == 0)
+ {
+ if (*option == '+')
+ break;
+ i++;
+ if (i == (ssize_t) (argc-1))
+ ThrowIdentifyException(OptionError,"MissingArgument",option);
+ break;
+ }
if (LocaleCompare("matte",option+1) == 0)
break;
if (LocaleCompare("monitor",option+1) == 0)
diff --git a/utilities/identify.1.in b/utilities/identify.1.in
index 91fba82..1f8d3c3 100644
--- a/utilities/identify.1.in
+++ b/utilities/identify.1.in
@@ -28,6 +28,7 @@
\-limit type value pixel cache resource limit
\-list type Color, Configure, Delegate, Format, Magic, Module,
Resource, or Type
+ \-mask filename associate a mask with the image
\-matte store matte channel if the image has one
\-monitor monitor progress
\-ping efficiently determine image attributes