From: Cristy Date: Mon, 28 Aug 2017 13:32:03 +0000 (-0400) Subject: ... X-Git-Tag: 7.0.7-0~47 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f8b1e6fac0229ff5a5f9352b874cf1bef643bd81;p=imagemagick ... --- diff --git a/MagickCore/compare.c b/MagickCore/compare.c index 98f1074df..5e558cda1 100644 --- a/MagickCore/compare.c +++ b/MagickCore/compare.c @@ -1349,6 +1349,10 @@ static MagickBooleanType GetStructuralSimilarityDistortion(const Image *image, register ssize_t i; + size_t + columns, + rows; + ssize_t y; @@ -1379,13 +1383,15 @@ static MagickBooleanType GetStructuralSimilarityDistortion(const Image *image, if (artifact != (const char *) NULL) c2=pow(StringToDouble(artifact,(char **) NULL)*SSIML,2.0); status=MagickTrue; + rows=MagickMax(image->rows,reconstruct_image->rows); + columns=MagickMax(image->columns,reconstruct_image->columns); image_view=AcquireVirtualCacheView(image,exception); reconstruct_view=AcquireVirtualCacheView(reconstruct_image,exception); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp parallel for schedule(static,4) shared(status) \ - magick_threads(image,reconstruct_image,image->rows,1) + magick_threads(image,reconstruct_image,rows,1) #endif - for (y=0; y < (ssize_t) image->rows; y++) + for (y=0; y < (ssize_t) rows; y++) { double channel_distortion[MaxPixelChannels+1]; @@ -1401,18 +1407,18 @@ static MagickBooleanType GetStructuralSimilarityDistortion(const Image *image, if (status == MagickFalse) continue; p=GetCacheViewVirtualPixels(image_view,-((ssize_t) kernel_info->width/2L),y- - ((ssize_t) kernel_info->height/2L),image->columns+kernel_info->width, + ((ssize_t) kernel_info->height/2L),columns+kernel_info->width, kernel_info->height,exception); q=GetCacheViewVirtualPixels(reconstruct_view,-((ssize_t) kernel_info->width/ - 2L),y-((ssize_t) kernel_info->height/2L),reconstruct_image->columns+ - kernel_info->width,kernel_info->height,exception); + 2L),y-((ssize_t) kernel_info->height/2L),columns+kernel_info->width, + kernel_info->height,exception); if ((p == (const Quantum *) NULL) || (q == (const Quantum *) NULL)) { status=MagickFalse; continue; } (void) ResetMagickMemory(channel_distortion,0,sizeof(channel_distortion)); - for (x=0; x < (ssize_t) image->columns; x++) + for (x=0; x < (ssize_t) columns; x++) { double x_pixel_mu[MaxPixelChannels+1], @@ -1477,8 +1483,8 @@ static MagickBooleanType GetStructuralSimilarityDistortion(const Image *image, reference+=GetPixelChannels(image); target+=GetPixelChannels(reconstruct_image); } - reference+=GetPixelChannels(image)*image->columns; - target+=GetPixelChannels(reconstruct_image)*reconstruct_image->columns; + reference+=GetPixelChannels(image)*columns; + target+=GetPixelChannels(reconstruct_image)*columns; } for (i=0; i < (ssize_t) GetPixelChannels(image); i++) { @@ -1528,9 +1534,9 @@ static MagickBooleanType GetStructuralSimilarityDistortion(const Image *image, PixelTrait traits = GetPixelChannelTraits(image,channel); if ((traits == UndefinedPixelTrait) || ((traits & UpdatePixelTrait) == 0)) continue; - distortion[i]/=((double) image->columns*image->rows); + distortion[i]/=((double) columns*rows); } - distortion[CompositePixelChannel]/=((double) image->columns*image->rows); + distortion[CompositePixelChannel]/=((double) columns*rows); distortion[CompositePixelChannel]/=(double) GetImageChannels(image); kernel_info=DestroyKernelInfo(kernel_info); return(status);