From: cristy Date: Sun, 9 Nov 2014 23:54:16 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~1751 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=44706661c10e56ccd366f5d48b28f3103ff21e5e;p=imagemagick --- diff --git a/MagickCore/statistic.c b/MagickCore/statistic.c index 339babe4e..15a674b3a 100644 --- a/MagickCore/statistic.c +++ b/MagickCore/statistic.c @@ -1151,9 +1151,12 @@ MagickExport MagickBooleanType GetImageEntropy(const Image *image, channel_statistics[i].entropy; area++; } - channel_statistics[CompositePixelChannel].entropy/=area; - channel_statistics[CompositePixelChannel].standard_deviation= - sqrt(channel_statistics[CompositePixelChannel].standard_deviation/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; channel_statistics=(ChannelStatistics *) RelinquishMagickMemory( channel_statistics); @@ -1413,9 +1416,12 @@ MagickExport MagickBooleanType GetImageMean(const Image *image,double *mean, channel_statistics[i].mean; area++; } - channel_statistics[CompositePixelChannel].mean/=area; - channel_statistics[CompositePixelChannel].standard_deviation= - sqrt(channel_statistics[CompositePixelChannel].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= channel_statistics[CompositePixelChannel].standard_deviation;