ExceptionInfo
*exception;
};
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
%
% The format of the AcquireFxInfo method is:
%
-% FxInfo *AcquireFxInfo(Image *image,const char *expression,
+% FxInfo *AcquireFxInfo(Image *images,const char *expression,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
-% o image: the image.
+% o images: the image sequence.
%
% o expression: the expression.
%
% o exception: return any errors or warnings in this structure.
%
*/
-MagickPrivate FxInfo *AcquireFxInfo(const Image *image,const char *expression,
+MagickPrivate FxInfo *AcquireFxInfo(const Image *images,const char *expression,
ExceptionInfo *exception)
{
char
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
(void) ResetMagickMemory(fx_info,0,sizeof(*fx_info));
fx_info->exception=AcquireExceptionInfo();
- fx_info->images=image;
+ fx_info->images=images;
fx_info->colors=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
RelinquishAlignedMemory);
fx_info->symbols=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
(void) SubstituteString(&fx_info->expression,"**",fx_op);
return(fx_info);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
noise_image=DestroyImage(noise_image);
return(noise_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
shift_image=DestroyImage(shift_image);
return(shift_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
(void) GrayscaleImage(charcoal_image,image->intensity,exception);
return(charcoal_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
colorize_image=DestroyImage(colorize_image);
return(colorize_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
color_image=DestroyImage(color_image);
return(color_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
fx_info=(FxInfo *) RelinquishMagickMemory(fx_info);
return(fx_info);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
&beta,exception);
return(exception->severity == OptionError ? MagickFalse : MagickTrue);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
fx_image=DestroyImage(fx_image);
return(fx_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
implode_image=DestroyImage(implode_image);
return(implode_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
}
return(GetFirstImageInList(morph_images));
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
image_view=DestroyCacheView(image_view);
return(status);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
polaroid_image=trim_image;
return(polaroid_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
sepia_image=DestroyImage(sepia_image);
return(sepia_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
shadow_image->page.y+=y_offset-(ssize_t) border_info.height;
return(shadow_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
blend_image=DestroyImage(blend_image);
return(sketch_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
image_view=DestroyCacheView(image_view);
return(status);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
stegano_image=DestroyImage(stegano_image);
return(stegano_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
stereo_image=DestroyImage(stereo_image);
return(stereo_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
swirl_image=DestroyImage(swirl_image);
return(swirl_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
tint_image=DestroyImage(tint_image);
return(tint_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
(void) TransformImageColorspace(vignette_image,image->colorspace,exception);
return(vignette_image);
}
-
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
if ((traits & UpdatePixelTrait) == 0)
continue;
channel_statistics[CompositePixelChannel].entropy+=
- channel_statistics[i].entropy;
+ channel_statistics[channel].entropy;
area++;
}
- if (area > MagickEpsilon)
- {
- channel_statistics[CompositePixelChannel].entropy/=area;
- channel_statistics[CompositePixelChannel].standard_deviation=
- sqrt(channel_statistics[CompositePixelChannel].standard_deviation/area);
- }
- *entropy=channel_statistics[CompositePixelChannel].entropy;
+ area=PerceptibleReciprocal(area);
+ *entropy=area*channel_statistics[CompositePixelChannel].entropy;
channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
channel_statistics);
return(MagickTrue);
}
}
image_view=DestroyCacheView(image_view);
- if (area != 0.0)
- {
- mean/=area;
- sum_squares/=area;
- sum_cubes/=area;
- sum_fourth_power/=area;
- }
+ area=PerceptibleReciprocal(area);
+ mean*=area;
+ sum_squares*=area;
+ sum_cubes*=area;
+ sum_fourth_power*=area;
standard_deviation=sqrt(sum_squares-(mean*mean));
if (standard_deviation != 0.0)
{
continue;
if ((traits & UpdatePixelTrait) == 0)
continue;
- channel_statistics[CompositePixelChannel].mean+=channel_statistics[i].mean;
+ channel_statistics[CompositePixelChannel].mean+=
+ channel_statistics[channel].mean;
channel_statistics[CompositePixelChannel].standard_deviation+=
- channel_statistics[i].variance-channel_statistics[i].mean*
- channel_statistics[i].mean;
+ channel_statistics[channel].standard_deviation;
area++;
}
- if (area > MagickEpsilon)
- {
- channel_statistics[CompositePixelChannel].mean/=area;
- channel_statistics[CompositePixelChannel].standard_deviation=
- sqrt(channel_statistics[CompositePixelChannel].standard_deviation/area);
- }
- *mean=channel_statistics[CompositePixelChannel].mean;
- *standard_deviation=
+ area=PerceptibleReciprocal(area);
+ *mean=area*channel_statistics[CompositePixelChannel].mean;
+ *standard_deviation=area*
channel_statistics[CompositePixelChannel].standard_deviation;
channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
channel_statistics);
Image
*hash_image;
-
size_t
j;
register ssize_t
x;
+ /*
+ Compute general statistics.
+ */
p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
}
}
for (i=0; i < (ssize_t) MaxPixelChannels; i++)
+ {
+ /*
+ Compute mean statistic.
+ */
+ double area=PerceptibleReciprocal(channel_statistics[i].area);
+ channel_statistics[i].mean=area*channel_statistics[i].sum;
+ }
+ for (y=0; y < (ssize_t) image->rows; y++)
+ {
+ register const Quantum
+ *magick_restrict p;
+
+ register ssize_t
+ x;
+
+ /*
+ Compute variance statistic.
+ */
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
+ break;
+ for (x=0; x < (ssize_t) image->columns; x++)
+ {
+ register ssize_t
+ i;
+
+ if (GetPixelWriteMask(image,p) == 0)
+ {
+ p+=GetPixelChannels(image);
+ continue;
+ }
+ for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+ {
+ PixelChannel channel=GetPixelChannelChannel(image,i);
+ PixelTrait traits=GetPixelChannelTraits(image,channel);
+ if (traits == UndefinedPixelTrait)
+ continue;
+ channel_statistics[channel].variance+=
+ (p[i]-channel_statistics[channel].mean)*
+ (p[i]-channel_statistics[channel].mean);
+ }
+ p+=GetPixelChannels(image);
+ }
+ }
+ for (i=0; i < (ssize_t) MaxPixelChannels; i++)
{
double
area,
channel_statistics[i].sum_squared*=area;
channel_statistics[i].sum_cubed*=area;
channel_statistics[i].sum_fourth_power*=area;
- channel_statistics[i].mean=channel_statistics[i].sum;
- channel_statistics[i].variance=channel_statistics[i].sum_squared;
- channel_statistics[i].standard_deviation=sqrt(
- channel_statistics[i].variance-(channel_statistics[i].mean*
- channel_statistics[i].mean));
number_bins=0.0;
for (j=0; j < (ssize_t) (MaxMap+1U); j++)
if (histogram[GetPixelChannels(image)*j+i] > 0.0)
channel_statistics[i].entropy+=-count*MagickLog10(count)/
MagickLog10(number_bins);
}
+ area=PerceptibleReciprocal(channel_statistics[i].area-1.0);
+ channel_statistics[i].standard_deviation=sqrt(area*
+ channel_statistics[i].variance);
}
for (i=0; i < (ssize_t) MaxPixelChannels; i++)
{
channel_statistics[i].sum_fourth_power;
channel_statistics[CompositePixelChannel].mean+=channel_statistics[i].mean;
channel_statistics[CompositePixelChannel].variance+=
- channel_statistics[i].variance-channel_statistics[i].mean*
- channel_statistics[i].mean;
+ channel_statistics[i].variance;
channel_statistics[CompositePixelChannel].standard_deviation+=
- channel_statistics[i].variance-channel_statistics[i].mean*
- channel_statistics[i].mean;
+ channel_statistics[i].standard_deviation;
if (channel_statistics[i].entropy > MagickEpsilon)
channel_statistics[CompositePixelChannel].entropy+=
channel_statistics[i].entropy;
channel_statistics[CompositePixelChannel].sum_fourth_power/=channels;
channel_statistics[CompositePixelChannel].mean/=channels;
channel_statistics[CompositePixelChannel].variance/=channels;
- channel_statistics[CompositePixelChannel].standard_deviation=
- sqrt(channel_statistics[CompositePixelChannel].standard_deviation/channels);
+ channel_statistics[CompositePixelChannel].standard_deviation/=channels;
channel_statistics[CompositePixelChannel].kurtosis/=channels;
channel_statistics[CompositePixelChannel].skewness/=channels;
channel_statistics[CompositePixelChannel].entropy/=channels;