From: anthony Date: Thu, 6 May 2010 07:05:29 +0000 (+0000) Subject: apply fix for difference compose methods used by difference morphology. X-Git-Tag: 7.0.1-0~9549 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7d10d74e4a2ddb0f1223a2a5d0c88754621c921f;p=imagemagick apply fix for difference compose methods used by difference morphology. --- diff --git a/ChangeLog b/ChangeLog index 2ef6e93ac..4ea63f090 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-05-06 6.6.1-6 Anthony Thyssen + * Made use of new no-'sync' channel enabled mathematical compose methods + for the difference morphology methods. These should now work correctly + for specific channels, and more importantally for alpha shaped morphology. + 2010-05-05 6.6.1-6 Cristy and Glenn Randers-Pehrson * Fixed bugs with losing the opacity channel while writing some PNG images. (bug reported by Anthony T.) diff --git a/magick/morphology.c b/magick/morphology.c index 36f2a7d6c..b5d18725c 100644 --- a/magick/morphology.c +++ b/magick/morphology.c @@ -1752,19 +1752,29 @@ MagickExport Image *MorphologyImageChannel(const Image *image, if ( curr_kernel != kernel ) curr_kernel=DestroyKernelInfo(curr_kernel); - /* Third-level Subtractive methods post-processing */ + /* Third-level Subtractive methods post-processing + ** + ** The removal of any 'Sync' channel flag in the Image Compositon below + ** ensures the compose method is applied in a purely mathematical way, only + ** the selected channels, without any normal 'alpha blending' normally + ** associated with the compose method. + ** + ** Note "method" here is the 'original' morphological method, and not the + ** 'current' morphological method used above to generate "new_image". + */ switch( method ) { case EdgeOutMorphology: case EdgeInMorphology: case TopHatMorphology: case BottomHatMorphology: /* Get Difference relative to the original image */ - (void) CompositeImageChannel(new_image, channel, DifferenceCompositeOp, - image, 0, 0); + (void) CompositeImageChannel(new_image, (channel & ~SyncChannels), + DifferenceCompositeOp, image, 0, 0); break; - case EdgeMorphology: /* subtract the Erode from a Dilate */ - (void) CompositeImageChannel(new_image, channel, DifferenceCompositeOp, - grad_image, 0, 0); + case EdgeMorphology: + /* Difference the Eroded image from the saved Dilated image */ + (void) CompositeImageChannel(new_image, (channel & ~SyncChannels), + DifferenceCompositeOp, grad_image, 0, 0); grad_image=DestroyImage(grad_image); break; default: