From 1245368fb967c01cafdd5b0e576272501a50cdcd Mon Sep 17 00:00:00 2001 From: cristy Date: Fri, 18 Mar 2011 18:45:04 +0000 Subject: [PATCH] --- ChangeLog | 2 ++ PerlMagick/Magick.xs | 20 +++++++++++++++++ magick/effect.h | 1 + magick/option.c | 1 + wand/magick-image.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ wand/magick-image.h | 3 +++ 6 files changed, 79 insertions(+) diff --git a/ChangeLog b/ChangeLog index 31522be08..ea277b72f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2011-03-14 6.6.8-6 Cristy * Fixed memory leak for PDF and Bitmap PSD RLE support (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=18317). + * Support the -statistic option: replace each pixel with corresponding + statistic from the neighborhood. 2011-03-17 6.6.8-5 Anthony Thyssen * Replaced Minus and Divide Composition methods with Dst and Src diff --git a/PerlMagick/Magick.xs b/PerlMagick/Magick.xs index 4b8e461c6..56124ef59 100644 --- a/PerlMagick/Magick.xs +++ b/PerlMagick/Magick.xs @@ -533,6 +533,8 @@ static struct { "ColorMatrix", { {"matrix", ArrayReference} } }, { "Color", { {"color", StringReference} } }, { "Mode", { {"radius", RealReference} } } + { "Statistic", { {"radius", RealReference}, + {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } } }; static SplayTreeInfo @@ -7281,6 +7283,8 @@ Mogrify(ref,...) ColorImage = 270 Mode = 271 ModeImage = 272 + Statistic = 273 + StatisticImage = 274 MogrifyRegion = 666 PPCODE: { @@ -10621,6 +10625,22 @@ Mogrify(ref,...) image=ModeImage(image,argument_list[0].real_reference,exception); break; } + case 137: /* Statistic */ + { + StatisticType + statistic; + + statistic=UndefinedStatistic; + if (attribute_flag[0] == 0) + argument_list[0].real_reference=0.0; + if (attribute_flag[1] != 0) + channel=(ChannelType) argument_list[1].integer_reference; + if (attribute_flag[2] != 0) + statistic=(StatisticType) argument_list[2].integer_reference; + image=StatisicImageChannel(image,channel,statistic, + argument_list[0].real_reference,exception); + break; + } } if (next != (Image *) NULL) (void) CatchImageException(next); diff --git a/magick/effect.h b/magick/effect.h index 9643d588e..c2c15a474 100644 --- a/magick/effect.h +++ b/magick/effect.h @@ -62,6 +62,7 @@ typedef enum { UndefinedStatistic, MaximumStatistic, + MeanStatistic, MedianStatistic, MinimumStatistic, ModeStatistic, diff --git a/magick/option.c b/magick/option.c index cd96dff26..d256930bb 100644 --- a/magick/option.c +++ b/magick/option.c @@ -1448,6 +1448,7 @@ static const OptionInfo { { "Undefined", (ssize_t) UndefinedStatistic, MagickTrue }, { "Maximum", (ssize_t) MaximumStatistic, MagickFalse }, + { "Mean", (ssize_t) MeanStatistic, MagickFalse }, { "Median", (ssize_t) MedianStatistic, MagickFalse }, { "Minimum", (ssize_t) MinimumStatistic, MagickFalse }, { "Mode", (ssize_t) ModeStatistic, MagickFalse }, diff --git a/wand/magick-image.c b/wand/magick-image.c index 554ec167e..c5ed43981 100644 --- a/wand/magick-image.c +++ b/wand/magick-image.c @@ -11820,6 +11820,58 @@ WandExport MagickBooleanType MagickSpreadImage(MagickWand *wand, % % % % % % +% M a g i c k S t a t i s t i c I m a g e % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% MagickStatisticImage() replace each pixel with corresponding statistic from +% the neighborhood of the specified radius. +% +% The format of the MagickStatisticImage method is: +% +% MagickBooleanType MagickStatisticImage(MagickWand *wand, +% const StatisticType type,const double radius) +% MagickBooleanType MagickStatisticImageChannel(MagickWand *wand, +% const ChannelType channel,const StatisticType type,const double radius) +% +% A description of each parameter follows: +% +% o wand: the magick wand. +% +% o channel: the image channel(s). +% +% o type: the statistic type (e.g. median, mode, etc.). +% +% o radius: the radius of the pixel neighborhood. +% +*/ +WandExport MagickBooleanType MagickStatisticImage(MagickWand *wand, + const ChannelType channel,const StatisticType type,const double radius) +{ + Image + *statistic_image; + + assert(wand != (MagickWand *) NULL); + assert(wand->signature == WandSignature); + if (wand->debug != MagickFalse) + (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); + if (wand->images == (Image *) NULL) + ThrowWandException(WandError,"ContainsNoImages",wand->name); + statistic_image=StatisticImageChannel(wand->images,channel,type,radius, + wand->exception); + if (statistic_image == (Image *) NULL) + return(MagickFalse); + ReplaceImageInList(&wand->images,statistic_image); + return(MagickTrue); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % M a g i c k S t e g a n o I m a g e % % % % % diff --git a/wand/magick-image.h b/wand/magick-image.h index e18be3048..25eb0833a 100644 --- a/wand/magick-image.h +++ b/wand/magick-image.h @@ -338,6 +338,9 @@ extern WandExport MagickBooleanType MagickSpliceImage(MagickWand *,const size_t,const size_t,const ssize_t, const ssize_t), MagickSpreadImage(MagickWand *,const double), + MagickStatisticImage(MagickWand *,const ChannelType,const StatisticType, + const double), + MagickStatisticImageChannel(MagickWand *,const StatisticType,const double), MagickStripImage(MagickWand *), MagickSwirlImage(MagickWand *,const double), MagickTintImage(MagickWand *,const PixelWand *,const PixelWand *), -- 2.40.0