From: Cristy Date: Sat, 18 Nov 2017 20:08:10 +0000 (-0500) Subject: https://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=33050 X-Git-Tag: 7.0.7-12~70 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=60634fd986465b1b6705b1d97b65624c385de590;p=imagemagick https://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=33050 --- diff --git a/MagickCore/compare.c b/MagickCore/compare.c index 96a104518..f90ef6a03 100644 --- a/MagickCore/compare.c +++ b/MagickCore/compare.c @@ -383,8 +383,8 @@ static MagickBooleanType GetAbsoluteDistortion(const Image *image, Compute the absolute difference in pixels between two images. */ status=MagickTrue; - fuzz=GetFuzzyColorDistance(image,reconstruct_image); - fuzz*=fuzz; + fuzz=MagickMin(GetPixelChannels(image),GetPixelChannels(reconstruct_image))* + GetFuzzyColorDistance(image,reconstruct_image); rows=MagickMax(image->rows,reconstruct_image->rows); columns=MagickMax(image->columns,reconstruct_image->columns); image_view=AcquireVirtualCacheView(image,exception); @@ -420,6 +420,7 @@ static MagickBooleanType GetAbsoluteDistortion(const Image *image, { double Da, + distance, Sa; MagickBooleanType @@ -435,12 +436,13 @@ static MagickBooleanType GetAbsoluteDistortion(const Image *image, continue; } difference=MagickFalse; + distance=0.0; Sa=QuantumScale*GetPixelAlpha(image,p); Da=QuantumScale*GetPixelAlpha(reconstruct_image,q); for (i=0; i < (ssize_t) GetPixelChannels(image); i++) { double - distance; + pixel; PixelChannel channel = GetPixelChannelChannel(image,i); PixelTrait traits = GetPixelChannelTraits(image,channel); @@ -451,10 +453,11 @@ static MagickBooleanType GetAbsoluteDistortion(const Image *image, ((reconstruct_traits & UpdatePixelTrait) == 0)) continue; if (channel == AlphaPixelChannel) - distance=(double) p[i]-GetPixelChannel(reconstruct_image,channel,q); + pixel=(double) p[i]-GetPixelChannel(reconstruct_image,channel,q); else - distance=Sa*p[i]-Da*GetPixelChannel(reconstruct_image,channel,q); - if ((distance*distance) > fuzz) + pixel=Sa*p[i]-Da*GetPixelChannel(reconstruct_image,channel,q); + distance+=pixel*pixel; + if (distance > fuzz) { channel_distortion[i]++; difference=MagickTrue;