From: Cristy Date: Mon, 2 Sep 2019 23:00:03 +0000 (-0400) Subject: https://imagemagick.org/discourse-server/viewtopic.php?f=3&t=36641&p=168446 X-Git-Tag: 7.0.8-64~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d85b62173209f7dae898a2d1cbc9ba9bd8cc57c2;p=imagemagick https://imagemagick.org/discourse-server/viewtopic.php?f=3&t=36641&p=168446 --- diff --git a/MagickCore/morphology.c b/MagickCore/morphology.c index 1fd4ed4b8..2e7822ba8 100644 --- a/MagickCore/morphology.c +++ b/MagickCore/morphology.c @@ -2855,7 +2855,8 @@ static ssize_t MorphologyPrimitive(const Image *image,Image *morphology_image, *magick_restrict k; register const Quantum - *magick_restrict pixels; + *magick_restrict pixels, + *magick_restrict quantum_pixels; register ssize_t u; @@ -2878,6 +2879,7 @@ static ssize_t MorphologyPrimitive(const Image *image,Image *morphology_image, continue; } pixels=p; + quantum_pixels=(const Quantum *) NULL; maximum=0.0; minimum=(double) QuantumRange; switch (method) @@ -3101,6 +3103,7 @@ static ssize_t MorphologyPrimitive(const Image *image,Image *morphology_image, intensity=(double) GetPixelIntensity(image,pixels); if (intensity < minimum) { + quantum_pixels=pixels; pixel=(double) pixels[i]; minimum=intensity; } @@ -3131,6 +3134,7 @@ static ssize_t MorphologyPrimitive(const Image *image,Image *morphology_image, if (intensity > maximum) { pixel=(double) pixels[i]; + quantum_pixels=pixels; maximum=intensity; } count++; @@ -3194,7 +3198,11 @@ static ssize_t MorphologyPrimitive(const Image *image,Image *morphology_image, gamma=PerceptibleReciprocal(gamma); if (count != 0) gamma*=(double) kernel->height*kernel->width/count; - SetPixelChannel(morphology_image,channel,ClampToQuantum(gamma*pixel),q); + if (quantum_pixels != (const Quantum *) NULL) + SetPixelChannel(morphology_image,channel,quantum_pixels[i],q); + else + SetPixelChannel(morphology_image,channel,ClampToQuantum(gamma*pixel), + q); } p+=GetPixelChannels(image); q+=GetPixelChannels(morphology_image);