]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sun, 11 Nov 2012 21:44:36 +0000 (21:44 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sun, 11 Nov 2012 21:44:36 +0000 (21:44 +0000)
MagickCore/statistic.c
MagickWand/convert.c
MagickWand/mogrify.c
MagickWand/operation.c
PerlMagick/Magick.xs
utilities/convert.1.in
utilities/mogrify.1.in

index a5c37571e92a741cf6845639dc7a46871e6194ad..6ff118d24ea91e324cdbbcd47aa04de6677a7722 100644 (file)
@@ -1760,7 +1760,7 @@ MagickExport ChannelStatistics *GetImageStatistics(const Image *image,
 %
 %  PolynomialImage() returns a new image where each pixel is the sum of the
 %  pixels in the image sequence after applying its corresponding terms
-%  (coefficients and degree pairs) and a constant.
+%  (coefficient and degree pairs) and a constant.
 %
 %  The format of the PolynomialImage method is:
 %
index 3fd12e11869a6681729e24c717529cfb0831e90d..47fa2671940d27e7924f41625c38670c84c0da8a 100644 (file)
@@ -327,6 +327,8 @@ static MagickBooleanType ConvertUsage(void)
       "-hald-clut           apply a Hald color lookup table to the image",
       "-morph value         morph an image sequence",
       "-mosaic              create a mosaic from an image sequence",
+      "-poly terms          build a polynomial from the image sequence and the corresponding",
+      "                     terms (coefficients and degree pairs + constant).",
       "-print string        interpret string and print to console",
       "-process arguments   process the image with a custom image filter",
       "-smush geometry      smush an image sequence together",
@@ -660,6 +662,8 @@ WandExport MagickBooleanType ConvertImageCommand(ImageInfo *image_info,
             i++;
             if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
+            if (IsGeometry(argv[i]) == MagickFalse)
+              ThrowConvertInvalidArgumentException(option,argv[i]);
             break;
           }
         if (LocaleCompare("alpha",option+1) == 0)
@@ -2192,6 +2196,17 @@ WandExport MagickBooleanType ConvertImageCommand(ImageInfo *image_info,
               ThrowConvertInvalidArgumentException(option,argv[i]);
             break;
           }
+        if (LocaleCompare("poly",option+1) == 0)
+          {
+            if (*option == '+')
+              break;
+            i++;
+            if (i == (ssize_t) (argc-1))
+              ThrowConvertException(OptionError,"MissingArgument",option);
+            if (IsGeometry(argv[i]) == MagickFalse)
+              ThrowConvertInvalidArgumentException(option,argv[i]);
+            break;
+          }
         if (LocaleCompare("posterize",option+1) == 0)
           {
             if (*option == '+')
index 78e429d30415a0dfcf096a4d72abba7d00096b40..aa9262efdb6e0fe6f0435c2f0d47eea0dfe3bbc3 100644 (file)
@@ -796,8 +796,8 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
               alpha_type;
 
             (void) SyncImageSettings(mogrify_info,*image,exception);
-            alpha_type=(AlphaChannelOption) ParseCommandOption(MagickAlphaChannelOptions,
-              MagickFalse,argv[i+1]);
+            alpha_type=(AlphaChannelOption) ParseCommandOption(
+              MagickAlphaChannelOptions,MagickFalse,argv[i+1]);
             (void) SetImageAlphaChannel(*image,alpha_type,exception);
             break;
           }
@@ -2294,6 +2294,60 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
               interpolate_method,exception);
             break;
           }
+        if (LocaleCompare("poly",option+1) == 0)
+          {
+            char
+              *args,
+              token[MaxTextExtent];
+
+            const char
+              *p;
+
+            double
+              *arguments;
+
+            register ssize_t
+              x;
+
+            size_t
+              number_arguments;
+
+            /*
+              Polynomial image.
+            */
+            (void) SyncImageSettings(mogrify_info,*image,exception);
+            args=InterpretImageProperties(mogrify_info,*image,argv[i+2],
+              exception);
+            if (args == (char *) NULL)
+              break;
+            p=(char *) args;
+            for (x=0; *p != '\0'; x++)
+            {
+              GetMagickToken(p,&p,token);
+              if (*token == ',')
+                GetMagickToken(p,&p,token);
+            }
+            number_arguments=(size_t) x;
+            arguments=(double *) AcquireQuantumMemory(number_arguments,
+              sizeof(*arguments));
+            if (arguments == (double *) NULL)
+              ThrowWandFatalException(ResourceLimitFatalError,
+                "MemoryAllocationFailed",(*image)->filename);
+            (void) ResetMagickMemory(arguments,0,number_arguments*
+              sizeof(*arguments));
+            p=(char *) args;
+            for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
+            {
+              GetMagickToken(p,&p,token);
+              if (*token == ',')
+                GetMagickToken(p,&p,token);
+              arguments[x]=StringToDouble(token,(char **) NULL);
+            }
+            args=DestroyString(args);
+            mogrify_image=PolynomialImage(*image,number_arguments >> 1,
+              arguments,exception);
+            arguments=(double *) RelinquishMagickMemory(arguments);
+          }
         if (LocaleCompare("posterize",option+1) == 0)
           {
             /*
@@ -3435,6 +3489,8 @@ static MagickBooleanType MogrifyUsage(void)
       "-hald-clut           apply a Hald color lookup table to the image",
       "-morph value         morph an image sequence",
       "-mosaic              create a mosaic from an image sequence",
+      "-poly terms          build a polynomial from the image sequence and the corresponding",
+      "                     terms (coefficients and degree pairs + constant).",
       "-print string        interpret string and print to console",
       "-process arguments   process the image with a custom image filter",
       "-smush geometry      smush an image sequence together",
@@ -5297,6 +5353,17 @@ WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
             break;
           }
+        if (LocaleCompare("poly",option+1) == 0)
+          {
+            if (*option == '+')
+              break;
+            i++;
+            if (i == (ssize_t) argc)
+              ThrowMogrifyException(OptionError,"MissingArgument",option);
+            if (IsGeometry(argv[i]) == MagickFalse)
+              ThrowMogrifyInvalidArgumentException(option,argv[i]);
+            break;
+          }
         if (LocaleCompare("posterize",option+1) == 0)
           {
             if (*option == '+')
index 7a77d96e1f18dc4e67d39bea34db94603be37d1f..3540d7b5494a4a6ca337bd634338196903631aee 100644 (file)
@@ -2875,6 +2875,22 @@ static void CLISimpleOperatorImage(MagickCLI *cli_wand,
             _image->interpolate,_exception);
           break;
         }
+      if (LocaleCompare("poly",option+1) == 0)
+        {
+          double
+            *args;
+
+          ssize_t
+            count;
+
+          /* convert argument string into an array of doubles */
+          args = StringToArrayOfDoubles(arg2,&count,_exception);
+          if (args == (double *)NULL )
+            CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2);
+          new_image=PolynomialImage(_image,count >> 1,args,_exception);
+          args=(double *) RelinquishMagickMemory(args);
+          break;
+        }
       if (LocaleCompare("posterize",option+1) == 0)
         {
           flags=ParseGeometry(arg1,&geometry_info);
index 9df389afe821dc64e115ba2d5302b471d8f256fe..17f5bcfdf6bf271813033bce2b79f9930b4c6161 100644 (file)
@@ -539,6 +539,8 @@ static struct
       {"width", IntegerReference},{"height", IntegerReference},
       {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } },
     { "Perceptible", { {"epsilon", RealReference},
+      {"channel", MagickChannelOptions} } },
+    { "Poly", { {"terms", ArrayReference},
       {"channel", MagickChannelOptions} } }
   };
 
@@ -7357,6 +7359,8 @@ Mogrify(ref,...)
     StatisticImage     = 270
     Perceptible        = 271
     PerceptibleImage   = 272
+    Poly               = 273
+    PolyImage          = 274
     MogrifyRegion      = 666
   PPCODE:
   {
@@ -10929,6 +10933,36 @@ Mogrify(ref,...)
           (void) SetImageChannelMask(image,channel_mask);
           break;
         }
+        case 136:  /* Poly */
+        {
+          AV
+            *av;
+
+          double
+            *terms;
+
+          size_t
+            number_terms;
+
+          if (attribute_flag[0] == 0)
+            break;
+          if (attribute_flag[1] != 0)
+            channel=(ChannelType) argument_list[1].integer_reference;
+          av=(AV *) argument_list[0].array_reference;
+          number_terms=(size_t) av_len(av);
+          terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
+          if (terms == (double *) NULL)
+            {
+              ThrowPerlException(exception,ResourceLimitFatalError,
+                "MemoryAllocationFailed",PackageName);
+              goto PerlException;
+            }
+          for (j=0; j < av_len(av); j++)
+            terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
+          image=PolynomialImage(image,number_terms >> 1,terms,exception);
+          terms=(double *) RelinquishMagickMemory(terms);
+          break;
+        }
       }
       if (next != (Image *) NULL)
         (void) CatchImageException(next);
index d997b5012b03174b9d13fa8b6a64d25652425c3c..78376ef00d17a49be51de1888f89807fb3d6edc0 100644 (file)
@@ -253,7 +253,8 @@ Image Sequence Operators:
   \-fx expression       apply mathematical expression to an image channel(s)
   \-hald-clut           apply a Hald color lookup table to the image
   \-morph value         morph an image sequence
-  \-mosaic              create a mosaic from an image sequence
+  \- osaic              create a mosaic from an image sequence
+  \-poly terms          build a polynomial from the image sequence and the corresponding terms (coefficients and degree pairs + constant)
   \-process arguments   process the image with a custom image filter
   \-separate            separate an image channel into a grayscale image
   \-smush geometry      smush an image sequence together
index ec0b9ac844128295ee4384b6e61843fb0e22e194..e64cd937f2b9bd125faab5cdf439f08a4cdc1e7d 100644 (file)
@@ -255,6 +255,7 @@ Image Sequence Operators:
   \-hald-clut           apply a Hald color lookup table to the image
   \-morph value         morph an image sequence
   \-mosaic              create a mosaic from an image sequence
+  \-poly terms          build a polynomial from the image sequence and the corresponding terms (coefficients and degree pairs + constant)
   \-process arguments   process the image with a custom image filter
   \-separate            separate an image channel into a grayscale image
   \-smush geometry      smush an image sequence together