From 218ff2885c327f291e6f573ef0fa4148692a7bfa Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 8 Feb 2025 19:09:53 -0500 Subject: [PATCH] fix correlation image for PSNR metric --- MagickCore/compare.c | 11 ++++++++++- MagickCore/statistic.c | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/MagickCore/compare.c b/MagickCore/compare.c index 92e7bffdb5..d1efd96d9b 100644 --- a/MagickCore/compare.c +++ b/MagickCore/compare.c @@ -3246,6 +3246,7 @@ static Image *DPCSimilarityImage(const Image *image,const Image *reconstruct, exception); if (status == MagickFalse) ThrowDPCSimilarityException(); + dot_product_image->depth=MAGICKCORE_QUANTUM_DEPTH; status=SIMMaximaImage(dot_product_image,&maxima,offset,exception); if (status == MagickFalse) ThrowDPCSimilarityException(); @@ -3364,6 +3365,7 @@ static Image *MSESimilarityImage(const Image *image,const Image *reconstruct, status=GrayscaleImage(mean_image,AveragePixelIntensityMethod,exception); if (status == MagickFalse) ThrowMSESimilarityException(); + mean_image->depth=MAGICKCORE_QUANTUM_DEPTH; /* Crop to difference of reconstruction and test images. */ @@ -3534,6 +3536,7 @@ static Image *NCCSimilarityImage(const Image *image,const Image *reconstruct, status=GrayscaleImage(ncc_image,AveragePixelIntensityMethod,exception); if (status == MagickFalse) ThrowNCCSimilarityException(); + ncc_image->depth=MAGICKCORE_QUANTUM_DEPTH; status=SIMMaximaImage(ncc_image,&maxima,offset,exception); if (status == MagickFalse) ThrowNCCSimilarityException(); @@ -3673,6 +3676,7 @@ static Image *PhaseSimilarityImage(const Image *image,const Image *reconstruct, status=GrayscaleImage(phase_image,AveragePixelIntensityMethod,exception); if (status == MagickFalse) ThrowPhaseSimilarityException(); + phase_image->depth=MAGICKCORE_QUANTUM_DEPTH; status=SIMMaximaImage(phase_image,&maxima,offset,exception); if (status == MagickFalse) ThrowPhaseSimilarityException(); @@ -3793,6 +3797,11 @@ static Image *PSNRSimilarityImage(const Image *image,const Image *reconstruct, if (status == MagickFalse) ThrowPSNRSimilarityException(); status=GrayscaleImage(mean_image,AveragePixelIntensityMethod,exception); + if (status == MagickFalse) + ThrowPSNRSimilarityException(); + mean_image->depth=MAGICKCORE_QUANTUM_DEPTH; + status=SIMMultiplyImage(mean_image,1.0/48.1647, + (const ChannelStatistics *) NULL,exception); if (status == MagickFalse) ThrowPSNRSimilarityException(); /* @@ -3817,7 +3826,7 @@ static Image *PSNRSimilarityImage(const Image *image,const Image *reconstruct, status=NegateImage(psnr_image,MagickFalse,exception); if (status == MagickFalse) ThrowPSNRSimilarityException(); - *similarity_metric=QuantumScale*minima/48.1647; + *similarity_metric=QuantumScale*minima; DestroyImage(alpha_image); DestroyImage(beta_image); return(psnr_image); diff --git a/MagickCore/statistic.c b/MagickCore/statistic.c index 377c7256a9..5ea4563884 100644 --- a/MagickCore/statistic.c +++ b/MagickCore/statistic.c @@ -1767,7 +1767,7 @@ MagickExport ChannelPerceptualHash *GetImagePerceptualHash(const Image *image, if (perceptual_hash == (ChannelPerceptualHash *) NULL) return((ChannelPerceptualHash *) NULL); artifact=GetImageArtifact(image,"phash:colorspaces"); - if (artifact != NULL) + if (artifact != (const char *) NULL) colorspaces=AcquireString(artifact); else colorspaces=AcquireString("xyY,HSB");