From: cristy Date: Sun, 11 Nov 2012 21:44:36 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~4730 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8cdfb34521517f1062d21941afcb28ca7b61b97c;p=imagemagick --- diff --git a/MagickCore/statistic.c b/MagickCore/statistic.c index a5c37571e..6ff118d24 100644 --- a/MagickCore/statistic.c +++ b/MagickCore/statistic.c @@ -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: % diff --git a/MagickWand/convert.c b/MagickWand/convert.c index 3fd12e118..47fa26719 100644 --- a/MagickWand/convert.c +++ b/MagickWand/convert.c @@ -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 == '+') diff --git a/MagickWand/mogrify.c b/MagickWand/mogrify.c index 78e429d30..aa9262efd 100644 --- a/MagickWand/mogrify.c +++ b/MagickWand/mogrify.c @@ -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 == '+') diff --git a/MagickWand/operation.c b/MagickWand/operation.c index 7a77d96e1..3540d7b54 100644 --- a/MagickWand/operation.c +++ b/MagickWand/operation.c @@ -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); diff --git a/PerlMagick/Magick.xs b/PerlMagick/Magick.xs index 9df389afe..17f5bcfdf 100644 --- a/PerlMagick/Magick.xs +++ b/PerlMagick/Magick.xs @@ -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); diff --git a/utilities/convert.1.in b/utilities/convert.1.in index d997b5012..78376ef00 100644 --- a/utilities/convert.1.in +++ b/utilities/convert.1.in @@ -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 diff --git a/utilities/mogrify.1.in b/utilities/mogrify.1.in index ec0b9ac84..e64cd937f 100644 --- a/utilities/mogrify.1.in +++ b/utilities/mogrify.1.in @@ -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