From: dirk Date: Tue, 3 Nov 2015 21:36:30 +0000 (+0100) Subject: Added local contrast to Magick++ and Wand. X-Git-Tag: 7.0.1-0~515 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=be80460638d2432ed6f7bdc93be1b342e30f6e9c;p=imagemagick Added local contrast to Magick++ and Wand. --- diff --git a/Magick++/lib/Image.cpp b/Magick++/lib/Image.cpp index fe6d47e01..4fe7775d5 100644 --- a/Magick++/lib/Image.cpp +++ b/Magick++/lib/Image.cpp @@ -3503,6 +3503,17 @@ void Magick::Image::liquidRescale(const Geometry &geometry_) ThrowImageException; } +void Magick::Image::localContrast(const double radius_,const double strength_) +{ + MagickCore::Image + *newImage; + + GetPPException; + newImage=LocalContrastImage(constImage(),radius_,strength_,exceptionInfo); + replaceImage(newImage); + ThrowImageException; +} + void Magick::Image::magnify(void) { MagickCore::Image diff --git a/Magick++/lib/Magick++/Image.h b/Magick++/lib/Magick++/Image.h index 27dfc5163..f3a41acfc 100644 --- a/Magick++/lib/Magick++/Image.h +++ b/Magick++/lib/Magick++/Image.h @@ -1065,6 +1065,9 @@ namespace Magick // Rescales image with seam carving. void liquidRescale(const Geometry &geometry_); + // Local contrast enhancement + void localContrast(const double radius_,const double strength_); + // Magnify image by integral size void magnify(void); diff --git a/Magick++/lib/Magick++/Include.h b/Magick++/lib/Magick++/Include.h index 4ce305114..8ca3e864f 100644 --- a/Magick++/lib/Magick++/Include.h +++ b/Magick++/lib/Magick++/Include.h @@ -1349,6 +1349,7 @@ namespace Magick using MagickCore::LevelizeImage; using MagickCore::LinearStretchImage; using MagickCore::LiquidRescaleImage; + using MagickCore::LocalContrastImage; using MagickCore::LocaleCompare; using MagickCore::LockSemaphoreInfo; using MagickCore::LogMagickEvent; diff --git a/MagickCore/accelerate.c b/MagickCore/accelerate.c index 239618dab..cc7a5f633 100644 --- a/MagickCore/accelerate.c +++ b/MagickCore/accelerate.c @@ -1614,10 +1614,8 @@ MagickExport Image* AccelerateBlurImage(const Image *image, % % o image: the image. % -% o channel: the channel type. -% -% o radius: the radius of the Gaussian blur, in percentage with 100% -% resulting in a blur radius of 20% of largest dimension. +% o radius: the radius of the Gaussian, in pixels, not counting +% the center pixel. % % o strength: the strength of the blur mask in percentage. % diff --git a/MagickCore/effect.c b/MagickCore/effect.c index 7c6caf192..5d1e1600b 100644 --- a/MagickCore/effect.c +++ b/MagickCore/effect.c @@ -1645,7 +1645,7 @@ MagickExport Image *KuwaharaImage(const Image *image,const double radius, %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % LocalContrastImage() attempts to increase the appearance of large-scale -% light-dark transitions. Local contrast enhancement works similarly to +% light-dark transitions. Local contrast enhancement works similarly to % sharpening with an unsharp mask, however the mask is instead created using % an image with a greater blur distance. % @@ -1658,8 +1658,6 @@ MagickExport Image *KuwaharaImage(const Image *image,const double radius, % % o image: the image. % -% o channel: the channel type. -% % o radius: the radius of the Gaussian, in pixels, not counting % the center pixel. % diff --git a/MagickWand/magick-image.c b/MagickWand/magick-image.c index 138604700..9e59a3707 100644 --- a/MagickWand/magick-image.c +++ b/MagickWand/magick-image.c @@ -6525,6 +6525,55 @@ WandExport MagickBooleanType MagickLiquidRescaleImage(MagickWand *wand, ReplaceImageInList(&wand->images,rescale_image); return(MagickTrue); } + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % +% M a g i c k L o c a l C o n t r a s t I m a g e % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% MagickLocalContrastImage() attempts to increase the appearance of +% large-scale light-dark transitions. Local contrast enhancement works +% similarly to sharpening with an unsharp mask, however the mask is instead +% created using an image with a greater blur distance. +% +% MagickBooleanType MagickLocalContrastImage(MagickWand *wand, +% const double radius,const double strength) +% +% A description of each parameter follows: +% +% o image: the image. +% +% o radius: the radius of the Gaussian, in pixels, not counting +% the center pixel. +% +% o strength: the strength of the blur mask in percentage. +% +*/ +WandExport MagickBooleanType MagickLocalContrastImage(MagickWand *wand, + const double radius, const double strength) +{ + Image + *contrast_image; + + assert(wand != (MagickWand *)NULL); + assert(wand->signature == MagickWandSignature); + if (wand->debug != MagickFalse) + (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s", wand->name); + if (wand->images == (Image *)NULL) + ThrowWandException(WandError,"ContainsNoImages",wand->name); + contrast_image=LocalContrastImage(wand->images,radius,strength, + wand->exception); + if (contrast_image == (Image *)NULL) + return(MagickFalse); + ReplaceImageInList(&wand->images,contrast_image); + return(MagickTrue); +} /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/MagickWand/magick-image.h b/MagickWand/magick-image.h index 6b59258c4..d50cf3d27 100644 --- a/MagickWand/magick-image.h +++ b/MagickWand/magick-image.h @@ -188,6 +188,7 @@ extern WandExport MagickBooleanType MagickLinearStretchImage(MagickWand *,const double,const double), MagickLiquidRescaleImage(MagickWand *,const size_t,const size_t,const double, const double), + MagickLocalContrastImage(MagickWand *,const double,const double), MagickMagnifyImage(MagickWand *), MagickMedianConvolveImage(MagickWand *,const double), MagickMinifyImage(MagickWand *),