From: dirk Date: Thu, 8 Jan 2015 23:04:58 +0000 (+0000) Subject: Moved duplicate max fuzz determination to new private inline method. X-Git-Tag: 7.0.1-0~1476 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a7bbf4a35fd2f0885de540b9a87a8fe33232496;p=imagemagick Moved duplicate max fuzz determination to new private inline method. Fixed creation of highlight image. Fixed calculation of distortion for a specific channel in GetAbsoluteDistortion. --- diff --git a/MagickCore/color-private.h b/MagickCore/color-private.h index 753905dee..dec4ea9c8 100644 --- a/MagickCore/color-private.h +++ b/MagickCore/color-private.h @@ -19,11 +19,22 @@ #define _MAGICKCORE_COLOR_PRIVATE_H #include "MagickCore/image.h" +#include "MagickCore/image-private.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif +static inline double GetMaxImageFuzz(const Image *a,const Image *b) +{ + double + fuzz; + + fuzz=(double) MagickMax(MagickMax(a->fuzz,b->fuzz),(MagickRealType) + MagickSQ1_2); + return(fuzz*fuzz); +} + extern MagickPrivate MagickBooleanType ColorComponentGenesis(void), IsEquivalentAlpha(const Image *,const PixelInfo *,const PixelInfo *), diff --git a/MagickCore/compare.c b/MagickCore/compare.c index 1eaa90372..f4e434c13 100644 --- a/MagickCore/compare.c +++ b/MagickCore/compare.c @@ -141,6 +141,9 @@ MagickExport Image *CompareImages(Image *image,const Image *reconstruct_image, *image_view, *reconstruct_view; + double + fuzz; + const char *artifact; @@ -206,6 +209,7 @@ MagickExport Image *CompareImages(Image *image,const Image *reconstruct_image, Generate difference image. */ status=MagickTrue; + fuzz=GetMaxImageFuzz(image,reconstruct_image); image_view=AcquireVirtualCacheView(image,exception); reconstruct_view=AcquireVirtualCacheView(reconstruct_image,exception); highlight_view=AcquireAuthenticCacheView(highlight_image,exception); @@ -278,8 +282,11 @@ MagickExport Image *CompareImages(Image *image,const Image *reconstruct_image, ((reconstruct_traits & UpdatePixelTrait) == 0)) continue; distance=Sa*p[i]-Da*GetPixelChannel(reconstruct_image,channel,q); - if (fabs(distance) >= MagickEpsilon) - difference=MagickTrue; + if ((distance*distance) > fuzz) + { + difference=MagickTrue; + break; + } } if (difference == MagickFalse) SetPixelViaPixelInfo(highlight_image,&lowlight,r); @@ -358,9 +365,7 @@ static MagickBooleanType GetAbsoluteDistortion(const Image *image, Compute the absolute difference in pixels between two images. */ status=MagickTrue; - fuzz=(double) MagickMax(MagickMax(image->fuzz,reconstruct_image->fuzz), - (MagickRealType) MagickSQ1_2); - fuzz*=fuzz; + fuzz=GetMaxImageFuzz(image,reconstruct_image); image_view=AcquireVirtualCacheView(image,exception); reconstruct_view=AcquireVirtualCacheView(reconstruct_image,exception); #if defined(MAGICKCORE_OPENMP_SUPPORT) @@ -428,15 +433,12 @@ static MagickBooleanType GetAbsoluteDistortion(const Image *image, distance=Sa*p[i]-Da*GetPixelChannel(reconstruct_image,channel,q); if ((distance*distance) > fuzz) { + channel_distortion[i]++; difference=MagickTrue; - break; } } if (difference != MagickFalse) - { - channel_distortion[i]++; - channel_distortion[CompositePixelChannel]++; - } + channel_distortion[CompositePixelChannel]++; p+=GetPixelChannels(image); q+=GetPixelChannels(reconstruct_image); } diff --git a/MagickCore/pixel.c b/MagickCore/pixel.c index c43c3489b..8c6ba124d 100644 --- a/MagickCore/pixel.c +++ b/MagickCore/pixel.c @@ -6036,9 +6036,7 @@ MagickExport MagickBooleanType IsFuzzyEquivalencePixel(const Image *source, distance, scale; - fuzz=(double) MagickMax(MagickMax(source->fuzz,destination->fuzz), - (MagickRealType) MagickSQ1_2); - fuzz*=fuzz; + fuzz=GetMaxImageFuzz(source,destination); scale=1.0; distance=0.0; if (source->alpha_trait != UndefinedPixelTrait)