Commit 9fabbd46d for imagemagick.org
commit 9fabbd46d75ba3169a402992c186e57a3124b472
Author: Cristy <urban-warrior@imagemagick.org>
Date: Fri Jul 24 19:04:44 2026 -0400
normalize PDC metric
diff --git a/MagickWand/compare.c b/MagickWand/compare.c
index f3404eb33..b66b06cf2 100644
--- a/MagickWand/compare.c
+++ b/MagickWand/compare.c
@@ -246,6 +246,7 @@ WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info,
double
dissimilarity_threshold = DefaultDissimilarityThreshold,
distortion = 0.0,
+ normal_scale = 1.0,
scale = (double) QuantumRange,
similarity_metric = 0.0,
similarity_threshold = DefaultSimilarityThreshold;
@@ -1309,6 +1310,7 @@ WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info,
case PixelDifferenceCountErrorMetric:
{
scale=1.0;
+ normal_scale=1.0/(double) image->columns/(double) image->rows;
break;
}
default:
@@ -1344,7 +1346,7 @@ WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info,
default:
{
(void) FormatLocaleFile(stderr,"%.*g (%.*g)",GetMagickPrecision(),
- scale*distortion,GetMagickPrecision(),distortion);
+ scale*distortion,GetMagickPrecision(),normal_scale*distortion);
break;
}
}
@@ -1383,21 +1385,20 @@ WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info,
(void) FormatLocaleFile(stderr," red: %.*g (%.*g)\n",
GetMagickPrecision(),scale*
channel_distortion[RedPixelChannel],GetMagickPrecision(),
- channel_distortion[RedPixelChannel]);
+ normal_scale*channel_distortion[RedPixelChannel]);
(void) FormatLocaleFile(stderr," green: %.*g (%.*g)\n",
GetMagickPrecision(),scale*
channel_distortion[GreenPixelChannel],GetMagickPrecision(),
- channel_distortion[GreenPixelChannel]);
+ normal_scale*channel_distortion[GreenPixelChannel]);
(void) FormatLocaleFile(stderr," blue: %.*g (%.*g)\n",
GetMagickPrecision(),scale*
channel_distortion[BluePixelChannel],GetMagickPrecision(),
- channel_distortion[BluePixelChannel]);
+ normal_scale*channel_distortion[BluePixelChannel]);
if (image->alpha_trait != UndefinedPixelTrait)
(void) FormatLocaleFile(stderr," alpha: %.*g (%.*g)\n",
GetMagickPrecision(),scale*
- channel_distortion[AlphaPixelChannel],
- GetMagickPrecision(),
- channel_distortion[AlphaPixelChannel]);
+ channel_distortion[AlphaPixelChannel],GetMagickPrecision(),
+ normal_scale*channel_distortion[AlphaPixelChannel]);
break;
}
case CMYKColorspace:
@@ -1405,26 +1406,26 @@ WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info,
(void) FormatLocaleFile(stderr," cyan: %.*g (%.*g)\n",
GetMagickPrecision(),scale*
channel_distortion[CyanPixelChannel],GetMagickPrecision(),
- channel_distortion[CyanPixelChannel]);
+ normal_scale*channel_distortion[CyanPixelChannel]);
(void) FormatLocaleFile(stderr," magenta: %.*g (%.*g)\n",
GetMagickPrecision(),scale*
channel_distortion[MagentaPixelChannel],
GetMagickPrecision(),
- channel_distortion[MagentaPixelChannel]);
+ normal_scale*channel_distortion[MagentaPixelChannel]);
(void) FormatLocaleFile(stderr," yellow: %.*g (%.*g)\n",
GetMagickPrecision(),scale*
channel_distortion[YellowPixelChannel],GetMagickPrecision(),
- channel_distortion[YellowPixelChannel]);
+ normal_scale*channel_distortion[YellowPixelChannel]);
(void) FormatLocaleFile(stderr," black: %.*g (%.*g)\n",
GetMagickPrecision(),scale*
channel_distortion[BlackPixelChannel],GetMagickPrecision(),
- channel_distortion[BlackPixelChannel]);
+ normal_scale*channel_distortion[BlackPixelChannel]);
if (image->alpha_trait != UndefinedPixelTrait)
(void) FormatLocaleFile(stderr," alpha: %.*g (%.*g)\n",
GetMagickPrecision(),scale*
channel_distortion[AlphaPixelChannel],
GetMagickPrecision(),
- channel_distortion[AlphaPixelChannel]);
+ normal_scale*channel_distortion[AlphaPixelChannel]);
break;
}
case LinearGRAYColorspace:
@@ -1433,19 +1434,19 @@ WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info,
(void) FormatLocaleFile(stderr," gray: %.*g (%.*g)\n",
GetMagickPrecision(),scale*
channel_distortion[GrayPixelChannel],GetMagickPrecision(),
- channel_distortion[GrayPixelChannel]);
+ normal_scale*channel_distortion[GrayPixelChannel]);
if (image->alpha_trait != UndefinedPixelTrait)
(void) FormatLocaleFile(stderr," alpha: %.*g (%.*g)\n",
GetMagickPrecision(),scale*
channel_distortion[AlphaPixelChannel],
GetMagickPrecision(),
- channel_distortion[AlphaPixelChannel]);
+ normal_scale*channel_distortion[AlphaPixelChannel]);
break;
}
}
(void) FormatLocaleFile(stderr," all: %.*g (%.*g)\n",
GetMagickPrecision(),scale*channel_distortion[MaxPixelChannels],
- GetMagickPrecision(),channel_distortion[MaxPixelChannels]);
+ GetMagickPrecision(),normal_scale*channel_distortion[MaxPixelChannels]);
break;
}
case DotProductCorrelationErrorMetric: