From: cristy Date: Tue, 18 Oct 2011 15:24:30 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~6790 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0913681b0661b193eb7a615eac7dc7900f58ff10;p=imagemagick --- diff --git a/MagickCore/compare.c b/MagickCore/compare.c index 8b2ce8145..289f77fd9 100644 --- a/MagickCore/compare.c +++ b/MagickCore/compare.c @@ -1445,7 +1445,8 @@ MagickExport MagickBooleanType IsImagesEqual(Image *image, % The format of the SimilarityImageImage method is: % % Image *SimilarityImage(const Image *image,const Image *reference, -% RectangleInfo *offset,double *similarity,ExceptionInfo *exception) +% const MetricType metric,RectangleInfo *offset,double *similarity, +% ExceptionInfo *exception) % % A description of each parameter follows: % @@ -1453,6 +1454,8 @@ MagickExport MagickBooleanType IsImagesEqual(Image *image, % % o reference: find an area of the image that closely resembles this image. % +% o metric: the metric. +% % o the best match offset of the reference image within the image. % % o similarity: the computed similarity between the images. @@ -1461,111 +1464,9 @@ MagickExport MagickBooleanType IsImagesEqual(Image *image, % */ -static double GetNCCDistortion(const Image *image, - const Image *reconstruct_image, - const ChannelStatistics *reconstruct_statistics,ExceptionInfo *exception) -{ -#define SimilarityImageTag "Similarity/Image" - - CacheView - *image_view, - *reconstruct_view; - - ChannelStatistics - *image_statistics; - - double - distortion; - - MagickBooleanType - status; - - MagickRealType - area, - gamma; - - ssize_t - y; - - /* - Normalize to account for variation due to lighting and exposure condition. - */ - image_statistics=GetImageStatistics(image,exception); - status=MagickTrue; - distortion=0.0; - area=1.0/((MagickRealType) image->columns*image->rows-1); - image_view=AcquireCacheView(image); - reconstruct_view=AcquireCacheView(reconstruct_image); - for (y=0; y < (ssize_t) image->rows; y++) - { - register const Quantum - *restrict p, - *restrict q; - - register ssize_t - x; - - if (status == MagickFalse) - continue; - p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception); - q=GetCacheViewVirtualPixels(reconstruct_view,0,y,reconstruct_image->columns, - 1,exception); - if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL)) - { - status=MagickFalse; - continue; - } - for (x=0; x < (ssize_t) image->columns; x++) - { - register ssize_t - i; - - for (i=0; i < (ssize_t) GetPixelChannels(image); i++) - { - PixelChannel - channel; - - PixelTrait - reconstruct_traits, - traits; - - traits=GetPixelChannelMapTraits(image,(PixelChannel) i); - channel=GetPixelChannelMapChannel(image,(PixelChannel) i); - reconstruct_traits=GetPixelChannelMapTraits(reconstruct_image,channel); - if ((traits == UndefinedPixelTrait) || - (reconstruct_traits == UndefinedPixelTrait)) - continue; - if ((reconstruct_traits & UpdatePixelTrait) == 0) - continue; - distortion+=area*QuantumScale*(p[i]-image_statistics[i].mean)* - (GetPixelChannel(reconstruct_image,channel,q)- - reconstruct_statistics[channel].mean); - } - p+=GetPixelChannels(image); - q+=GetPixelChannels(reconstruct_image); - } - } - reconstruct_view=DestroyCacheView(reconstruct_view); - image_view=DestroyCacheView(image_view); - /* - Divide by the standard deviation. - */ - gamma=image_statistics[MaxPixelChannels].standard_deviation* - reconstruct_statistics[MaxPixelChannels].standard_deviation; - gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma); - distortion=QuantumRange*gamma*distortion; - distortion=sqrt(distortion/GetImageChannels(image)); - /* - Free resources. - */ - image_statistics=(ChannelStatistics *) RelinquishMagickMemory( - image_statistics); - return(1.0-distortion); -} - static double GetSimilarityMetric(const Image *image,const Image *reference, - const ChannelStatistics *reference_statistics,const ssize_t x_offset, - const ssize_t y_offset,ExceptionInfo *exception) + const MetricType metric,const ssize_t x_offset,const ssize_t y_offset, + ExceptionInfo *exception) { double distortion; @@ -1573,6 +1474,9 @@ static double GetSimilarityMetric(const Image *image,const Image *reference, Image *similarity_image; + MagickBooleanType + status; + RectangleInfo geometry; @@ -1582,23 +1486,24 @@ static double GetSimilarityMetric(const Image *image,const Image *reference, similarity_image=CropImage(image,&geometry,exception); if (similarity_image == (Image *) NULL) return(0.0); - distortion=GetNCCDistortion(reference,similarity_image,reference_statistics, + distortion=0.0; + status=GetImageDistortion(similarity_image,reference,metric,&distortion, exception); similarity_image=DestroyImage(similarity_image); + if (status == MagickFalse) + return(0.0); return(distortion); } MagickExport Image *SimilarityImage(Image *image,const Image *reference, - RectangleInfo *offset,double *similarity_metric,ExceptionInfo *exception) + const MetricType metric,RectangleInfo *offset,double *similarity_metric, + ExceptionInfo *exception) { #define SimilarityImageTag "Similarity/Image" CacheView *similarity_view; - ChannelStatistics - *reference_statistics; - Image *similarity_image; @@ -1637,7 +1542,6 @@ MagickExport Image *SimilarityImage(Image *image,const Image *reference, */ status=MagickTrue; progress=0; - reference_statistics=GetImageStatistics(reference,exception); similarity_view=AcquireCacheView(similarity_image); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp parallel for schedule(dynamic,4) shared(progress,status) @@ -1667,8 +1571,7 @@ MagickExport Image *SimilarityImage(Image *image,const Image *reference, register ssize_t i; - similarity=GetSimilarityMetric(image,reference,reference_statistics,x,y, - exception); + similarity=GetSimilarityMetric(image,reference,metric,x,y,exception); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp critical (MagickCore_SimilarityImage) #endif @@ -1717,7 +1620,5 @@ MagickExport Image *SimilarityImage(Image *image,const Image *reference, } } similarity_view=DestroyCacheView(similarity_view); - reference_statistics=(ChannelStatistics *) RelinquishMagickMemory( - reference_statistics); return(similarity_image); } diff --git a/MagickCore/compare.h b/MagickCore/compare.h index 15944b7ee..50de712cf 100644 --- a/MagickCore/compare.h +++ b/MagickCore/compare.h @@ -44,8 +44,8 @@ extern MagickExport double extern MagickExport Image *CompareImages(Image *,const Image *,const MetricType,double *, ExceptionInfo *), - *SimilarityImage(Image *,const Image *,RectangleInfo *,double *, - ExceptionInfo *); + *SimilarityImage(Image *,const Image *,const MetricType,RectangleInfo *, + double *,ExceptionInfo *); extern MagickExport MagickBooleanType GetImageDistortion(Image *,const Image *,const MetricType,double *, diff --git a/MagickCore/magick-config.h b/MagickCore/magick-config.h index 0616c229b..7d8c047b5 100644 --- a/MagickCore/magick-config.h +++ b/MagickCore/magick-config.h @@ -12,7 +12,9 @@ /* #undef AUTOTRACE_DELEGATE */ /* Define if coders and filters are to be built as modules. */ -/* #undef BUILD_MODULES */ +#ifndef MAGICKCORE_BUILD_MODULES +#define MAGICKCORE_BUILD_MODULES 1 +#endif /* Define if you have the bzip2 library */ #ifndef MAGICKCORE_BZLIB_DELEGATE @@ -75,7 +77,9 @@ #endif /* Define if you have FFTW library */ -/* #undef FFTW_DELEGATE */ +#ifndef MAGICKCORE_FFTW_DELEGATE +#define MAGICKCORE_FFTW_DELEGATE 1 +#endif /* Location of filter modules */ #ifndef MAGICKCORE_FILTER_PATH @@ -217,7 +221,9 @@ #endif /* Define to 1 if you have the header file. */ -/* #undef HAVE_CL_CL_H */ +#ifndef MAGICKCORE_HAVE_CL_CL_H +#define MAGICKCORE_HAVE_CL_CL_H 1 +#endif /* Define to 1 if you have the header file. */ #ifndef MAGICKCORE_HAVE_COMPLEX_H @@ -1166,7 +1172,9 @@ #endif /* Define if you have JBIG library */ -/* #undef JBIG_DELEGATE */ +#ifndef MAGICKCORE_JBIG_DELEGATE +#define MAGICKCORE_JBIG_DELEGATE 1 +#endif /* Define if you have JPEG version 2 "Jasper" library */ #ifndef MAGICKCORE_JP2_DELEGATE @@ -1198,14 +1206,16 @@ /* #undef LQR_DELEGATE */ /* Define if using libltdl to support dynamically loadable modules */ -/* #undef LTDL_DELEGATE */ +#ifndef MAGICKCORE_LTDL_DELEGATE +#define MAGICKCORE_LTDL_DELEGATE 1 +#endif /* Define if the OS needs help to load dependent libraries for dlopen(). */ /* #undef LTDL_DLOPEN_DEPLIBS */ /* Define to the system default library search path. */ #ifndef MAGICKCORE_LT_DLSEARCH_PATH -#define MAGICKCORE_LT_DLSEARCH_PATH "/lib64:/usr/lib64:/lib:/usr/lib:/usr/lib64/atlas:/usr/lib/llvm:/usr/lib64/llvm:/usr/lib64/mysql:/usr/lib64/qt-3.3/lib:/usr/lib64/tcl8.5/tclx8.4:/usr/lib64/tcl8.5:/usr/lib64/tracker-0.12:/usr/lib/wine/:/usr/lib64/wine/:/usr/lib64/xulrunner-2" +#define MAGICKCORE_LT_DLSEARCH_PATH "/lib64:/usr/lib64:/lib:/usr/lib:/usr/lib64/R/lib:/usr/lib64/alliance/lib:/usr/lib64/atlas:/opt/modules/pkg/intel/f77/10.0.025/lib:/usr/lib64/kicad:/usr/lib/llvm:/usr/lib64/llvm:/usr/local/lib:/usr/lib64/mpich2/lib/:/usr/lib64/mysql:/usr/lib64/nvidia:/usr/lib64/octave/3.4.2:/usr/lib64/openmotif:/usr/lib64/qt-3.3/lib:/usr/lib64/tcl8.5/tclx8.4:/usr/lib/wine/:/usr/lib64/wine/:/usr/lib64/xulrunner-2" #endif /* The archive extension */ @@ -1256,7 +1266,9 @@ /* #undef NO_MINUS_C_MINUS_O */ /* Define if you have OPENEXR library */ -/* #undef OPENEXR_DELEGATE */ +#ifndef MAGICKCORE_OPENEXR_DELEGATE +#define MAGICKCORE_OPENEXR_DELEGATE 1 +#endif /* Name of package */ #ifndef MAGICKCORE_PACKAGE @@ -1316,7 +1328,9 @@ #endif /* Define if you have RSVG library */ -/* #undef RSVG_DELEGATE */ +#ifndef MAGICKCORE_RSVG_DELEGATE +#define MAGICKCORE_RSVG_DELEGATE 1 +#endif /* Define to the type of arg 1 for `select'. */ #ifndef MAGICKCORE_SELECT_TYPE_ARG1 @@ -1472,7 +1486,9 @@ /* #undef WITH_DMALLOC */ /* Define if you have WMF library */ -/* #undef WMF_DELEGATE */ +#ifndef MAGICKCORE_WMF_DELEGATE +#define MAGICKCORE_WMF_DELEGATE 1 +#endif /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ @@ -1528,7 +1544,9 @@ /* #undef _MINIX */ /* Define this for the OpenCL Accelerator */ -/* #undef _OPENCL */ +#ifndef MAGICKCORE__OPENCL +#define MAGICKCORE__OPENCL 1 +#endif /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ diff --git a/MagickCore/version.h b/MagickCore/version.h index bacc20e4f..c628fa09a 100644 --- a/MagickCore/version.h +++ b/MagickCore/version.h @@ -27,7 +27,7 @@ extern "C" { */ #define MagickPackageName "ImageMagick" #define MagickCopyright "Copyright (C) 1999-2011 ImageMagick Studio LLC" -#define MagickSVNRevision "5659" +#define MagickSVNRevision "exported" #define MagickLibVersion 0x700 #define MagickLibVersionText "7.0.0" #define MagickLibVersionNumber 7,0,0 diff --git a/MagickWand/compare.c b/MagickWand/compare.c index e285cbc53..a18f55278 100644 --- a/MagickWand/compare.c +++ b/MagickWand/compare.c @@ -943,7 +943,7 @@ WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info, reconstruct_image=GetImageFromList(image,1); if (subimage_search != MagickFalse) { - similarity_image=SimilarityImage(image,reconstruct_image,&offset, + similarity_image=SimilarityImage(image,reconstruct_image,metric,&offset, &similarity_metric,exception); if (similarity_metric > dissimilarity_threshold) ThrowCompareException(ImageError,"ImagesTooDissimilar",image->filename); diff --git a/MagickWand/magick-image.c b/MagickWand/magick-image.c index 2f0dbf78f..78364c6d7 100644 --- a/MagickWand/magick-image.c +++ b/MagickWand/magick-image.c @@ -10474,7 +10474,8 @@ WandExport MagickBooleanType MagickSigmoidalContrastImage( % The format of the MagickSimilarityImage method is: % % MagickWand *MagickSimilarityImage(MagickWand *wand, -% const MagickWand *reference,RectangeInfo *offset,double *similarity) +% const MagickWand *reference,const MetricType metric, +% RectangeInfo *offset,double *similarity) % % A description of each parameter follows: % @@ -10482,13 +10483,16 @@ WandExport MagickBooleanType MagickSigmoidalContrastImage( % % o reference: the reference wand. % +% o metric: the metric. +% % o offset: the best match offset of the reference image within the image. % % o similarity: the computed similarity between the images. % */ WandExport MagickWand *MagickSimilarityImage(MagickWand *wand, - const MagickWand *reference,RectangleInfo *offset,double *similarity) + const MagickWand *reference,const MetricType metric,RectangleInfo *offset, + double *similarity) { Image *similarity_image; @@ -10503,7 +10507,7 @@ WandExport MagickWand *MagickSimilarityImage(MagickWand *wand, "ContainsNoImages","`%s'",wand->name); return((MagickWand *) NULL); } - similarity_image=SimilarityImage(wand->images,reference->images,offset, + similarity_image=SimilarityImage(wand->images,reference->images,metric,offset, similarity,wand->exception); if (similarity_image == (Image *) NULL) return((MagickWand *) NULL); diff --git a/MagickWand/magick-image.h b/MagickWand/magick-image.h index 60a42f8af..3a4b5eff2 100644 --- a/MagickWand/magick-image.h +++ b/MagickWand/magick-image.h @@ -338,8 +338,8 @@ extern WandExport MagickWand const char *,const MontageMode,const char *), *MagickOptimizeImageLayers(MagickWand *), *MagickPreviewImages(MagickWand *wand,const PreviewType), - *MagickSimilarityImage(MagickWand *,const MagickWand *,RectangleInfo *, - double *), + *MagickSimilarityImage(MagickWand *,const MagickWand *,const MetricType, + RectangleInfo *,double *), *MagickSmushImages(MagickWand *,const MagickBooleanType,const ssize_t), *MagickSteganoImage(MagickWand *,const MagickWand *,const ssize_t), *MagickStereoImage(MagickWand *,const MagickWand *),