]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Fri, 18 Mar 2011 18:45:04 +0000 (18:45 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Fri, 18 Mar 2011 18:45:04 +0000 (18:45 +0000)
ChangeLog
PerlMagick/Magick.xs
magick/effect.h
magick/option.c
wand/magick-image.c
wand/magick-image.h

index 31522be080e9092f730c8a8d9a74e87c73d064b2..ea277b72f0fe17c5ce75316f6e6604b5a26117b2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
 2011-03-14  6.6.8-6 Cristy  <quetzlzacatenango@image...>
   * 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 <A.Thyssen@griffith...>
   * Replaced Minus and Divide Composition methods with Dst and Src
index 4b8e461c6f424bb1dca4b6e249c9aebe52122b9c..56124ef59642f3677dae21e9ceabf9e088a115e3 100644 (file)
@@ -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);
index 9643d588e3314adffafaa4ad3e7e20007ed9f025..c2c15a474d74149a3fa283b0d4c75e61b1a3dfcc 100644 (file)
@@ -62,6 +62,7 @@ typedef enum
 {
   UndefinedStatistic,
   MaximumStatistic,
+  MeanStatistic,
   MedianStatistic,
   MinimumStatistic,
   ModeStatistic,
index cd96dff2649f58d3d697ae8ab8c0200e7336b28c..d256930bbd1225ac2f2a0170e011348de4549290 100644 (file)
@@ -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 },
index 554ec167e3a9b0bab3ab476f8344cd482557a1bf..c5ed43981b20c37d7515062fbe6feb0058c74661 100644 (file)
@@ -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);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   M a g i c k S t e g a n o I m a g e                                       %
 %                                                                             %
 %                                                                             %
index e18be30482e761f8d5291b0d4f397df2572f09de..25eb0833acc44151bcf15af0f448675baf281aed 100644 (file)
@@ -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 *),