]> granicus.if.org Git - imagemagick/blobdiff - MagickWand/operation.c
(no commit message)
[imagemagick] / MagickWand / operation.c
index 90518de655a3d0bce80b2eb1a00beef89a9ef208..a88f83f49f7bd9485e6621755506ceef617f5f6b 100644 (file)
 #include "MagickWand/studio.h"
 #include "MagickWand/MagickWand.h"
 #include "MagickWand/magick-wand-private.h"
+#include "MagickWand/mogrify.h"
 #include "MagickWand/wand.h"
 #include "MagickWand/wandcli.h"
 #include "MagickWand/wandcli-private.h"
-#include "MagickWand/operation.h"
+#include "MagickCore/image-private.h"
 #include "MagickCore/monitor-private.h"
+#include "MagickWand/operation.h"
 #include "MagickCore/thread-private.h"
 #include "MagickCore/string-private.h"
 #include "MagickCore/pixel-private.h"
 \f
+/*
+  Constant declaration.
+*/
+static const char
+  MogrifyBackgroundColor[] = "#fff",  /* white */
+  MogrifyBorderColor[] = "#dfdfdf",  /* sRGB gray */
+  MogrifyMatteColor[] = "#bdbdbd";  /* slightly darker gray */
+\f
 /*
   Define declarations.
 */
 /* FUTURE: why is this default so specific? */
 #define DEFAULT_DISSIMILARITY_THRESHOLD "0.31830988618379067154"
 
-/*
-  Constant declaration. (temporary exports)
-*/
-static const char
-  BackgroundColor[] = "#fff",  /* white */
-  BorderColor[] = "#dfdfdf",  /* sRGB gray */
-  MatteColor[] = "#bdbdbd";  /* slightly darker gray */
-
 /* For Debugging Geometry Input */
 #define ReportGeometry(flags,info) \
   (void) FormatLocaleFile(stderr, "Geometry = 0x%04X : %lg x %lg %+lg %+lg\n", \
@@ -149,7 +151,8 @@ static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
   if (image != (Image *) NULL)
     return(image);
   read_info=CloneImageInfo(image_info);
-  (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
+  if (path != (const char *) NULL)
+    (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
   image=ReadImage(read_info,exception);
   read_info=DestroyImageInfo(read_info);
   if (image != (Image *) NULL)
@@ -513,7 +516,7 @@ WandPrivate void CLISettingOptionInfo(MagickCLI *cli_wand,
              Better error handling of QueryColorCompliance() needed.
           */
           (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
-          (void) QueryColorCompliance(ArgOption(BackgroundColor),AllCompliance,
+          (void) QueryColorCompliance(ArgOption(MogrifyBackgroundColor),AllCompliance,
              &_image_info->background_color,_exception);
           break;
         }
@@ -566,9 +569,9 @@ WandPrivate void CLISettingOptionInfo(MagickCLI *cli_wand,
               break;
             }
           (void) DeleteImageOption(_image_info,option+1);
-          (void) QueryColorCompliance(BorderColor,AllCompliance,
+          (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
             &_image_info->border_color,_exception);
-          (void) QueryColorCompliance(BorderColor,AllCompliance,
+          (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance,
             &_draw_info->border_color,_exception);
           break;
         }
@@ -1097,7 +1100,7 @@ WandPrivate void CLISettingOptionInfo(MagickCLI *cli_wand,
         {
           /* SyncImageSettings() used to set per-image attribute. */
           (void) SetImageOption(_image_info,option+1,ArgOption(NULL));
-          (void) QueryColorCompliance(ArgOption(MatteColor),AllCompliance,
+          (void) QueryColorCompliance(ArgOption(MogrifyMatteColor),AllCompliance,
              &_image_info->matte_color,_exception);
           break;
         }
@@ -1911,6 +1914,26 @@ static MagickBooleanType CLISimpleOperatorImage(MagickCLI *cli_wand,
     }
     case 'c':
     {
+      if (LocaleCompare("canny",option+1) == 0)
+        {
+          flags=ParseGeometry(arg1,&geometry_info);
+          if ((flags & (RhoValue|SigmaValue)) == 0)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
+          if ((flags & SigmaValue) == 0)
+            geometry_info.sigma=1.0;
+          if ((flags & XiValue) == 0)
+            geometry_info.xi=10;
+          if ((flags & PsiValue) == 0)
+            geometry_info.psi=30;
+          if ((flags & PercentValue) != 0)
+            {
+              geometry_info.xi/=100.0;
+              geometry_info.psi/=100.0;
+            }
+          new_image=CannyEdgeImage(_image,geometry_info.rho,geometry_info.sigma,
+            geometry_info.xi,geometry_info.psi,_exception);
+          break;
+        }
       if (LocaleCompare("cdl",option+1) == 0)
         {
           /* Note: arguments do not have percent escapes expanded */
@@ -2465,6 +2488,23 @@ static MagickBooleanType CLISimpleOperatorImage(MagickCLI *cli_wand,
         }
       CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
     }
+    case 'h':
+    {
+      if (LocaleCompare("hough-lines",option+1) == 0)
+        {
+          flags=ParseGeometry(arg1,&geometry_info);
+          if ((flags & (RhoValue|SigmaValue)) == 0)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
+          if ((flags & SigmaValue) == 0)
+            geometry_info.sigma=geometry_info.rho;
+          if ((flags & XiValue) == 0)
+            geometry_info.xi=40;
+          new_image=HoughLineImage(_image,(size_t) geometry_info.rho,
+            (size_t) geometry_info.sigma,(size_t) geometry_info.xi,_exception);
+          break;
+        }
+      CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
+    }
     case 'i':
     {
       if (LocaleCompare("identify",option+1) == 0)
@@ -2677,7 +2717,22 @@ static MagickBooleanType CLISimpleOperatorImage(MagickCLI *cli_wand,
         {
           CLIWandWarnReplaced(IfNormalOp?"-alpha Set":"-alpha Off");
           (void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel :
-                         DeactivateAlphaChannel, _exception);
+            DeactivateAlphaChannel, _exception);
+          break;
+        }
+      if (LocaleCompare("mean-shift",option+1) == 0)
+        {
+          flags=ParseGeometry(arg1,&geometry_info);
+          if ((flags & (RhoValue|SigmaValue)) == 0)
+            CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
+          if ((flags & SigmaValue) == 0)
+            geometry_info.sigma=1.0;
+          if ((flags & XiValue) == 0)
+            geometry_info.xi=0.10*QuantumRange;
+          if ((flags & PercentValue) != 0)
+            geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
+          new_image=MeanShiftImage(_image,(size_t) geometry_info.rho,
+            (size_t) geometry_info.sigma,geometry_info.xi,_exception);
           break;
         }
       if (LocaleCompare("median",option+1) == 0)
@@ -2948,12 +3003,12 @@ static MagickBooleanType CLISimpleOperatorImage(MagickCLI *cli_wand,
     }
     case 'r':
     {
-      if (LocaleCompare("radial-blur",option+1) == 0)
+      if (LocaleCompare("rotational-blur",option+1) == 0)
         {
           flags=ParseGeometry(arg1,&geometry_info);
           if ((flags & RhoValue) == 0)
             CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
-          new_image=RadialBlurImage(_image,geometry_info.rho,_exception);
+          new_image=RotationalBlurImage(_image,geometry_info.rho,_exception);
           break;
         }
       if (LocaleCompare("raise",option+1) == 0)
@@ -4161,6 +4216,7 @@ WandPrivate MagickBooleanType CLIListOperatorImages(MagickCLI *cli_wand,
               /*
                 Support old style syntax, filter="-option arg1".
               */
+              assert(arg1 != (const char *) NULL);
               length=strlen(arg1);
               token=(char *) NULL;
               if (~length >= (MaxTextExtent-1))