% 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:
%
%
% 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.
%
*/
-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;
Image
*similarity_image;
+ MagickBooleanType
+ status;
+
RectangleInfo
geometry;
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;
*/
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)
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
}
}
similarity_view=DestroyCacheView(similarity_view);
- reference_statistics=(ChannelStatistics *) RelinquishMagickMemory(
- reference_statistics);
return(similarity_image);
}
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 *,
/* #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
#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
#endif
/* Define to 1 if you have the <CL/cl.h> 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 <complex.h> header file. */
#ifndef MAGICKCORE_HAVE_COMPLEX_H
#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
/* #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 */
/* #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
#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
/* #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). */
/* #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. */
*/
#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
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);
% 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:
%
%
% 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;
"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);
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 *),