]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/fx.c
(no commit message)
[imagemagick] / MagickCore / fx.c
index 7fe94d98200e43e9113fa15e3635bb69bb046794..c0f1f8e0059c7b1aa75f81e1a9d902aff01c9bf6 100644 (file)
@@ -17,7 +17,7 @@
 %                                 October 1996                                %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
 #include "MagickCore/cache-view.h"
 #include "MagickCore/color.h"
 #include "MagickCore/color-private.h"
+#include "MagickCore/colorspace-private.h"
 #include "MagickCore/composite.h"
 #include "MagickCore/decorate.h"
+#include "MagickCore/distort.h"
 #include "MagickCore/draw.h"
 #include "MagickCore/effect.h"
 #include "MagickCore/enhance.h"
@@ -58,6 +60,7 @@
 #include "MagickCore/fx.h"
 #include "MagickCore/fx-private.h"
 #include "MagickCore/gem.h"
+#include "MagickCore/gem-private.h"
 #include "MagickCore/geometry.h"
 #include "MagickCore/layer.h"
 #include "MagickCore/list.h"
@@ -79,7 +82,6 @@
 #include "MagickCore/resample.h"
 #include "MagickCore/resample-private.h"
 #include "MagickCore/resize.h"
-#include "MagickCore/shear.h"
 #include "MagickCore/splay-tree.h"
 #include "MagickCore/statistic.h"
 #include "MagickCore/string_.h"
@@ -150,7 +152,7 @@ struct _FxInfo
 %    o expression: the expression.
 %
 */
-MagickExport FxInfo *AcquireFxInfo(const Image *image,const char *expression)
+MagickPrivate FxInfo *AcquireFxInfo(const Image *image,const char *expression)
 {
   char
     fx_op[2];
@@ -193,60 +195,6 @@ MagickExport FxInfo *AcquireFxInfo(const Image *image,const char *expression)
     Force right-to-left associativity for unary negation.
   */
   (void) SubstituteString(&fx_info->expression,"-","-1.0*");
-  if ((strstr(fx_info->expression,"e+") != (char *) NULL) ||
-      (strstr(fx_info->expression,"e-") != (char *) NULL))
-    {
-      /*
-        Convert scientific notation.
-      */
-      (void) SubstituteString(&fx_info->expression,"0e+","0**10^");
-      (void) SubstituteString(&fx_info->expression,"1e+","1**10^");
-      (void) SubstituteString(&fx_info->expression,"2e+","2**10^");
-      (void) SubstituteString(&fx_info->expression,"3e+","3**10^");
-      (void) SubstituteString(&fx_info->expression,"4e+","4**10^");
-      (void) SubstituteString(&fx_info->expression,"5e+","5**10^");
-      (void) SubstituteString(&fx_info->expression,"6e+","6**10^");
-      (void) SubstituteString(&fx_info->expression,"7e+","7**10^");
-      (void) SubstituteString(&fx_info->expression,"8e+","8**10^");
-      (void) SubstituteString(&fx_info->expression,"9e+","9**10^");
-      (void) SubstituteString(&fx_info->expression,"0e-1.0*","0**10^-");
-      (void) SubstituteString(&fx_info->expression,"1e-1.0*","1**10^-");
-      (void) SubstituteString(&fx_info->expression,"2e-1.0*","2**10^-");
-      (void) SubstituteString(&fx_info->expression,"3e-1.0*","3**10^-");
-      (void) SubstituteString(&fx_info->expression,"4e-1.0*","4**10^-");
-      (void) SubstituteString(&fx_info->expression,"5e-1.0*","5**10^-");
-      (void) SubstituteString(&fx_info->expression,"6e-1.0*","6**10^-");
-      (void) SubstituteString(&fx_info->expression,"7e-1.0*","7**10^-");
-      (void) SubstituteString(&fx_info->expression,"8e-1.0*","8**10^-");
-      (void) SubstituteString(&fx_info->expression,"9e-1.0*","9**10^-");
-    }
-  if ((strstr(fx_info->expression,"E+") != (char *) NULL) ||
-      (strstr(fx_info->expression,"E-") != (char *) NULL))
-    {
-      /*
-        Convert scientific notation.
-      */
-      (void) SubstituteString(&fx_info->expression,"0E+","0**10^");
-      (void) SubstituteString(&fx_info->expression,"1E+","1**10^");
-      (void) SubstituteString(&fx_info->expression,"2E+","2**10^");
-      (void) SubstituteString(&fx_info->expression,"3E+","3**10^");
-      (void) SubstituteString(&fx_info->expression,"4E+","4**10^");
-      (void) SubstituteString(&fx_info->expression,"5E+","5**10^");
-      (void) SubstituteString(&fx_info->expression,"6E+","6**10^");
-      (void) SubstituteString(&fx_info->expression,"7E+","7**10^");
-      (void) SubstituteString(&fx_info->expression,"8E+","8**10^");
-      (void) SubstituteString(&fx_info->expression,"9E+","9**10^");
-      (void) SubstituteString(&fx_info->expression,"0E-1.0*","0**10^-");
-      (void) SubstituteString(&fx_info->expression,"1E-1.0*","1**10^-");
-      (void) SubstituteString(&fx_info->expression,"2E-1.0*","2**10^-");
-      (void) SubstituteString(&fx_info->expression,"3E-1.0*","3**10^-");
-      (void) SubstituteString(&fx_info->expression,"4E-1.0*","4**10^-");
-      (void) SubstituteString(&fx_info->expression,"5E-1.0*","5**10^-");
-      (void) SubstituteString(&fx_info->expression,"6E-1.0*","6**10^-");
-      (void) SubstituteString(&fx_info->expression,"7E-1.0*","7**10^-");
-      (void) SubstituteString(&fx_info->expression,"8E-1.0*","8**10^-");
-      (void) SubstituteString(&fx_info->expression,"9E-1.0*","9**10^-");
-    }
   /*
     Convert complex to simple operators.
   */
@@ -288,7 +236,7 @@ MagickExport FxInfo *AcquireFxInfo(const Image *image,const char *expression)
 %  The format of the AddNoiseImage method is:
 %
 %      Image *AddNoiseImage(const Image *image,const NoiseType noise_type,
-%        ExceptionInfo *exception)
+%        const double attenuate,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -299,10 +247,13 @@ MagickExport FxInfo *AcquireFxInfo(const Image *image,const char *expression)
 %    o noise_type:  The type of noise: Uniform, Gaussian, Multiplicative,
 %      Impulse, Laplacian, or Poisson.
 %
+%    o attenuate:  attenuate the random distribution.
+%
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *AddNoiseImage(const Image *image,const NoiseType noise_type,  ExceptionInfo *exception)
+MagickExport Image *AddNoiseImage(const Image *image,const NoiseType noise_type,
+  const double attenuate,ExceptionInfo *exception)
 {
 #define AddNoiseImageTag  "AddNoise/Image"
 
@@ -310,21 +261,16 @@ MagickExport Image *AddNoiseImage(const Image *image,const NoiseType noise_type,
     *image_view,
     *noise_view;
 
-  const char
-    *option;
-
   Image
     *noise_image;
 
   MagickBooleanType
+    concurrent,
     status;
 
   MagickOffsetType
     progress;
 
-  MagickRealType
-    attenuate;
-
   RandomInfo
     **restrict random_info;
 
@@ -340,7 +286,7 @@ MagickExport Image *AddNoiseImage(const Image *image,const NoiseType noise_type,
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  noise_image=CloneImage(image,0,0,MagickTrue,exception);
+  noise_image=CloneImage(image,image->columns,image->rows,MagickTrue,exception);
   if (noise_image == (Image *) NULL)
     return((Image *) NULL);
   if (SetImageStorageClass(noise_image,DirectClass,exception) == MagickFalse)
@@ -351,17 +297,15 @@ MagickExport Image *AddNoiseImage(const Image *image,const NoiseType noise_type,
   /*
     Add noise in each row.
   */
-  attenuate=1.0;
-  option=GetImageArtifact(image,"attenuate");
-  if (option != (char *) NULL)
-    attenuate=InterpretLocaleValue(option,(char **) NULL);
   status=MagickTrue;
   progress=0;
   random_info=AcquireRandomInfoThreadSet();
+  concurrent=GetRandomSecretKey(random_info[0]) == ~0UL ? MagickTrue :
+    MagickFalse;
   image_view=AcquireCacheView(image);
   noise_view=AcquireCacheView(noise_image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) omp_concurrent(concurrent)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
@@ -383,7 +327,7 @@ MagickExport Image *AddNoiseImage(const Image *image,const NoiseType noise_type,
     if (status == MagickFalse)
       continue;
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
-    q=GetCacheViewAuthenticPixels(noise_view,0,y,noise_image->columns,1,
+    q=QueueCacheViewAuthenticPixels(noise_view,0,y,noise_image->columns,1,
       exception);
     if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
       {
@@ -392,22 +336,39 @@ MagickExport Image *AddNoiseImage(const Image *image,const NoiseType noise_type,
       }
     for (x=0; x < (ssize_t) image->columns; x++)
     {
-      if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
-        SetPixelRed(noise_image,ClampToQuantum(GenerateDifferentialNoise(
-          random_info[id],GetPixelRed(image,p),noise_type,attenuate)),q);
-      if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
-        SetPixelGreen(noise_image,ClampToQuantum(GenerateDifferentialNoise(
-          random_info[id],GetPixelGreen(image,p),noise_type,attenuate)),q);
-      if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
-        SetPixelBlue(noise_image,ClampToQuantum(GenerateDifferentialNoise(
-          random_info[id],GetPixelBlue(image,p),noise_type,attenuate)),q);
-      if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
-          (image->colorspace == CMYKColorspace))
-        SetPixelBlack(noise_image,ClampToQuantum(GenerateDifferentialNoise(
-          random_info[id],GetPixelBlack(image,p),noise_type,attenuate)),q);
-      if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
-        SetPixelAlpha(noise_image,ClampToQuantum(GenerateDifferentialNoise(
-          random_info[id],GetPixelAlpha(image,p),noise_type,attenuate)),q);
+      register ssize_t
+        i;
+
+      if (GetPixelMask(image,p) != 0)
+        {
+          p+=GetPixelChannels(image);
+          q+=GetPixelChannels(noise_image);
+          continue;
+        }
+      for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+      {
+        PixelChannel
+          channel;
+
+        PixelTrait
+          noise_traits,
+          traits;
+
+        channel=GetPixelChannelMapChannel(image,i);
+        traits=GetPixelChannelMapTraits(image,channel);
+        noise_traits=GetPixelChannelMapTraits(noise_image,channel);
+        if ((traits == UndefinedPixelTrait) ||
+            (noise_traits == UndefinedPixelTrait))
+          continue;
+        if ((noise_traits & CopyPixelTrait) != 0)
+          {
+            SetPixelChannel(noise_image,channel,p[i],q);
+            continue;
+          }
+        SetPixelChannel(noise_image,channel,ClampToQuantum(
+          GenerateDifferentialNoise(random_info[id],p[i],noise_type,attenuate)),
+          q);
+      }
       p+=GetPixelChannels(image);
       q+=GetPixelChannels(noise_image);
     }
@@ -494,8 +455,7 @@ MagickExport Image *BlueShiftImage(const Image *image,const double factor,
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  shift_image=CloneImage(image,image->columns,image->rows,MagickTrue,
-    exception);
+  shift_image=CloneImage(image,image->columns,image->rows,MagickTrue,exception);
   if (shift_image == (Image *) NULL)
     return((Image *) NULL);
   if (SetImageStorageClass(shift_image,DirectClass,exception) == MagickFalse)
@@ -511,7 +471,7 @@ MagickExport Image *BlueShiftImage(const Image *image,const double factor,
   image_view=AcquireCacheView(image);
   shift_view=AcquireCacheView(shift_image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
@@ -576,7 +536,7 @@ MagickExport Image *BlueShiftImage(const Image *image,const double factor,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_BlueShiftImage)
+        #pragma omp critical (MagickCore_BlueShiftImage)
 #endif
         proceed=SetImageProgress(image,BlueShiftImageTag,progress++,
           image->rows);
@@ -639,8 +599,8 @@ MagickExport Image *CharcoalImage(const Image *image,const double radius,
   clone_image=CloneImage(image,0,0,MagickTrue,exception);
   if (clone_image == (Image *) NULL)
     return((Image *) NULL);
-  (void) SetImageType(clone_image,GrayscaleType);
-  edge_image=EdgeImage(clone_image,radius,exception);
+  (void) SetImageType(clone_image,GrayscaleType,exception);
+  edge_image=EdgeImage(clone_image,radius,sigma,exception);
   clone_image=DestroyImage(clone_image);
   if (edge_image == (Image *) NULL)
     return((Image *) NULL);
@@ -650,7 +610,7 @@ MagickExport Image *CharcoalImage(const Image *image,const double radius,
     return((Image *) NULL);
   (void) NormalizeImage(charcoal_image,exception);
   (void) NegateImage(charcoal_image,MagickFalse,exception);
-  (void) SetImageType(charcoal_image,GrayscaleType);
+  (void) SetImageType(charcoal_image,GrayscaleType,exception);
   return(charcoal_image);
 }
 \f
@@ -672,14 +632,14 @@ MagickExport Image *CharcoalImage(const Image *image,const double radius,
 %
 %  The format of the ColorizeImage method is:
 %
-%      Image *ColorizeImage(const Image *image,const char *opacity,
-%        const PixelPacket colorize,ExceptionInfo *exception)
+%      Image *ColorizeImage(const Image *image,const char *blend,
+%        const PixelInfo *colorize,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
 %    o image: the image.
 %
-%    o opacity:  A character string indicating the level of opacity as a
+%    o blend:  A character string indicating the level of blending as a
 %      percentage.
 %
 %    o colorize: A color value.
@@ -687,10 +647,12 @@ MagickExport Image *CharcoalImage(const Image *image,const double radius,
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *ColorizeImage(const Image *image,const char *opacity,
-  const PixelPacket colorize,ExceptionInfo *exception)
+MagickExport Image *ColorizeImage(const Image *image,const char *blend,
+  const PixelInfo *colorize,ExceptionInfo *exception)
 {
 #define ColorizeImageTag  "Colorize/Image"
+#define Colorize(pixel,blend_percentage,colorize)  \
+  (pixel)=((pixel)*(100.0-(blend_percentage))+(colorize)*(blend_percentage))/100.0;
 
   CacheView
     *colorize_view,
@@ -708,12 +670,12 @@ MagickExport Image *ColorizeImage(const Image *image,const char *opacity,
   MagickOffsetType
     progress;
 
-  PixelInfo
-    pixel;
-
   MagickStatusType
     flags;
 
+  PixelInfo
+    blend_percentage;
+
   ssize_t
     y;
 
@@ -735,22 +697,34 @@ MagickExport Image *ColorizeImage(const Image *image,const char *opacity,
       colorize_image=DestroyImage(colorize_image);
       return((Image *) NULL);
     }
-  if (opacity == (const char *) NULL)
+  if ((IsGrayColorspace(image->colorspace) != MagickFalse) &&
+      (IsPixelInfoGray(colorize) != MagickFalse))
+    (void) SetImageColorspace(colorize_image,sRGBColorspace,exception);
+  if ((colorize_image->matte == MagickFalse) &&
+      (colorize->matte != MagickFalse))
+    (void) SetImageAlpha(colorize_image,OpaqueAlpha,exception);
+  if (blend == (const char *) NULL)
     return(colorize_image);
-  /*
-    Determine RGB values of the pen color.
-  */
-  flags=ParseGeometry(opacity,&geometry_info);
-  pixel.red=geometry_info.rho;
-  pixel.green=geometry_info.rho;
-  pixel.blue=geometry_info.rho;
-  pixel.alpha=(MagickRealType) OpaqueAlpha;
+  GetPixelInfo(image,&blend_percentage);
+  flags=ParseGeometry(blend,&geometry_info);
+  blend_percentage.red=geometry_info.rho;
+  blend_percentage.green=geometry_info.rho;
+  blend_percentage.blue=geometry_info.rho;
+  blend_percentage.black=geometry_info.rho;
+  blend_percentage.alpha=geometry_info.rho;
   if ((flags & SigmaValue) != 0)
-    pixel.green=geometry_info.sigma;
+    blend_percentage.green=geometry_info.sigma;
   if ((flags & XiValue) != 0)
-    pixel.blue=geometry_info.xi;
+    blend_percentage.blue=geometry_info.xi;
   if ((flags & PsiValue) != 0)
-    pixel.alpha=geometry_info.psi;
+    blend_percentage.alpha=geometry_info.psi;
+  if (blend_percentage.colorspace == CMYKColorspace)
+    {
+      if ((flags & PsiValue) != 0)
+        blend_percentage.black=geometry_info.psi;
+      if ((flags & ChiValue) != 0)
+        blend_percentage.alpha=geometry_info.chi;
+    }
   /*
     Colorize DirectClass image.
   */
@@ -759,13 +733,16 @@ MagickExport Image *ColorizeImage(const Image *image,const char *opacity,
   image_view=AcquireCacheView(image);
   colorize_view=AcquireCacheView(colorize_image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickBooleanType
       sync;
 
+    PixelInfo
+      pixel;
+
     register const Quantum
       *restrict p;
 
@@ -785,16 +762,22 @@ MagickExport Image *ColorizeImage(const Image *image,const char *opacity,
         status=MagickFalse;
         continue;
       }
+    GetPixelInfo(colorize_image,&pixel);
     for (x=0; x < (ssize_t) image->columns; x++)
     {
-      SetPixelRed(colorize_image,ClampToQuantum((GetPixelRed(image,p)*
-        (100.0-pixel.red)+colorize.red*pixel.red)/100.0),q);
-      SetPixelGreen(colorize_image,ClampToQuantum((GetPixelGreen(image,p)*
-        (100.0-pixel.green)+colorize.green*pixel.green)/100.0),q);
-      SetPixelBlue(colorize_image,ClampToQuantum((GetPixelBlue(image,p)*
-        (100.0-pixel.blue)+colorize.blue*pixel.blue)/100.0),q);
-      SetPixelAlpha(colorize_image,ClampToQuantum((GetPixelAlpha(image,p)*
-        (100.0-pixel.alpha)+colorize.alpha*pixel.alpha)/100.0),q);
+      if (GetPixelMask(colorize_image,q) != 0)
+        {
+          p+=GetPixelChannels(image);
+          q+=GetPixelChannels(colorize_image);
+          continue;
+        }
+      GetPixelInfoPixel(image,p,&pixel);
+      Colorize(pixel.red,blend_percentage.red,colorize->red);
+      Colorize(pixel.green,blend_percentage.green,colorize->green);
+      Colorize(pixel.blue,blend_percentage.blue,colorize->blue);
+      Colorize(pixel.black,blend_percentage.black,colorize->black);
+      Colorize(pixel.alpha,blend_percentage.alpha,colorize->alpha);
+      SetPixelInfoPixel(colorize_image,&pixel,q);
       p+=GetPixelChannels(image);
       q+=GetPixelChannels(colorize_image);
     }
@@ -807,7 +790,7 @@ MagickExport Image *ColorizeImage(const Image *image,const char *opacity,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_ColorizeImage)
+        #pragma omp critical (MagickCore_ColorizeImage)
 #endif
         proceed=SetImageProgress(image,ColorizeImageTag,progress++,image->rows);
         if (proceed == MagickFalse)
@@ -854,6 +837,11 @@ MagickExport Image *ColorizeImage(const Image *image,const char *opacity,
 %    o exception: return any errors or warnings in this structure.
 %
 */
+/* FUTURE: modify to make use of a MagickMatrix Mutliply function
+   That should be provided in "matrix.c"
+   (ASIDE: actually distorts should do this too but currently doesn't)
+*/
+
 MagickExport Image *ColorMatrixImage(const Image *image,
   const KernelInfo *color_matrix,ExceptionInfo *exception)
 {
@@ -892,7 +880,7 @@ MagickExport Image *ColorMatrixImage(const Image *image,
     y;
 
   /*
-    Create color matrix.
+    Map given color_matrix, into a 6x6 matrix   RGBKA and a constant
   */
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
@@ -944,18 +932,18 @@ MagickExport Image *ColorMatrixImage(const Image *image,
       message=DestroyString(message);
     }
   /*
-    ColorMatrix image.
+    Apply the ColorMatrix to image.
   */
   status=MagickTrue;
   progress=0;
   image_view=AcquireCacheView(image);
   color_view=AcquireCacheView(color_image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
-    MagickRealType
+    PixelInfo
       pixel;
 
     register const Quantum
@@ -977,6 +965,7 @@ MagickExport Image *ColorMatrixImage(const Image *image,
         status=MagickFalse;
         continue;
       }
+    GetPixelInfo(image,&pixel);
     for (x=0; x < (ssize_t) image->columns; x++)
     {
       register ssize_t
@@ -985,35 +974,31 @@ MagickExport Image *ColorMatrixImage(const Image *image,
       size_t
         height;
 
+      GetPixelInfoPixel(image,p,&pixel);
       height=color_matrix->height > 6 ? 6UL : color_matrix->height;
       for (v=0; v < (ssize_t) height; v++)
       {
-        pixel=ColorMatrix[v][0]*GetPixelRed(image,p)+ColorMatrix[v][1]*
+        MagickRealType
+          sum;
+
+        sum=ColorMatrix[v][0]*GetPixelRed(image,p)+ColorMatrix[v][1]*
           GetPixelGreen(image,p)+ColorMatrix[v][2]*GetPixelBlue(image,p);
         if (image->colorspace == CMYKColorspace)
-          pixel+=ColorMatrix[v][3]*GetPixelBlack(image,p);
+          sum+=ColorMatrix[v][3]*GetPixelBlack(image,p);
         if (image->matte != MagickFalse)
-          pixel+=ColorMatrix[v][4]*GetPixelAlpha(image,p);
-        pixel+=QuantumRange*ColorMatrix[v][5];
+          sum+=ColorMatrix[v][4]*GetPixelAlpha(image,p);
+        sum+=QuantumRange*ColorMatrix[v][5];
         switch (v)
         {
-          case 0: SetPixelRed(color_image,ClampToQuantum(pixel),q); break;
-          case 1: SetPixelGreen(color_image,ClampToQuantum(pixel),q); break;
-          case 2: SetPixelBlue(color_image,ClampToQuantum(pixel),q); break;
-          case 3:
-          {
-            if (image->colorspace == CMYKColorspace)
-              SetPixelBlack(color_image,ClampToQuantum(pixel),q);
-            break;
-          }
-          case 4:
-          {
-            if (image->matte != MagickFalse)
-              SetPixelAlpha(color_image,ClampToQuantum(pixel),q);
-            break;
-          }
+          case 0: pixel.red=sum; break;
+          case 1: pixel.green=sum; break;
+          case 2: pixel.blue=sum; break;
+          case 3: pixel.black=sum; break;
+          case 4: pixel.alpha=sum; break;
+          default: break;
         }
       }
+      SetPixelInfoPixel(color_image,&pixel,q);
       p+=GetPixelChannels(image);
       q+=GetPixelChannels(color_image);
     }
@@ -1025,7 +1010,7 @@ MagickExport Image *ColorMatrixImage(const Image *image,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_ColorMatrixImage)
+        #pragma omp critical (MagickCore_ColorMatrixImage)
 #endif
         proceed=SetImageProgress(image,ColorMatrixImageTag,progress++,
           image->rows);
@@ -1062,7 +1047,7 @@ MagickExport Image *ColorMatrixImage(const Image *image,
 %    o fx_info: the fx info.
 %
 */
-MagickExport FxInfo *DestroyFxInfo(FxInfo *fx_info)
+MagickPrivate FxInfo *DestroyFxInfo(FxInfo *fx_info)
 {
   register ssize_t
     i;
@@ -1159,7 +1144,7 @@ static MagickRealType FxChannelStatistics(FxInfo *fx_info,const Image *image,
     (double) channel,symbol);
   value=(const char *) GetValueFromSplayTree(fx_info->symbols,key);
   if (value != (const char *) NULL)
-    return(QuantumScale*InterpretLocaleValue(value,(char **) NULL));
+    return(QuantumScale*StringToDouble(value,(char **) NULL));
   (void) DeleteNodeFromSplayTree(fx_info->symbols,key);
   if (LocaleNCompare(symbol,"depth",5) == 0)
     {
@@ -1226,35 +1211,18 @@ static MagickRealType FxChannelStatistics(FxInfo *fx_info,const Image *image,
     }
   (void) AddValueToSplayTree(fx_info->symbols,ConstantString(key),
     ConstantString(statistic));
-  return(QuantumScale*InterpretLocaleValue(statistic,(char **) NULL));
+  return(QuantumScale*StringToDouble(statistic,(char **) NULL));
 }
 
 static MagickRealType
   FxEvaluateSubexpression(FxInfo *,const PixelChannel,const ssize_t,
     const ssize_t,const char *,MagickRealType *,ExceptionInfo *);
 
-static inline MagickRealType FxMax(FxInfo *fx_info,const PixelChannel channel,
-  const ssize_t x,const ssize_t y,const char *expression,
-  ExceptionInfo *exception)
-{
-  MagickRealType
-    alpha,
-    beta;
-
-  alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression,&beta,exception);
-  return((MagickRealType) MagickMax((double) alpha,(double) beta));
-}
-
-static inline MagickRealType FxMin(FxInfo *fx_info,PixelChannel channel,
-  const ssize_t x,const ssize_t y,const char *expression,
-  ExceptionInfo *exception)
+static MagickOffsetType FxGCD(MagickOffsetType alpha,MagickOffsetType beta)
 {
-  MagickRealType
-    alpha,
-    beta;
-
-  alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression,&beta,exception);
-  return((MagickRealType) MagickMin((double) alpha,(double) beta));
+  if (beta != 0)
+    return(FxGCD(beta,alpha % beta));
+  return(alpha);
 }
 
 static inline const char *FxSubexpression(const char *expression,
@@ -1314,9 +1282,7 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
     i;
 
   size_t
-    length;
-
-  size_t
+    length,
     level;
 
   p=expression;
@@ -1436,10 +1402,8 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
   GetPixelInfo(image,&pixel);
   (void) InterpolatePixelInfo(image,fx_info->view[i],image->interpolate,
     point.x,point.y,&pixel,exception);
-  if ((strlen(p) > 2) &&
-      (LocaleCompare(p,"intensity") != 0) &&
-      (LocaleCompare(p,"luminance") != 0) &&
-      (LocaleCompare(p,"hue") != 0) &&
+  if ((strlen(p) > 2) && (LocaleCompare(p,"intensity") != 0) &&
+      (LocaleCompare(p,"luminance") != 0) && (LocaleCompare(p,"hue") != 0) &&
       (LocaleCompare(p,"saturation") != 0) &&
       (LocaleCompare(p,"lightness") != 0))
     {
@@ -1470,12 +1434,19 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
               p+=strlen(name);
             }
           else
-            if (QueryMagickColor(name,&pixel,fx_info->exception) != MagickFalse)
-              {
-                (void) AddValueToSplayTree(fx_info->colors,ConstantString(name),
-                  ClonePixelInfo(&pixel));
-                p+=strlen(name);
-              }
+            {
+              MagickBooleanType
+                status;
+
+              status=QueryColorCompliance(name,AllCompliance,&pixel,
+                fx_info->exception);
+              if (status != MagickFalse)
+                {
+                  (void) AddValueToSplayTree(fx_info->colors,ConstantString(
+                    name),ClonePixelInfo(&pixel));
+                  p+=strlen(name);
+                }
+            }
         }
     }
   (void) CopyMagickString(symbol,p,MaxTextExtent);
@@ -1492,7 +1463,7 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
           if (image->colorspace != CMYKColorspace)
             {
               (void) ThrowMagickException(exception,GetMagickModule(),
-                OptionError,"ColorSeparatedImageRequired","`%s'",
+                ImageError,"ColorSeparatedImageRequired","`%s'",
                 image->filename);
               return(0.0);
             }
@@ -1508,6 +1479,8 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
           alpha=(MagickRealType) (QuantumScale*pixel.alpha);
           return(alpha);
         }
+        case IndexPixelChannel:
+          return(0.0);
         case IntensityPixelChannel:
         {
           return(QuantumScale*GetPixelInfoIntensity(&pixel));
@@ -1668,8 +1641,8 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
             lightness,
             saturation;
 
-          ConvertRGBToHSL(ClampToQuantum(pixel.red),ClampToQuantum(pixel.green),
-            ClampToQuantum(pixel.blue),&hue,&saturation,&lightness);
+          ConvertRGBToHSL(pixel.red,pixel.green,pixel.blue,&hue,&saturation,
+            &lightness);
           return(hue);
         }
       break;
@@ -1686,9 +1659,9 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
           (LocaleCompare(symbol,"image.standard_deviation") == 0))
         return(FxChannelStatistics(fx_info,image,channel,symbol+6,exception));
       if (LocaleCompare(symbol,"image.resolution.x") == 0)
-        return(image->x_resolution);
+        return(image->resolution.x);
       if (LocaleCompare(symbol,"image.resolution.y") == 0)
-        return(image->y_resolution);
+        return(image->resolution.y);
       if (LocaleCompare(symbol,"intensity") == 0)
         return(QuantumScale*GetPixelInfoIntensity(&pixel));
       if (LocaleCompare(symbol,"i") == 0)
@@ -1712,8 +1685,8 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
             lightness,
             saturation;
 
-          ConvertRGBToHSL(ClampToQuantum(pixel.red),ClampToQuantum(pixel.green),
-            ClampToQuantum(pixel.blue),&hue,&saturation,&lightness);
+          ConvertRGBToHSL(pixel.red,pixel.green,pixel.blue,&hue,&saturation,
+            &lightness);
           return(lightness);
         }
       if (LocaleCompare(symbol,"luminance") == 0)
@@ -1770,9 +1743,9 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
     case 'r':
     {
       if (LocaleCompare(symbol,"resolution.x") == 0)
-        return(image->x_resolution);
+        return(image->resolution.x);
       if (LocaleCompare(symbol,"resolution.y") == 0)
-        return(image->y_resolution);
+        return(image->resolution.y);
       if (LocaleCompare(symbol,"r") == 0)
         return(QuantumScale*pixel.red);
       break;
@@ -1787,8 +1760,8 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
             lightness,
             saturation;
 
-          ConvertRGBToHSL(ClampToQuantum(pixel.red),ClampToQuantum(pixel.green),
-            ClampToQuantum(pixel.blue),&hue,&saturation,&lightness);
+          ConvertRGBToHSL(pixel.red,pixel.green,pixel.blue,&hue,&saturation,
+            &lightness);
           return(saturation);
         }
       if (LocaleNCompare(symbol,"skewness",8) == 0)
@@ -1836,7 +1809,7 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
   }
   value=(const char *) GetValueFromSplayTree(fx_info->symbols,symbol);
   if (value != (const char *) NULL)
-    return((MagickRealType) InterpretLocaleValue(value,(char **) NULL));
+    return((MagickRealType) StringToDouble(value,(char **) NULL));
   (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
     "UnableToParseExpression","`%s'",symbol);
   return(0.0);
@@ -1920,6 +1893,16 @@ static const char *FxOperatorPrecedence(const char *expression,
 #endif
         break;
       }
+      case 'E':
+      case 'e':
+      {
+        if ((LocaleNCompare(expression,"E+",2) == 0) ||
+            (LocaleNCompare(expression,"E-",2) == 0))
+          {
+            expression+=2;  /* scientific notation */
+            break;
+          }
+      }
       case 'J':
       case 'j':
       {
@@ -2179,15 +2162,13 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         case LeftShiftOperator:
         {
           gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
-          *beta=(MagickRealType) ((size_t) (alpha+0.5) << (size_t)
-            (gamma+0.5));
+          *beta=(MagickRealType) ((size_t) (alpha+0.5) << (size_t) (gamma+0.5));
           return(*beta);
         }
         case RightShiftOperator:
         {
           gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
-          *beta=(MagickRealType) ((size_t) (alpha+0.5) >> (size_t)
-            (gamma+0.5));
+          *beta=(MagickRealType) ((size_t) (alpha+0.5) >> (size_t) (gamma+0.5));
           return(*beta);
         }
         case '<':
@@ -2223,15 +2204,13 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         case '&':
         {
           gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
-          *beta=(MagickRealType) ((size_t) (alpha+0.5) & (size_t)
-            (gamma+0.5));
+          *beta=(MagickRealType) ((size_t) (alpha+0.5) & (size_t) (gamma+0.5));
           return(*beta);
         }
         case '|':
         {
           gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
-          *beta=(MagickRealType) ((size_t) (alpha+0.5) | (size_t)
-            (gamma+0.5));
+          *beta=(MagickRealType) ((size_t) (alpha+0.5) | (size_t) (gamma+0.5));
           return(*beta);
         }
         case LogicalAndOperator:
@@ -2478,12 +2457,17 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
           if (strlen(subexpression) > 1)
             subexpression[strlen(subexpression)-1]='\0';
           if (fx_info->file != (FILE *) NULL)
-            (void) FormatLocaleFile(fx_info->file,
-              "%s[%.20g,%.20g].%s: %s=%.*g\n",fx_info->images->filename,
-               (double) x,(double) y,type,subexpression,GetMagickPrecision(),
-               (double) alpha);
+            (void) FormatLocaleFile(fx_info->file,"%s[%.20g,%.20g].%s: "
+               "%s=%.*g\n",fx_info->images->filename,(double) x,(double) y,type,
+               subexpression,GetMagickPrecision(),(double) alpha);
           return(0.0);
         }
+      if (LocaleNCompare(expression,"drc",3) == 0)
+        {
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
+            exception);
+          return((MagickRealType) (alpha/(*beta*(alpha-1.0)+1.0)));
+        }
       break;
     }
     case 'E':
@@ -2515,6 +2499,24 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
     case 'G':
     case 'g':
     {
+      if (LocaleNCompare(expression,"gauss",5) == 0)
+        {
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
+            exception);
+          gamma=exp((double) (-alpha*alpha/2.0))/sqrt(2.0*MagickPI);
+          return((MagickRealType) gamma);
+        }
+      if (LocaleNCompare(expression,"gcd",3) == 0)
+        {
+          MagickOffsetType
+            gcd;
+
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
+            exception);
+          gcd=FxGCD((MagickOffsetType) (alpha+0.5),(MagickOffsetType) (*beta+
+            0.5));
+          return((MagickRealType) gcd);
+        }
       if (LocaleCompare(expression,"g") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
@@ -2552,6 +2554,14 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
             exception);
           return((MagickRealType) floor(alpha));
         }
+#if defined(MAGICKCORE_HAVE_ISNAN)
+      if (LocaleNCompare(expression,"isnan",5) == 0)
+        {
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
+            exception);
+          return((MagickRealType) !!isnan((double) alpha));
+        }
+#endif
       if (LocaleCompare(expression,"i") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
@@ -2584,8 +2594,8 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
             exception);
           if (alpha == 0.0)
             return(1.0);
-          gamma=(MagickRealType) (2.0*j1((double) (MagickPI*alpha))/
-            (MagickPI*alpha));
+          gamma=(MagickRealType) (2.0*j1((double) (MagickPI*alpha))/(MagickPI*
+            alpha));
           return(gamma);
         }
 #endif
@@ -2624,16 +2634,25 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
       if (LocaleNCompare(expression,"maxima",6) == 0)
         break;
       if (LocaleNCompare(expression,"max",3) == 0)
-        return(FxMax(fx_info,channel,x,y,expression+3,exception));
+        {
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
+            exception);
+          return(alpha > *beta ? alpha : *beta);
+        }
       if (LocaleNCompare(expression,"minima",6) == 0)
         break;
       if (LocaleNCompare(expression,"min",3) == 0)
-        return(FxMin(fx_info,channel,x,y,expression+3,exception));
+        {
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
+            exception);
+          return(alpha < *beta ? alpha : *beta);
+        }
       if (LocaleNCompare(expression,"mod",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
             exception);
-          return((MagickRealType) fmod((double) alpha,(double) *beta));
+          gamma=alpha-floor((double) (alpha/(*beta)))*(*beta);
+          return(gamma);
         }
       if (LocaleCompare(expression,"m") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
@@ -2642,6 +2661,12 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
     case 'N':
     case 'n':
     {
+      if (LocaleNCompare(expression,"not",3) == 0)
+        {
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
+            exception);
+          return((MagickRealType) (alpha < MagickEpsilon));
+        }
       if (LocaleCompare(expression,"n") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
@@ -2658,6 +2683,8 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
     case 'P':
     case 'p':
     {
+      if (LocaleCompare(expression,"phi") == 0)
+        return((MagickRealType) MagickPHI);
       if (LocaleCompare(expression,"pi") == 0)
         return((MagickRealType) MagickPI);
       if (LocaleNCompare(expression,"pow",3) == 0)
@@ -2733,6 +2760,12 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
             exception);
           return((MagickRealType) sqrt((double) alpha));
         }
+      if (LocaleNCompare(expression,"squish",6) == 0)
+        {
+          alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+6,beta,
+            exception);
+          return((MagickRealType) (1.0/(1.0+exp((double) (4.0*alpha)))));
+        }
       if (LocaleCompare(expression,"s") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
@@ -2783,6 +2816,15 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
     case 'W':
     case 'w':
     {
+      if (LocaleNCompare(expression,"while",5) == 0)
+        {
+          do
+          {
+            alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
+              exception);
+          } while (fabs((double) alpha) >= MagickEpsilon);
+          return((MagickRealType) *beta);
+        }
       if (LocaleCompare(expression,"w") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
@@ -2805,13 +2847,13 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
       break;
   }
   q=(char *) expression;
-  alpha=InterpretLocaleValue(expression,&q);
+  alpha=InterpretSiPrefixValue(expression,&q);
   if (q == expression)
     return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
   return(alpha);
 }
 
-MagickExport MagickBooleanType FxEvaluateExpression(FxInfo *fx_info,
+MagickPrivate MagickBooleanType FxEvaluateExpression(FxInfo *fx_info,
   MagickRealType *alpha,ExceptionInfo *exception)
 {
   MagickBooleanType
@@ -2839,7 +2881,7 @@ MagickExport MagickBooleanType FxPreprocessExpression(FxInfo *fx_info,
   return(status);
 }
 
-MagickExport MagickBooleanType FxEvaluateChannelExpression(FxInfo *fx_info,
+MagickPrivate MagickBooleanType FxEvaluateChannelExpression(FxInfo *fx_info,
   const PixelChannel channel,const ssize_t x,const ssize_t y,
   MagickRealType *alpha,ExceptionInfo *exception)
 {
@@ -2991,7 +3033,7 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
   image_view=AcquireCacheView(image);
   fx_view=AcquireCacheView(fx_image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status)
 #endif
   for (y=0; y < (ssize_t) fx_image->rows; y++)
   {
@@ -3010,7 +3052,7 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
     if (status == MagickFalse)
       continue;
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
-    q=GetCacheViewAuthenticPixels(fx_view,0,y,fx_image->columns,1,exception);
+    q=QueueCacheViewAuthenticPixels(fx_view,0,y,fx_image->columns,1,exception);
     if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
       {
         status=MagickFalse;
@@ -3021,6 +3063,12 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
       register ssize_t
         i;
 
+      if (GetPixelMask(image,p) != 0)
+        {
+          p+=GetPixelChannels(image);
+          q+=GetPixelChannels(fx_image);
+          continue;
+        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         MagickRealType
@@ -3033,21 +3081,20 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
           fx_traits,
           traits;
 
-        traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
-        if (traits == UndefinedPixelTrait)
-          continue;
-        channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
+        channel=GetPixelChannelMapChannel(image,i);
+        traits=GetPixelChannelMapTraits(image,channel);
         fx_traits=GetPixelChannelMapTraits(fx_image,channel);
-        if (fx_traits == UndefinedPixelTrait)
+        if ((traits == UndefinedPixelTrait) ||
+            (fx_traits == UndefinedPixelTrait))
           continue;
         if ((fx_traits & CopyPixelTrait) != 0)
           {
-            q[channel]=p[i];
+            SetPixelChannel(fx_image,channel,p[i],q);
             continue;
           }
         alpha=0.0;
-        (void) FxEvaluateChannelExpression(fx_info[id],(PixelChannel) i,x,y,
-          &alpha,exception);
+        (void) FxEvaluateChannelExpression(fx_info[id],channel,x,y,&alpha,
+          exception);
         q[i]=ClampToQuantum((MagickRealType) QuantumRange*alpha);
       }
       p+=GetPixelChannels(image);
@@ -3061,7 +3108,7 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_FxImage)
+        #pragma omp critical (MagickCore_FxImage)
 #endif
         proceed=SetImageProgress(image,FxImageTag,progress++,image->rows);
         if (proceed == MagickFalse)
@@ -3095,7 +3142,7 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
 %  The format of the ImplodeImage method is:
 %
 %      Image *ImplodeImage(const Image *image,const double amount,
-%        ExceptionInfo *exception)
+%        const PixelInterpolateMethod method,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -3107,11 +3154,13 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
 %
 %    o amount:  Define the extent of the implosion.
 %
+%    o method: the pixel interpolation method.
+%
 %    o exception: return any errors or warnings in this structure.
 %
 */
 MagickExport Image *ImplodeImage(const Image *image,const double amount,
-  ExceptionInfo *exception)
+  const PixelInterpolateMethod method,ExceptionInfo *exception)
 {
 #define ImplodeImageTag  "Implode/Image"
 
@@ -3128,9 +3177,6 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
   MagickOffsetType
     progress;
 
-  PixelInfo
-    zero;
-
   MagickRealType
     radius;
 
@@ -3150,7 +3196,8 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  implode_image=CloneImage(image,0,0,MagickTrue,exception);
+  implode_image=CloneImage(image,image->columns,image->rows,MagickTrue,
+    exception);
   if (implode_image == (Image *) NULL)
     return((Image *) NULL);
   if (SetImageStorageClass(implode_image,DirectClass,exception) == MagickFalse)
@@ -3181,23 +3228,22 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
   */
   status=MagickTrue;
   progress=0;
-  GetPixelInfo(implode_image,&zero);
   image_view=AcquireCacheView(image);
   implode_view=AcquireCacheView(implode_image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
-    PixelInfo
-      pixel;
-
     MagickRealType
       distance;
 
     PointInfo
       delta;
 
+    register const Quantum
+      *restrict p;
+
     register ssize_t
       x;
 
@@ -3206,23 +3252,50 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
 
     if (status == MagickFalse)
       continue;
-    q=GetCacheViewAuthenticPixels(implode_view,0,y,implode_image->columns,1,
+    p=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
+    q=QueueCacheViewAuthenticPixels(implode_view,0,y,implode_image->columns,1,
       exception);
-    if (q == (const Quantum *) NULL)
+    if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
       {
         status=MagickFalse;
         continue;
       }
     delta.y=scale.y*(double) (y-center.y);
-    pixel=zero;
     for (x=0; x < (ssize_t) image->columns; x++)
     {
+      register ssize_t
+        i;
+
       /*
         Determine if the pixel is within an ellipse.
       */
+      if (GetPixelMask(image,p) != 0)
+        {
+          p+=GetPixelChannels(image);
+          q+=GetPixelChannels(implode_image);
+          continue;
+        }
       delta.x=scale.x*(double) (x-center.x);
       distance=delta.x*delta.x+delta.y*delta.y;
-      if (distance < (radius*radius))
+      if (distance >= (radius*radius))
+        for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+        {
+          PixelChannel
+            channel;
+
+          PixelTrait
+            implode_traits,
+            traits;
+
+          channel=GetPixelChannelMapChannel(image,i);
+          traits=GetPixelChannelMapTraits(image,channel);
+          implode_traits=GetPixelChannelMapTraits(implode_image,channel);
+          if ((traits == UndefinedPixelTrait) ||
+              (implode_traits == UndefinedPixelTrait))
+            continue;
+          SetPixelChannel(implode_image,channel,p[i],q);
+        }
+      else
         {
           double
             factor;
@@ -3232,14 +3305,13 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
           */
           factor=1.0;
           if (distance > 0.0)
-            factor=pow(sin((double) (MagickPI*sqrt((double) distance)/
-              radius/2)),-amount);
-          (void) InterpolatePixelInfo(image,image_view,
-            UndefinedInterpolatePixel,(double) (factor*delta.x/scale.x+
-            center.x),(double) (factor*delta.y/scale.y+center.y),&pixel,
-            exception);
-          SetPixelPixelInfo(implode_image,&pixel,q);
+            factor=pow(sin((double) (MagickPI*sqrt((double) distance)/radius/
+              2)),-amount);
+          status=InterpolatePixelChannels(image,image_view,implode_image,method,
+            (double) (factor*delta.x/scale.x+center.x),(double) (factor*delta.y/
+            scale.y+center.y),q,exception);
         }
+      p+=GetPixelChannels(image);
       q+=GetPixelChannels(implode_image);
     }
     if (SyncCacheViewAuthenticPixels(implode_view,exception) == MagickFalse)
@@ -3250,7 +3322,7 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_ImplodeImage)
+        #pragma omp critical (MagickCore_ImplodeImage)
 #endif
         proceed=SetImageProgress(image,ImplodeImageTag,progress++,image->rows);
         if (proceed == MagickFalse)
@@ -3378,15 +3450,15 @@ MagickExport Image *MorphImages(const Image *image,
       beta=(MagickRealType) (i+1.0)/(MagickRealType) (number_frames+1.0);
       alpha=1.0-beta;
       morph_image=ResizeImage(next,(size_t) (alpha*next->columns+beta*
-        GetNextImageInList(next)->columns+0.5),(size_t) (alpha*
-        next->rows+beta*GetNextImageInList(next)->rows+0.5),
-        next->filter,next->blur,exception);
+        GetNextImageInList(next)->columns+0.5),(size_t) (alpha*next->rows+beta*
+        GetNextImageInList(next)->rows+0.5),next->filter,exception);
       if (morph_image == (Image *) NULL)
         {
           morph_images=DestroyImageList(morph_images);
           return((Image *) NULL);
         }
-      if (SetImageStorageClass(morph_image,DirectClass,exception) == MagickFalse)
+      status=SetImageStorageClass(morph_image,DirectClass,exception);
+      if (status == MagickFalse)
         {
           morph_image=DestroyImage(morph_image);
           return((Image *) NULL);
@@ -3394,8 +3466,7 @@ MagickExport Image *MorphImages(const Image *image,
       AppendImageToList(&morph_images,morph_image);
       morph_images=GetLastImageInList(morph_images);
       morph_image=ResizeImage(GetNextImageInList(next),morph_images->columns,
-        morph_images->rows,GetNextImageInList(next)->filter,
-        GetNextImageInList(next)->blur,exception);
+        morph_images->rows,GetNextImageInList(next)->filter,exception);
       if (morph_image == (Image *) NULL)
         {
           morph_images=DestroyImageList(morph_images);
@@ -3404,7 +3475,7 @@ MagickExport Image *MorphImages(const Image *image,
       image_view=AcquireCacheView(morph_image);
       morph_view=AcquireCacheView(morph_images);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(status)
+  #pragma omp parallel for schedule(static,4) shared(status)
 #endif
       for (y=0; y < (ssize_t) morph_images->rows; y++)
       {
@@ -3433,19 +3504,38 @@ MagickExport Image *MorphImages(const Image *image,
           }
         for (x=0; x < (ssize_t) morph_images->columns; x++)
         {
-          SetPixelRed(morph_images,ClampToQuantum(alpha*
-            GetPixelRed(morph_images,q)+beta*GetPixelRed(morph_image,p)),q);
-          SetPixelGreen(morph_images,ClampToQuantum(alpha*
-            GetPixelGreen(morph_images,q)+beta*GetPixelGreen(morph_image,p)),q);
-          SetPixelBlue(morph_images,ClampToQuantum(alpha*
-            GetPixelBlue(morph_images,q)+beta*GetPixelBlue(morph_image,p)),q);
-          SetPixelAlpha(morph_images,ClampToQuantum(alpha*
-            GetPixelAlpha(morph_images,q)+beta*GetPixelAlpha(morph_image,p)),q);
-          if ((morph_image->colorspace == CMYKColorspace) &&
-              (morph_images->colorspace == CMYKColorspace))
-            SetPixelBlack(morph_images,ClampToQuantum(alpha*
-              GetPixelBlack(morph_images,q)+beta*GetPixelBlack(morph_image,p)),
-              q);
+          register ssize_t
+            i;
+
+          if (GetPixelMask(image,p) != 0)
+            {
+              p+=GetPixelChannels(image);
+              q+=GetPixelChannels(morph_image);
+              continue;
+            }
+          for (i=0; i < (ssize_t) GetPixelChannels(morph_image); i++)
+          {
+            PixelChannel
+              channel;
+
+            PixelTrait
+              morph_traits,
+              traits;
+
+            channel=GetPixelChannelMapChannel(image,i);
+            traits=GetPixelChannelMapTraits(image,channel);
+            morph_traits=GetPixelChannelMapTraits(morph_image,channel);
+            if ((traits == UndefinedPixelTrait) ||
+                (morph_traits == UndefinedPixelTrait))
+              continue;
+            if ((morph_traits & CopyPixelTrait) != 0)
+              {
+                SetPixelChannel(morph_image,channel,p[i],q);
+                continue;
+              }
+            SetPixelChannel(morph_image,channel,ClampToQuantum(alpha*
+              GetPixelChannel(morph_images,channel,q)+beta*p[i]),q);
+          }
           p+=GetPixelChannels(morph_image);
           q+=GetPixelChannels(morph_images);
         }
@@ -3476,7 +3566,7 @@ MagickExport Image *MorphImages(const Image *image,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_MorphImages)
+        #pragma omp critical (MagickCore_MorphImages)
 #endif
         proceed=SetImageProgress(image,MorphImageTag,scene,
           GetImageListLength(image));
@@ -3511,7 +3601,7 @@ MagickExport Image *MorphImages(const Image *image,
 %  The format of the PlasmaImage method is:
 %
 %      MagickBooleanType PlasmaImage(Image *image,const SegmentInfo *segment,
-%        size_t attenuate,size_t depth)
+%        size_t attenuate,size_t depth,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -3523,6 +3613,8 @@ MagickExport Image *MorphImages(const Image *image,
 %
 %    o depth: Limit the plasma recursion depth.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 
 static inline Quantum PlasmaPixel(RandomInfo *random_info,
@@ -3536,19 +3628,29 @@ static inline Quantum PlasmaPixel(RandomInfo *random_info,
   return(plasma);
 }
 
-MagickExport MagickBooleanType PlasmaImageProxy(Image *image,
-  CacheView *image_view,RandomInfo *random_info,const SegmentInfo *segment,
-  size_t attenuate,size_t depth)
+static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
+  CacheView *u_view,CacheView *v_view,RandomInfo *random_info,
+  const SegmentInfo *segment,size_t attenuate,size_t depth,
+  ExceptionInfo *exception)
 {
-  ExceptionInfo
-    *exception;
-
   MagickRealType
     plasma;
 
-  PixelPacket
-    u,
-    v;
+  PixelChannel
+    channel;
+
+  PixelTrait
+    traits;
+
+  register const Quantum
+    *restrict u,
+    *restrict v;
+
+  register Quantum
+    *restrict q;
+
+  register ssize_t
+    i;
 
   ssize_t
     x,
@@ -3573,23 +3675,23 @@ MagickExport MagickBooleanType PlasmaImageProxy(Image *image,
       local_info=(*segment);
       local_info.x2=(double) x_mid;
       local_info.y2=(double) y_mid;
-      (void) PlasmaImageProxy(image,image_view,random_info,&local_info,
-        attenuate,depth);
+      (void) PlasmaImageProxy(image,image_view,u_view,v_view,random_info,
+        &local_info,attenuate,depth,exception);
       local_info=(*segment);
       local_info.y1=(double) y_mid;
       local_info.x2=(double) x_mid;
-      (void) PlasmaImageProxy(image,image_view,random_info,&local_info,
-        attenuate,depth);
+      (void) PlasmaImageProxy(image,image_view,u_view,v_view,random_info,
+        &local_info,attenuate,depth,exception);
       local_info=(*segment);
       local_info.x1=(double) x_mid;
       local_info.y2=(double) y_mid;
-      (void) PlasmaImageProxy(image,image_view,random_info,&local_info,
-        attenuate,depth);
+      (void) PlasmaImageProxy(image,image_view,u_view,v_view,random_info,
+        &local_info,attenuate,depth,exception);
       local_info=(*segment);
       local_info.x1=(double) x_mid;
       local_info.y1=(double) y_mid;
-      return(PlasmaImageProxy(image,image_view,random_info,&local_info,
-        attenuate,depth));
+      return(PlasmaImageProxy(image,image_view,u_view,v_view,random_info,
+        &local_info,attenuate,depth,exception));
     }
   x_mid=(ssize_t) ceil((segment->x1+segment->x2)/2-0.5);
   y_mid=(ssize_t) ceil((segment->y1+segment->y2)/2-0.5);
@@ -3599,30 +3701,29 @@ MagickExport MagickBooleanType PlasmaImageProxy(Image *image,
   /*
     Average pixels and apply plasma.
   */
-  exception=(&image->exception);
   plasma=(MagickRealType) QuantumRange/(2.0*attenuate);
   if ((segment->x1 != (double) x_mid) || (segment->x2 != (double) x_mid))
     {
-      register Quantum
-        *restrict q;
-
       /*
         Left pixel.
       */
       x=(ssize_t) ceil(segment->x1-0.5);
-      (void) GetOneCacheViewVirtualPixel(image_view,x,(ssize_t)
-        ceil(segment->y1-0.5),&u,exception);
-      (void) GetOneCacheViewVirtualPixel(image_view,x,(ssize_t)
-        ceil(segment->y2-0.5),&v,exception);
+      u=GetCacheViewVirtualPixels(u_view,x,(ssize_t) ceil(segment->y1-0.5),1,1,
+        exception);
+      v=GetCacheViewVirtualPixels(v_view,x,(ssize_t) ceil(segment->y2-0.5),1,1,
+        exception);
       q=QueueCacheViewAuthenticPixels(image_view,x,y_mid,1,1,exception);
-      if (q == (const Quantum *) NULL)
+      if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
+          (q == (Quantum *) NULL))
         return(MagickTrue);
-      SetPixelRed(image,PlasmaPixel(random_info,(MagickRealType)
-        (u.red+v.red)/2.0,plasma),q);
-      SetPixelGreen(image,PlasmaPixel(random_info,(MagickRealType)
-        (u.green+v.green)/2.0,plasma),q);
-      SetPixelBlue(image,PlasmaPixel(random_info,(MagickRealType)
-        (u.blue+v.blue)/2.0,plasma),q);
+      for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+      {
+        channel=GetPixelChannelMapChannel(image,i);
+        traits=GetPixelChannelMapTraits(image,channel);
+        if (traits == UndefinedPixelTrait)
+          continue;
+        q[i]=PlasmaPixel(random_info,(u[channel]+v[channel])/2.0,plasma);
+      }
       (void) SyncCacheViewAuthenticPixels(image_view,exception);
       if (segment->x1 != segment->x2)
         {
@@ -3630,19 +3731,22 @@ MagickExport MagickBooleanType PlasmaImageProxy(Image *image,
             Right pixel.
           */
           x=(ssize_t) ceil(segment->x2-0.5);
-          (void) GetOneCacheViewVirtualPixel(image_view,x,(ssize_t)
-            ceil(segment->y1-0.5),&u,exception);
-          (void) GetOneCacheViewVirtualPixel(image_view,x,(ssize_t)
-            ceil(segment->y2-0.5),&v,exception);
+          u=GetCacheViewVirtualPixels(u_view,x,(ssize_t) ceil(segment->y1-0.5),
+            1,1,exception);
+          v=GetCacheViewVirtualPixels(v_view,x,(ssize_t) ceil(segment->y2-0.5),
+            1,1,exception);
           q=QueueCacheViewAuthenticPixels(image_view,x,y_mid,1,1,exception);
-          if (q == (const Quantum *) NULL)
+          if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
+              (q == (Quantum *) NULL))
             return(MagickTrue);
-          SetPixelRed(image,PlasmaPixel(random_info,(MagickRealType)
-            (u.red+v.red)/2.0,plasma),q);
-          SetPixelGreen(image,PlasmaPixel(random_info,(MagickRealType)
-            (u.green+v.green)/2.0,plasma),q);
-          SetPixelBlue(image,PlasmaPixel(random_info,(MagickRealType)
-            (u.blue+v.blue)/2.0,plasma),q);
+          for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+          {
+            channel=GetPixelChannelMapChannel(image,i);
+            traits=GetPixelChannelMapTraits(image,channel);
+            if (traits == UndefinedPixelTrait)
+              continue;
+            q[i]=PlasmaPixel(random_info,(u[channel]+v[channel])/2.0,plasma);
+          }
           (void) SyncCacheViewAuthenticPixels(image_view,exception);
         }
     }
@@ -3650,88 +3754,91 @@ MagickExport MagickBooleanType PlasmaImageProxy(Image *image,
     {
       if ((segment->x1 != (double) x_mid) || (segment->y2 != (double) y_mid))
         {
-          register Quantum
-            *restrict q;
-
           /*
             Bottom pixel.
           */
           y=(ssize_t) ceil(segment->y2-0.5);
-          (void) GetOneCacheViewVirtualPixel(image_view,(ssize_t)
-            ceil(segment->x1-0.5),y,&u,exception);
-          (void) GetOneCacheViewVirtualPixel(image_view,(ssize_t)
-            ceil(segment->x2-0.5),y,&v,exception);
+          u=GetCacheViewVirtualPixels(u_view,(ssize_t) ceil(segment->x1-0.5),y,
+            1,1,exception);
+          v=GetCacheViewVirtualPixels(v_view,(ssize_t) ceil(segment->x2-0.5),y,
+            1,1,exception);
           q=QueueCacheViewAuthenticPixels(image_view,x_mid,y,1,1,exception);
-          if (q == (const Quantum *) NULL)
+          if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
+              (q == (Quantum *) NULL))
             return(MagickTrue);
-          SetPixelRed(image,PlasmaPixel(random_info,(MagickRealType)
-            (u.red+v.red)/2.0,plasma),q);
-          SetPixelGreen(image,PlasmaPixel(random_info,(MagickRealType)
-            (u.green+v.green)/2.0,plasma),q);
-          SetPixelBlue(image,PlasmaPixel(random_info,(MagickRealType)
-            (u.blue+v.blue)/2.0,plasma),q);
+          for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+          {
+            channel=GetPixelChannelMapChannel(image,i);
+            traits=GetPixelChannelMapTraits(image,channel);
+            if (traits == UndefinedPixelTrait)
+              continue;
+            q[i]=PlasmaPixel(random_info,(u[channel]+v[channel])/2.0,plasma);
+          }
           (void) SyncCacheViewAuthenticPixels(image_view,exception);
         }
       if (segment->y1 != segment->y2)
         {
-          register Quantum
-            *restrict q;
-
           /*
             Top pixel.
           */
           y=(ssize_t) ceil(segment->y1-0.5);
-          (void) GetOneCacheViewVirtualPixel(image_view,(ssize_t)
-            ceil(segment->x1-0.5),y,&u,exception);
-          (void) GetOneCacheViewVirtualPixel(image_view,(ssize_t)
-            ceil(segment->x2-0.5),y,&v,exception);
+          u=GetCacheViewVirtualPixels(u_view,(ssize_t) ceil(segment->x1-0.5),y,
+            1,1,exception);
+          v=GetCacheViewVirtualPixels(v_view,(ssize_t) ceil(segment->x2-0.5),y,
+            1,1,exception);
           q=QueueCacheViewAuthenticPixels(image_view,x_mid,y,1,1,exception);
-          if (q == (const Quantum *) NULL)
+          if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
+              (q == (Quantum *) NULL))
             return(MagickTrue);
-          SetPixelRed(image,PlasmaPixel(random_info,(MagickRealType)
-            (u.red+v.red)/2.0,plasma),q);
-          SetPixelGreen(image,PlasmaPixel(random_info,(MagickRealType)
-            (u.green+v.green)/2.0,plasma),q);
-          SetPixelBlue(image,PlasmaPixel(random_info,(MagickRealType)
-            (u.blue+v.blue)/2.0,plasma),q);
+          for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+          {
+            channel=GetPixelChannelMapChannel(image,i);
+            traits=GetPixelChannelMapTraits(image,channel);
+            if (traits == UndefinedPixelTrait)
+              continue;
+            q[i]=PlasmaPixel(random_info,(u[channel]+v[channel])/2.0,plasma);
+          }
           (void) SyncCacheViewAuthenticPixels(image_view,exception);
         }
     }
   if ((segment->x1 != segment->x2) || (segment->y1 != segment->y2))
     {
-      register Quantum
-        *restrict q;
-
       /*
         Middle pixel.
       */
       x=(ssize_t) ceil(segment->x1-0.5);
       y=(ssize_t) ceil(segment->y1-0.5);
-      (void) GetOneVirtualPixel(image,x,y,&u,exception);
+      u=GetCacheViewVirtualPixels(u_view,x,y,1,1,exception);
       x=(ssize_t) ceil(segment->x2-0.5);
       y=(ssize_t) ceil(segment->y2-0.5);
-      (void) GetOneCacheViewVirtualPixel(image_view,x,y,&v,exception);
+      v=GetCacheViewVirtualPixels(v_view,x,y,1,1,exception);
       q=QueueCacheViewAuthenticPixels(image_view,x_mid,y_mid,1,1,exception);
-      if (q == (const Quantum *) NULL)
+      if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
+          (q == (Quantum *) NULL))
         return(MagickTrue);
-      SetPixelRed(image,PlasmaPixel(random_info,(MagickRealType)
-        (u.red+v.red)/2.0,plasma),q);
-      SetPixelGreen(image,PlasmaPixel(random_info,(MagickRealType)
-        (u.green+v.green)/2.0,plasma),q);
-      SetPixelBlue(image,PlasmaPixel(random_info,(MagickRealType)
-        (u.blue+v.blue)/2.0,plasma),q);
+      for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+      {
+        channel=GetPixelChannelMapChannel(image,i);
+        traits=GetPixelChannelMapTraits(image,channel);
+        if (traits == UndefinedPixelTrait)
+          continue;
+        q[i]=PlasmaPixel(random_info,(u[channel]+v[channel])/2.0,plasma);
+      }
       (void) SyncCacheViewAuthenticPixels(image_view,exception);
     }
   if (((segment->x2-segment->x1) < 3.0) && ((segment->y2-segment->y1) < 3.0))
     return(MagickTrue);
   return(MagickFalse);
 }
-\f
+
 MagickExport MagickBooleanType PlasmaImage(Image *image,
-  const SegmentInfo *segment,size_t attenuate,size_t depth)
+  const SegmentInfo *segment,size_t attenuate,size_t depth,
+  ExceptionInfo *exception)
 {
   CacheView
-    *image_view;
+    *image_view,
+    *u_view,
+    *v_view;
 
   MagickBooleanType
     status;
@@ -3745,12 +3852,17 @@ MagickExport MagickBooleanType PlasmaImage(Image *image,
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
-  if (SetImageStorageClass(image,DirectClass,&image->exception) == MagickFalse)
+  if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
     return(MagickFalse);
   image_view=AcquireCacheView(image);
+  u_view=AcquireCacheView(image);
+  v_view=AcquireCacheView(image);
   random_info=AcquireRandomInfo();
-  status=PlasmaImageProxy(image,image_view,random_info,segment,attenuate,depth);
+  status=PlasmaImageProxy(image,image_view,u_view,v_view,random_info,segment,
+    attenuate,depth,exception);
   random_info=DestroyRandomInfo(random_info);
+  v_view=DestroyCacheView(v_view);
+  u_view=DestroyCacheView(u_view);
   image_view=DestroyCacheView(image_view);
   return(status);
 }
@@ -3771,7 +3883,8 @@ MagickExport MagickBooleanType PlasmaImage(Image *image,
 %  The format of the AnnotateImage method is:
 %
 %      Image *PolaroidImage(const Image *image,const DrawInfo *draw_info,
-%        const double angle,ExceptionInfo exception)
+%        const char *caption,const double angle,
+%        const PixelInterpolateMethod method,ExceptionInfo exception)
 %
 %  A description of each parameter follows:
 %
@@ -3779,17 +3892,19 @@ MagickExport MagickBooleanType PlasmaImage(Image *image,
 %
 %    o draw_info: the draw info.
 %
+%    o caption: the Polaroid caption.
+%
 %    o angle: Apply the effect along this angle.
 %
+%    o method: the pixel interpolation method.
+%
 %    o exception: return any errors or warnings in this structure.
 %
 */
 MagickExport Image *PolaroidImage(const Image *image,const DrawInfo *draw_info,
-  const double angle,ExceptionInfo *exception)
+  const char *caption,const double angle,const PixelInterpolateMethod method,
+  ExceptionInfo *exception)
 {
-  const char
-    *value;
-
   Image
     *bend_image,
     *caption_image,
@@ -3818,12 +3933,11 @@ MagickExport Image *PolaroidImage(const Image *image,const DrawInfo *draw_info,
     image->rows)/25.0,10.0);
   height=image->rows+2*quantum;
   caption_image=(Image *) NULL;
-  value=GetImageProperty(image,"Caption");
-  if (value != (const char *) NULL)
+  if (caption != (const char *) NULL)
     {
       char
-        *caption,
-        geometry[MaxTextExtent];
+        geometry[MaxTextExtent],
+        *text;
 
       DrawInfo
         *annotate_info;
@@ -3844,30 +3958,30 @@ MagickExport Image *PolaroidImage(const Image *image,const DrawInfo *draw_info,
       if (caption_image == (Image *) NULL)
         return((Image *) NULL);
       annotate_info=CloneDrawInfo((const ImageInfo *) NULL,draw_info);
-      caption=InterpretImageProperties((ImageInfo *) NULL,(Image *) image,
-        value);
-      (void) CloneString(&annotate_info->text,caption);
+      text=InterpretImageProperties((ImageInfo *) NULL,(Image *) image,caption,
+        exception);
+      (void) CloneString(&annotate_info->text,text);
       count=FormatMagickCaption(caption_image,annotate_info,MagickTrue,&metrics,
-        &caption);
-      status=SetImageExtent(caption_image,image->columns,(size_t)
-        ((count+1)*(metrics.ascent-metrics.descent)+0.5),exception);
+        &text,exception);
+      status=SetImageExtent(caption_image,image->columns,(size_t) ((count+1)*
+        (metrics.ascent-metrics.descent)+0.5),exception);
       if (status == MagickFalse)
         caption_image=DestroyImage(caption_image);
       else
         {
           caption_image->background_color=image->border_color;
-          (void) SetImageBackgroundColor(caption_image);
-          (void) CloneString(&annotate_info->text,caption);
+          (void) SetImageBackgroundColor(caption_image,exception);
+          (void) CloneString(&annotate_info->text,text);
           (void) FormatLocaleString(geometry,MaxTextExtent,"+0+%g",
             metrics.ascent);
           if (annotate_info->gravity == UndefinedGravity)
             (void) CloneString(&annotate_info->geometry,AcquireString(
               geometry));
-          (void) AnnotateImage(caption_image,annotate_info);
+          (void) AnnotateImage(caption_image,annotate_info,exception);
           height+=caption_image->rows;
         }
       annotate_info=DestroyDrawInfo(annotate_info);
-      caption=DestroyString(caption);
+      text=DestroyString(text);
     }
   picture_image=CloneImage(image,image->columns+2*quantum,height,MagickTrue,
     exception);
@@ -3878,15 +3992,17 @@ MagickExport Image *PolaroidImage(const Image *image,const DrawInfo *draw_info,
       return((Image *) NULL);
     }
   picture_image->background_color=image->border_color;
-  (void) SetImageBackgroundColor(picture_image);
-  (void) CompositeImage(picture_image,OverCompositeOp,image,quantum,quantum);
+  (void) SetImageBackgroundColor(picture_image,exception);
+  (void) CompositeImage(picture_image,image,OverCompositeOp,MagickTrue,quantum,
+    quantum,exception);
   if (caption_image != (Image *) NULL)
     {
-      (void) CompositeImage(picture_image,OverCompositeOp,caption_image,
-        quantum,(ssize_t) (image->rows+3*quantum/2));
+      (void) CompositeImage(picture_image,caption_image,OverCompositeOp,
+        MagickTrue,quantum,(ssize_t) (image->rows+3*quantum/2),exception);
       caption_image=DestroyImage(caption_image);
     }
-  (void) QueryColorDatabase("none",&picture_image->background_color,exception);
+  (void) QueryColorCompliance("none",AllCompliance,
+    &picture_image->background_color,exception);
   (void) SetImageAlphaChannel(picture_image,OpaqueAlphaChannel,exception);
   rotate_image=RotateImage(picture_image,90.0,exception);
   picture_image=DestroyImage(picture_image);
@@ -3894,11 +4010,10 @@ MagickExport Image *PolaroidImage(const Image *image,const DrawInfo *draw_info,
     return((Image *) NULL);
   picture_image=rotate_image;
   bend_image=WaveImage(picture_image,0.01*picture_image->rows,2.0*
-    picture_image->columns,exception);
+    picture_image->columns,method,exception);
   picture_image=DestroyImage(picture_image);
   if (bend_image == (Image *) NULL)
     return((Image *) NULL);
-  InheritException(&bend_image->exception,exception);
   picture_image=bend_image;
   rotate_image=RotateImage(picture_image,-90.0,exception);
   picture_image=DestroyImage(picture_image);
@@ -3921,10 +4036,11 @@ MagickExport Image *PolaroidImage(const Image *image,const DrawInfo *draw_info,
       return(picture_image);
     }
   polaroid_image=flop_image;
-  (void) CompositeImage(polaroid_image,OverCompositeOp,picture_image,
-    (ssize_t) (-0.01*picture_image->columns/2.0),0L);
+  (void) CompositeImage(polaroid_image,picture_image,OverCompositeOp,
+    MagickTrue,(ssize_t) (-0.01*picture_image->columns/2.0),0L,exception);
   picture_image=DestroyImage(picture_image);
-  (void) QueryColorDatabase("none",&polaroid_image->background_color,exception);
+  (void) QueryColorCompliance("none",AllCompliance,
+    &polaroid_image->background_color,exception);
   rotate_image=RotateImage(polaroid_image,angle,exception);
   polaroid_image=DestroyImage(polaroid_image);
   if (rotate_image == (Image *) NULL)
@@ -3998,7 +4114,7 @@ MagickExport Image *SepiaToneImage(const Image *image,const double threshold,
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  sepia_image=CloneImage(image,image->columns,image->rows,MagickTrue,exception);
+  sepia_image=CloneImage(image,0,0,MagickTrue,exception);
   if (sepia_image == (Image *) NULL)
     return((Image *) NULL);
   if (SetImageStorageClass(sepia_image,DirectClass,exception) == MagickFalse)
@@ -4014,7 +4130,7 @@ MagickExport Image *SepiaToneImage(const Image *image,const double threshold,
   image_view=AcquireCacheView(image);
   sepia_view=AcquireCacheView(sepia_image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
@@ -4030,7 +4146,7 @@ MagickExport Image *SepiaToneImage(const Image *image,const double threshold,
     if (status == MagickFalse)
       continue;
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
-    q=QueueCacheViewAuthenticPixels(sepia_view,0,y,sepia_image->columns,1,
+    q=GetCacheViewAuthenticPixels(sepia_view,0,y,sepia_image->columns,1,
       exception);
     if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
       {
@@ -4068,7 +4184,7 @@ MagickExport Image *SepiaToneImage(const Image *image,const double threshold,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_SepiaToneImage)
+        #pragma omp critical (MagickCore_SepiaToneImage)
 #endif
         proceed=SetImageProgress(image,SepiaToneImageTag,progress++,
           image->rows);
@@ -4100,7 +4216,7 @@ MagickExport Image *SepiaToneImage(const Image *image,const double threshold,
 %
 %  The format of the ShadowImage method is:
 %
-%      Image *ShadowImage(const Image *image,const double opacity,
+%      Image *ShadowImage(const Image *image,const double alpha,
 %        const double sigma,const ssize_t x_offset,const ssize_t y_offset,
 %        ExceptionInfo *exception)
 %
@@ -4108,7 +4224,7 @@ MagickExport Image *SepiaToneImage(const Image *image,const double threshold,
 %
 %    o image: the image.
 %
-%    o opacity: percentage transparency.
+%    o alpha: percentage transparency.
 %
 %    o sigma: the standard deviation of the Gaussian, in pixels.
 %
@@ -4119,14 +4235,17 @@ MagickExport Image *SepiaToneImage(const Image *image,const double threshold,
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *ShadowImage(const Image *image,const double opacity,
+MagickExport Image *ShadowImage(const Image *image,const double alpha,
   const double sigma,const ssize_t x_offset,const ssize_t y_offset,
   ExceptionInfo *exception)
 {
 #define ShadowImageTag  "Shadow/Image"
 
   CacheView
-    *border_view;
+    *image_view;
+
+  ChannelType
+    channel_mask;
 
   Image
     *border_image,
@@ -4136,9 +4255,6 @@ MagickExport Image *ShadowImage(const Image *image,const double opacity,
   MagickBooleanType
     status;
 
-  MagickOffsetType
-    progress;
-
   RectangleInfo
     border_info;
 
@@ -4154,14 +4270,18 @@ MagickExport Image *ShadowImage(const Image *image,const double opacity,
   clone_image=CloneImage(image,0,0,MagickTrue,exception);
   if (clone_image == (Image *) NULL)
     return((Image *) NULL);
-  (void) SetImageVirtualPixelMethod(clone_image,EdgeVirtualPixelMethod);
-  clone_image->compose=OverCompositeOp;
+  if (IsGrayColorspace(image->colorspace) != MagickFalse)
+    (void) TransformImageColorspace(clone_image,sRGBColorspace,exception);
+  (void) SetImageVirtualPixelMethod(clone_image,EdgeVirtualPixelMethod,
+    exception);
   border_info.width=(size_t) floor(2.0*sigma+0.5);
   border_info.height=(size_t) floor(2.0*sigma+0.5);
   border_info.x=0;
   border_info.y=0;
-  (void) QueryColorDatabase("none",&clone_image->border_color,exception);
-  border_image=BorderImage(clone_image,&border_info,exception);
+  (void) QueryColorCompliance("none",AllCompliance,&clone_image->border_color,
+    exception);
+  clone_image->matte=MagickTrue;
+  border_image=BorderImage(clone_image,&border_info,OverCompositeOp,exception);
   clone_image=DestroyImage(clone_image);
   if (border_image == (Image *) NULL)
     return((Image *) NULL);
@@ -4171,63 +4291,51 @@ MagickExport Image *ShadowImage(const Image *image,const double opacity,
     Shadow image.
   */
   status=MagickTrue;
-  progress=0;
-  border_view=AcquireCacheView(border_image);
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
-#endif
+  image_view=AcquireCacheView(border_image);
   for (y=0; y < (ssize_t) border_image->rows; y++)
   {
-    register ssize_t
-      x;
+    PixelInfo
+      background_color;
 
     register Quantum
       *restrict q;
 
+    register ssize_t
+      x;
+
     if (status == MagickFalse)
       continue;
-    q=GetCacheViewAuthenticPixels(border_view,0,y,border_image->columns,1,
+    q=QueueCacheViewAuthenticPixels(image_view,0,y,border_image->columns,1,
       exception);
-    if (q == (const Quantum *) NULL)
+    if (q == (Quantum *) NULL)
       {
         status=MagickFalse;
         continue;
       }
+    background_color=border_image->background_color;
+    background_color.matte=MagickTrue;
     for (x=0; x < (ssize_t) border_image->columns; x++)
     {
-      SetPixelRed(border_image,border_image->background_color.red,q);
-      SetPixelGreen(border_image,border_image->background_color.green,q);
-      SetPixelBlue(border_image,border_image->background_color.blue,q);
-      if (border_image->matte == MagickFalse)
-        SetPixelAlpha(border_image,border_image->background_color.alpha,q);
-      else
-        SetPixelAlpha(border_image,ClampToQuantum((MagickRealType)
-          (GetPixelAlpha(border_image,q)*opacity/100.0)),q);
+      if (border_image->matte != MagickFalse)
+        background_color.alpha=GetPixelAlpha(border_image,q)*alpha/100.0;
+      SetPixelInfoPixel(border_image,&background_color,q);
       q+=GetPixelChannels(border_image);
     }
-    if (SyncCacheViewAuthenticPixels(border_view,exception) == MagickFalse)
+    if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
       status=MagickFalse;
-    if (border_image->progress_monitor != (MagickProgressMonitor) NULL)
-      {
-        MagickBooleanType
-          proceed;
-
-#if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_ShadowImage)
-#endif
-        proceed=SetImageProgress(border_image,ShadowImageTag,progress++,
-          border_image->rows);
-        if (proceed == MagickFalse)
-          status=MagickFalse;
-      }
   }
-  border_view=DestroyCacheView(border_view);
-  PushPixelChannelMap(border_image,AlphaChannel);
+  image_view=DestroyCacheView(image_view);
+  if (status == MagickFalse)
+    {
+      border_image=DestroyImage(border_image);
+      return((Image *) NULL);
+    }
+  channel_mask=SetPixelChannelMask(border_image,AlphaChannel);
   shadow_image=BlurImage(border_image,0.0,sigma,exception);
-  PopPixelChannelMap(border_image);
   border_image=DestroyImage(border_image);
   if (shadow_image == (Image *) NULL)
     return((Image *) NULL);
+  (void) SetPixelChannelMapMask(shadow_image,channel_mask);
   if (shadow_image->page.width == 0)
     shadow_image->page.width=shadow_image->columns;
   if (shadow_image->page.height == 0)
@@ -4270,7 +4378,7 @@ MagickExport Image *ShadowImage(const Image *image,const double opacity,
 %
 %    o sigma: the standard deviation of the Gaussian, in pixels.
 %
-%    o angle: Apply the effect along this angle.
+%    o angle: apply the effect along this angle.
 %
 %    o exception: return any errors or warnings in this structure.
 %
@@ -4289,11 +4397,9 @@ MagickExport Image *SketchImage(const Image *image,const double radius,
     *sketch_image;
 
   MagickBooleanType
+    concurrent,
     status;
 
-  PixelInfo
-    zero;
-
   RandomInfo
     **restrict random_info;
 
@@ -4308,20 +4414,18 @@ MagickExport Image *SketchImage(const Image *image,const double radius,
   if (random_image == (Image *) NULL)
     return((Image *) NULL);
   status=MagickTrue;
-  GetPixelInfo(random_image,&zero);
   random_info=AcquireRandomInfoThreadSet();
+  concurrent=GetRandomSecretKey(random_info[0]) == ~0UL ? MagickTrue :
+    MagickFalse;
   random_view=AcquireCacheView(random_image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(status)
+  #pragma omp parallel for schedule(static,4) shared(status) omp_concurrent(concurrent)
 #endif
   for (y=0; y < (ssize_t) random_image->rows; y++)
   {
     const int
       id = GetOpenMPThreadId();
 
-    PixelInfo
-      pixel;
-
     register ssize_t
       x;
 
@@ -4332,21 +4436,39 @@ MagickExport Image *SketchImage(const Image *image,const double radius,
       continue;
     q=QueueCacheViewAuthenticPixels(random_view,0,y,random_image->columns,1,
       exception);
-    if (q == (const Quantum *) NULL)
+    if (q == (Quantum *) NULL)
       {
         status=MagickFalse;
         continue;
       }
-    pixel=zero;
     for (x=0; x < (ssize_t) random_image->columns; x++)
     {
-      pixel.red=(MagickRealType) (QuantumRange*
-        GetPseudoRandomValue(random_info[id]));
-      pixel.green=pixel.red;
-      pixel.blue=pixel.red;
-      if (image->colorspace == CMYKColorspace)
-        pixel.black=pixel.red;
-      SetPixelPixelInfo(random_image,&pixel,q);
+      MagickRealType
+        value;
+
+      register ssize_t
+        i;
+
+      if (GetPixelMask(random_image,q) != 0)
+        {
+          q+=GetPixelChannels(random_image);
+          continue;
+        }
+      value=GetPseudoRandomValue(random_info[id]);
+      for (i=0; i < (ssize_t) GetPixelChannels(random_image); i++)
+      {
+        PixelChannel
+          channel;
+
+        PixelTrait
+          traits;
+
+        channel=GetPixelChannelMapChannel(image,i);
+        traits=GetPixelChannelMapTraits(image,channel);
+        if (traits == UndefinedPixelTrait)
+          continue;
+        q[i]=ClampToQuantum(QuantumRange*value);
+      }
       q+=GetPixelChannels(random_image);
     }
     if (SyncCacheViewAuthenticPixels(random_view,exception) == MagickFalse)
@@ -4363,20 +4485,21 @@ MagickExport Image *SketchImage(const Image *image,const double radius,
   random_image=DestroyImage(random_image);
   if (blur_image == (Image *) NULL)
     return((Image *) NULL);
-  dodge_image=EdgeImage(blur_image,radius,exception);
+  dodge_image=EdgeImage(blur_image,radius,1.0,exception);
   blur_image=DestroyImage(blur_image);
   if (dodge_image == (Image *) NULL)
     return((Image *) NULL);
   (void) NormalizeImage(dodge_image,exception);
   (void) NegateImage(dodge_image,MagickFalse,exception);
-  (void) TransformImage(&dodge_image,(char *) NULL,"50%");
+  (void) TransformImage(&dodge_image,(char *) NULL,"50%",exception);
   sketch_image=CloneImage(image,0,0,MagickTrue,exception);
   if (sketch_image == (Image *) NULL)
     {
       dodge_image=DestroyImage(dodge_image);
       return((Image *) NULL);
     }
-  (void) CompositeImage(sketch_image,ColorDodgeCompositeOp,dodge_image,0,0);
+  (void) CompositeImage(sketch_image,dodge_image,ColorDodgeCompositeOp,
+    MagickTrue,0,0,exception);
   dodge_image=DestroyImage(dodge_image);
   blend_image=CloneImage(image,0,0,MagickTrue,exception);
   if (blend_image == (Image *) NULL)
@@ -4385,7 +4508,8 @@ MagickExport Image *SketchImage(const Image *image,const double radius,
       return((Image *) NULL);
     }
   (void) SetImageArtifact(blend_image,"compose:args","20x80");
-  (void) CompositeImage(sketch_image,BlendCompositeOp,blend_image,0,0);
+  (void) CompositeImage(sketch_image,blend_image,BlendCompositeOp,MagickTrue,
+    0,0,exception);
   blend_image=DestroyImage(blend_image);
   return(sketch_image);
 }
@@ -4408,7 +4532,8 @@ MagickExport Image *SketchImage(const Image *image,const double radius,
 %
 %  The format of the SolarizeImage method is:
 %
-%      MagickBooleanType SolarizeImage(Image *image,const double threshold)
+%      MagickBooleanType SolarizeImage(Image *image,const double threshold,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -4416,18 +4541,17 @@ MagickExport Image *SketchImage(const Image *image,const double radius,
 %
 %    o threshold:  Define the extent of the solarization.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 MagickExport MagickBooleanType SolarizeImage(Image *image,
-  const double threshold)
+  const double threshold,ExceptionInfo *exception)
 {
 #define SolarizeImageTag  "Solarize/Image"
 
   CacheView
     *image_view;
 
-  ExceptionInfo
-    *exception;
-
   MagickBooleanType
     status;
 
@@ -4466,10 +4590,9 @@ MagickExport MagickBooleanType SolarizeImage(Image *image,
   */
   status=MagickTrue;
   progress=0;
-  exception=(&image->exception);
   image_view=AcquireCacheView(image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
@@ -4481,21 +4604,38 @@ MagickExport MagickBooleanType SolarizeImage(Image *image,
 
     if (status == MagickFalse)
       continue;
-    q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
-      exception);
-    if (q == (const Quantum *) NULL)
+    q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
+    if (q == (Quantum *) NULL)
       {
         status=MagickFalse;
         continue;
       }
     for (x=0; x < (ssize_t) image->columns; x++)
     {
-      if ((MagickRealType) GetPixelRed(image,q) > threshold)
-        SetPixelRed(image,QuantumRange-GetPixelRed(image,q),q);
-      if ((MagickRealType) GetPixelGreen(image,q) > threshold)
-        SetPixelGreen(image,QuantumRange-GetPixelGreen(image,q),q);
-      if ((MagickRealType) GetPixelBlue(image,q) > threshold)
-        SetPixelBlue(image,QuantumRange-GetPixelBlue(image,q),q);
+      register ssize_t
+        i;
+
+      if (GetPixelMask(image,q) != 0)
+        {
+          q+=GetPixelChannels(image);
+          continue;
+        }
+      for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+      {
+        PixelChannel
+          channel;
+
+        PixelTrait
+          traits;
+
+        channel=GetPixelChannelMapChannel(image,i);
+        traits=GetPixelChannelMapTraits(image,channel);
+        if ((traits == UndefinedPixelTrait) ||
+            ((traits & CopyPixelTrait) != 0))
+          continue;
+        if ((MagickRealType) q[i] > threshold)
+          q[i]=QuantumRange-q[i];
+      }
       q+=GetPixelChannels(image);
     }
     if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
@@ -4506,7 +4646,7 @@ MagickExport MagickBooleanType SolarizeImage(Image *image,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_SolarizeImage)
+        #pragma omp critical (MagickCore_SolarizeImage)
 #endif
         proceed=SetImageProgress(image,SolarizeImageTag,progress++,image->rows);
         if (proceed == MagickFalse)
@@ -4567,7 +4707,7 @@ MagickExport Image *SteganoImage(const Image *image,const Image *watermark,
   MagickBooleanType
     status;
 
-  PixelPacket
+  PixelInfo
     pixel;
 
   register Quantum
@@ -4601,12 +4741,12 @@ MagickExport Image *SteganoImage(const Image *image,const Image *watermark,
   stegano_image=CloneImage(image,0,0,MagickTrue,exception);
   if (stegano_image == (Image *) NULL)
     return((Image *) NULL);
+  stegano_image->depth=MAGICKCORE_QUANTUM_DEPTH;
   if (SetImageStorageClass(stegano_image,DirectClass,exception) == MagickFalse)
     {
       stegano_image=DestroyImage(stegano_image);
       return((Image *) NULL);
     }
-  stegano_image->depth=MAGICKCORE_QUANTUM_DEPTH;
   /*
     Hide watermark in low-order bits of image.
   */
@@ -4614,7 +4754,7 @@ MagickExport Image *SteganoImage(const Image *image,const Image *watermark,
   i=0;
   j=0;
   depth=stegano_image->depth;
-  k=image->offset;
+  k=stegano_image->offset;
   status=MagickTrue;
   watermark_view=AcquireCacheView(watermark);
   stegano_view=AcquireCacheView(stegano_image);
@@ -4624,32 +4764,37 @@ MagickExport Image *SteganoImage(const Image *image,const Image *watermark,
     {
       for (x=0; (x < (ssize_t) watermark->columns) && (j < (ssize_t) depth); x++)
       {
-        (void) GetOneCacheViewVirtualPixel(watermark_view,x,y,&pixel,exception);
-        if ((k/(ssize_t) stegano_image->columns) >= (ssize_t) stegano_image->rows)
+        ssize_t
+          offset;
+
+        (void) GetOneCacheViewVirtualPixelInfo(watermark_view,x,y,&pixel,
+          exception);
+        offset=k/(ssize_t) stegano_image->columns;
+        if (offset >= (ssize_t) stegano_image->rows)
           break;
         q=GetCacheViewAuthenticPixels(stegano_view,k % (ssize_t)
           stegano_image->columns,k/(ssize_t) stegano_image->columns,1,1,
           exception);
-        if (q == (const Quantum *) NULL)
+        if (q == (Quantum *) NULL)
           break;
         switch (c)
         {
           case 0:
           {
-            SetPixelRed(image,SetBit(GetPixelRed(image,q),j,GetBit(
-              GetPixelPacketIntensity(&pixel),i)),q);
+            SetPixelRed(stegano_image,SetBit(GetPixelRed(stegano_image,q),j,
+              GetBit(GetPixelInfoIntensity(&pixel),i)),q);
             break;
           }
           case 1:
           {
-            SetPixelGreen(image,SetBit(GetPixelGreen(image,q),j,GetBit(
-              GetPixelPacketIntensity(&pixel),i)),q);
+            SetPixelGreen(stegano_image,SetBit(GetPixelGreen(stegano_image,q),j,
+              GetBit(GetPixelInfoIntensity(&pixel),i)),q);
             break;
           }
           case 2:
           {
-            SetPixelBlue(image,SetBit(GetPixelBlue(image,q),j,GetBit(
-              GetPixelPacketIntensity(&pixel),i)),q);
+            SetPixelBlue(stegano_image,SetBit(GetPixelBlue(stegano_image,q),j,
+              GetBit(GetPixelInfoIntensity(&pixel),i)),q);
             break;
           }
         }
@@ -4661,7 +4806,7 @@ MagickExport Image *SteganoImage(const Image *image,const Image *watermark,
         k++;
         if (k == (ssize_t) (stegano_image->columns*stegano_image->columns))
           k=0;
-        if (k == image->offset)
+        if (k == stegano_image->offset)
           j++;
       }
     }
@@ -4678,8 +4823,6 @@ MagickExport Image *SteganoImage(const Image *image,const Image *watermark,
   }
   stegano_view=DestroyCacheView(stegano_view);
   watermark_view=DestroyCacheView(watermark_view);
-  if (stegano_image->storage_class == PseudoClass)
-    (void) SyncImage(stegano_image);
   if (status == MagickFalse)
     {
       stegano_image=DestroyImage(stegano_image);
@@ -4797,19 +4940,20 @@ MagickExport Image *StereoAnaglyphImage(const Image *left_image,
       exception);
     q=GetVirtualPixels(right_image,0,y,right_image->columns,1,exception);
     r=QueueAuthenticPixels(stereo_image,0,y,stereo_image->columns,1,exception);
-    if ((p == (const Quantum *) NULL) ||
-        (q == (const Quantum *) NULL) || (r == (Quantum *) NULL))
+    if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL) ||
+        (r == (Quantum *) NULL))
       break;
     for (x=0; x < (ssize_t) stereo_image->columns; x++)
     {
       SetPixelRed(image,GetPixelRed(left_image,p),r);
-      SetPixelGreen(image,GetPixelGreen(left_image,q),r);
-      SetPixelBlue(image,GetPixelBlue(left_image,q),r);
-      SetPixelAlpha(image,(GetPixelAlpha(left_image,p)+
-        GetPixelAlpha(left_image,q))/2,r);
+      SetPixelGreen(image,GetPixelGreen(right_image,q),r);
+      SetPixelBlue(image,GetPixelBlue(right_image,q),r);
+      if ((GetPixelAlphaTraits(stereo_image) & CopyPixelTrait) != 0)
+        SetPixelAlpha(image,(GetPixelAlpha(left_image,p)+
+          GetPixelAlpha(right_image,q))/2,r);
       p+=GetPixelChannels(left_image);
-      q++;
-      r++;
+      q+=GetPixelChannels(right_image);
+      r+=GetPixelChannels(stereo_image);
     }
     if (SyncAuthenticPixels(stereo_image,exception) == MagickFalse)
       break;
@@ -4850,7 +4994,7 @@ MagickExport Image *StereoAnaglyphImage(const Image *left_image,
 %  The format of the SwirlImage method is:
 %
 %      Image *SwirlImage(const Image *image,double degrees,
-%        ExceptionInfo *exception)
+%        const PixelInterpolateMethod method,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -4858,11 +5002,13 @@ MagickExport Image *StereoAnaglyphImage(const Image *left_image,
 %
 %    o degrees: Define the tightness of the swirling effect.
 %
+%    o method: the pixel interpolation method.
+%
 %    o exception: return any errors or warnings in this structure.
 %
 */
 MagickExport Image *SwirlImage(const Image *image,double degrees,
-  ExceptionInfo *exception)
+  const PixelInterpolateMethod method,ExceptionInfo *exception)
 {
 #define SwirlImageTag  "Swirl/Image"
 
@@ -4879,9 +5025,6 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
   MagickOffsetType
     progress;
 
-  PixelInfo
-    zero;
-
   MagickRealType
     radius;
 
@@ -4901,7 +5044,7 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  swirl_image=CloneImage(image,0,0,MagickTrue,exception);
+  swirl_image=CloneImage(image,image->columns,image->rows,MagickTrue,exception);
   if (swirl_image == (Image *) NULL)
     return((Image *) NULL);
   if (SetImageStorageClass(swirl_image,DirectClass,exception) == MagickFalse)
@@ -4930,23 +5073,22 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
   */
   status=MagickTrue;
   progress=0;
-  GetPixelInfo(swirl_image,&zero);
   image_view=AcquireCacheView(image);
   swirl_view=AcquireCacheView(swirl_image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
-    PixelInfo
-      pixel;
-
     MagickRealType
       distance;
 
     PointInfo
       delta;
 
+    register const Quantum
+      *restrict p;
+
     register ssize_t
       x;
 
@@ -4955,23 +5097,52 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
 
     if (status == MagickFalse)
       continue;
-    q=GetCacheViewAuthenticPixels(swirl_view,0,y,swirl_image->columns,1,
+    p=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
+    q=QueueCacheViewAuthenticPixels(swirl_view,0,y,swirl_image->columns,1,
       exception);
-    if (q == (const Quantum *) NULL)
+    if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
       {
         status=MagickFalse;
         continue;
       }
     delta.y=scale.y*(double) (y-center.y);
-    pixel=zero;
     for (x=0; x < (ssize_t) image->columns; x++)
     {
       /*
         Determine if the pixel is within an ellipse.
       */
+      if (GetPixelMask(image,p) != 0)
+        {
+          p+=GetPixelChannels(image);
+          q+=GetPixelChannels(swirl_image);
+          continue;
+        }
       delta.x=scale.x*(double) (x-center.x);
       distance=delta.x*delta.x+delta.y*delta.y;
-      if (distance < (radius*radius))
+      if (distance >= (radius*radius))
+        {
+          register ssize_t
+            i;
+
+          for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+          {
+            PixelChannel
+              channel;
+
+            PixelTrait
+              swirl_traits,
+              traits;
+
+            channel=GetPixelChannelMapChannel(image,i);
+            traits=GetPixelChannelMapTraits(image,channel);
+            swirl_traits=GetPixelChannelMapTraits(swirl_image,channel);
+            if ((traits == UndefinedPixelTrait) ||
+                (swirl_traits == UndefinedPixelTrait))
+              continue;
+            SetPixelChannel(swirl_image,channel,p[i],q);
+          }
+        }
+      else
         {
           MagickRealType
             cosine,
@@ -4984,12 +5155,11 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
           factor=1.0-sqrt((double) distance)/radius;
           sine=sin((double) (degrees*factor*factor));
           cosine=cos((double) (degrees*factor*factor));
-          (void) InterpolatePixelInfo(image,image_view,
-            UndefinedInterpolatePixel,(double) ((cosine*delta.x-sine*delta.y)/
-            scale.x+center.x),(double) ((sine*delta.x+cosine*delta.y)/scale.y+
-            center.y),&pixel,exception);
-          SetPixelPixelInfo(swirl_image,&pixel,q);
+          status=InterpolatePixelChannels(image,image_view,swirl_image,method,
+            ((cosine*delta.x-sine*delta.y)/scale.x+center.x),(double)
+            ((sine*delta.x+cosine*delta.y)/scale.y+center.y),q,exception);
         }
+      p+=GetPixelChannels(image);
       q+=GetPixelChannels(swirl_image);
     }
     if (SyncCacheViewAuthenticPixels(swirl_view,exception) == MagickFalse)
@@ -5000,7 +5170,7 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_SwirlImage)
+        #pragma omp critical (MagickCore_SwirlImage)
 #endif
         proceed=SetImageProgress(image,SwirlImageTag,progress++,image->rows);
         if (proceed == MagickFalse)
@@ -5031,22 +5201,22 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
 %
 %  The format of the TintImage method is:
 %
-%      Image *TintImage(const Image *image,const char *opacity,
-%        const PixelPacket tint,ExceptionInfo *exception)
+%      Image *TintImage(const Image *image,const char *blend,
+%        const PixelInfo *tint,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
 %    o image: the image.
 %
-%    o opacity: A color value used for tinting.
+%    o blend: A color value used for tinting.
 %
 %    o tint: A color value used for tinting.
 %
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *TintImage(const Image *image,const char *opacity,
-  const PixelPacket tint,ExceptionInfo *exception)
+MagickExport Image *TintImage(const Image *image,const char *blend,
+  const PixelInfo *tint,ExceptionInfo *exception)
 {
 #define TintImageTag  "Tint/Image"
 
@@ -5066,9 +5236,11 @@ MagickExport Image *TintImage(const Image *image,const char *opacity,
   MagickOffsetType
     progress;
 
+  MagickRealType
+    intensity;
+
   PixelInfo
-    color_vector,
-    pixel;
+    color_vector;
 
   MagickStatusType
     flags;
@@ -5093,31 +5265,42 @@ MagickExport Image *TintImage(const Image *image,const char *opacity,
       tint_image=DestroyImage(tint_image);
       return((Image *) NULL);
     }
-  if (opacity == (const char *) NULL)
+  if (blend == (const char *) NULL)
     return(tint_image);
   /*
     Determine RGB values of the color.
   */
-  flags=ParseGeometry(opacity,&geometry_info);
-  pixel.red=geometry_info.rho;
+  GetPixelInfo(image,&color_vector);
+  flags=ParseGeometry(blend,&geometry_info);
+  color_vector.red=geometry_info.rho;
+  color_vector.green=geometry_info.rho;
+  color_vector.blue=geometry_info.rho;
+  color_vector.alpha=OpaqueAlpha;
   if ((flags & SigmaValue) != 0)
-    pixel.green=geometry_info.sigma;
-  else
-    pixel.green=pixel.red;
+    color_vector.green=geometry_info.sigma;
   if ((flags & XiValue) != 0)
-    pixel.blue=geometry_info.xi;
-  else
-    pixel.blue=pixel.red;
+    color_vector.blue=geometry_info.xi;
   if ((flags & PsiValue) != 0)
-    pixel.alpha=geometry_info.psi;
-  else
-    pixel.alpha=(MagickRealType) OpaqueAlpha;
-  color_vector.red=(MagickRealType) (pixel.red*tint.red/100.0-
-    GetPixelPacketIntensity(&tint));
-  color_vector.green=(MagickRealType) (pixel.green*tint.green/100.0-
-    GetPixelPacketIntensity(&tint));
-  color_vector.blue=(MagickRealType) (pixel.blue*tint.blue/100.0-
-    GetPixelPacketIntensity(&tint));
+    color_vector.alpha=geometry_info.psi;
+  if (image->colorspace == CMYKColorspace)
+    {
+      color_vector.black=geometry_info.rho;
+      if ((flags & PsiValue) != 0)
+        color_vector.black=geometry_info.psi;
+      if ((flags & ChiValue) != 0)
+        color_vector.alpha=geometry_info.chi;
+    }
+  intensity=(MagickRealType) GetPixelInfoIntensity(tint);
+  color_vector.red=(MagickRealType) (color_vector.red*tint->red/100.0-
+    intensity);
+  color_vector.green=(MagickRealType) (color_vector.green*tint->green/100.0-
+    intensity);
+  color_vector.blue=(MagickRealType) (color_vector.blue*tint->blue/100.0-
+    intensity);
+  color_vector.black=(MagickRealType) (color_vector.black*tint->black/100.0-
+    intensity);
+  color_vector.alpha=(MagickRealType) (color_vector.alpha*tint->alpha/100.0-
+    intensity);
   /*
     Tint image.
   */
@@ -5126,7 +5309,7 @@ MagickExport Image *TintImage(const Image *image,const char *opacity,
   image_view=AcquireCacheView(image);
   tint_view=AcquireCacheView(tint_image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
@@ -5157,19 +5340,50 @@ MagickExport Image *TintImage(const Image *image,const char *opacity,
       MagickRealType
         weight;
 
+      register ssize_t
+        i;
+
+      if (GetPixelMask(image,p) != 0)
+        {
+          p+=GetPixelChannels(image);
+          q+=GetPixelChannels(tint_image);
+          continue;
+        }
+      for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+      {
+        PixelChannel
+          channel;
+
+        PixelTrait
+          tint_traits,
+          traits;
+
+        channel=GetPixelChannelMapChannel(image,i);
+        traits=GetPixelChannelMapTraits(image,channel);
+        tint_traits=GetPixelChannelMapTraits(tint_image,channel);
+        if ((traits == UndefinedPixelTrait) ||
+            (tint_traits == UndefinedPixelTrait))
+          continue;
+        if ((tint_traits & CopyPixelTrait) != 0)
+          {
+            SetPixelChannel(tint_image,channel,p[i],q);
+            continue;
+          }
+      }
+      GetPixelInfo(image,&pixel);
       weight=QuantumScale*GetPixelRed(image,p)-0.5;
       pixel.red=(MagickRealType) GetPixelRed(image,p)+color_vector.red*
         (1.0-(4.0*(weight*weight)));
-      SetPixelRed(tint_image,ClampToQuantum(pixel.red),q);
       weight=QuantumScale*GetPixelGreen(image,p)-0.5;
       pixel.green=(MagickRealType) GetPixelGreen(image,p)+color_vector.green*
         (1.0-(4.0*(weight*weight)));
-      SetPixelGreen(tint_image,ClampToQuantum(pixel.green),q);
       weight=QuantumScale*GetPixelBlue(image,p)-0.5;
       pixel.blue=(MagickRealType) GetPixelBlue(image,p)+color_vector.blue*
         (1.0-(4.0*(weight*weight)));
-      SetPixelBlue(tint_image,ClampToQuantum(pixel.blue),q);
-      SetPixelAlpha(tint_image,GetPixelAlpha(image,p),q);
+      weight=QuantumScale*GetPixelBlack(image,p)-0.5;
+      pixel.black=(MagickRealType) GetPixelBlack(image,p)+color_vector.black*
+        (1.0-(4.0*(weight*weight)));
+      SetPixelInfoPixel(tint_image,&pixel,q);
       p+=GetPixelChannels(image);
       q+=GetPixelChannels(tint_image);
     }
@@ -5181,7 +5395,7 @@ MagickExport Image *TintImage(const Image *image,const char *opacity,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_TintImage)
+        #pragma omp critical (MagickCore_TintImage)
 #endif
         proceed=SetImageProgress(image,TintImageTag,progress++,image->rows);
         if (proceed == MagickFalse)
@@ -5211,7 +5425,8 @@ MagickExport Image *TintImage(const Image *image,const char *opacity,
 %  The format of the VignetteImage method is:
 %
 %      Image *VignetteImage(const Image *image,const double radius,
-%        const double sigma,const ssize_t x,const ssize_t y,ExceptionInfo *exception)
+%        const double sigma,const ssize_t x,const ssize_t y,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -5256,23 +5471,26 @@ MagickExport Image *VignetteImage(const Image *image,const double radius,
       return((Image *) NULL);
     }
   canvas_image->matte=MagickTrue;
-  oval_image=CloneImage(canvas_image,canvas_image->columns,
-    canvas_image->rows,MagickTrue,exception);
+  oval_image=CloneImage(canvas_image,canvas_image->columns,canvas_image->rows,
+    MagickTrue,exception);
   if (oval_image == (Image *) NULL)
     {
       canvas_image=DestroyImage(canvas_image);
       return((Image *) NULL);
     }
-  (void) QueryColorDatabase("#000000",&oval_image->background_color,exception);
-  (void) SetImageBackgroundColor(oval_image);
+  (void) QueryColorCompliance("#000000",AllCompliance,
+    &oval_image->background_color,exception);
+  (void) SetImageBackgroundColor(oval_image,exception);
   draw_info=CloneDrawInfo((const ImageInfo *) NULL,(const DrawInfo *) NULL);
-  (void) QueryColorDatabase("#ffffff",&draw_info->fill,exception);
-  (void) QueryColorDatabase("#ffffff",&draw_info->stroke,exception);
-  (void) FormatLocaleString(ellipse,MaxTextExtent,
-    "ellipse %g,%g,%g,%g,0.0,360.0",image->columns/2.0,
-    image->rows/2.0,image->columns/2.0-x,image->rows/2.0-y);
+  (void) QueryColorCompliance("#ffffff",AllCompliance,&draw_info->fill,
+    exception);
+  (void) QueryColorCompliance("#ffffff",AllCompliance,&draw_info->stroke,
+    exception);
+  (void) FormatLocaleString(ellipse,MaxTextExtent,"ellipse %g,%g,%g,%g,"
+    "0.0,360.0",image->columns/2.0,image->rows/2.0,image->columns/2.0-x,
+    image->rows/2.0-y);
   draw_info->primitive=AcquireString(ellipse);
-  (void) DrawImage(oval_image,draw_info);
+  (void) DrawImage(oval_image,draw_info,exception);
   draw_info=DestroyDrawInfo(draw_info);
   blur_image=BlurImage(oval_image,radius,sigma,exception);
   oval_image=DestroyImage(oval_image);
@@ -5282,7 +5500,8 @@ MagickExport Image *VignetteImage(const Image *image,const double radius,
       return((Image *) NULL);
     }
   blur_image->matte=MagickFalse;
-  (void) CompositeImage(canvas_image,CopyOpacityCompositeOp,blur_image,0,0);
+  (void) CompositeImage(canvas_image,blur_image,IntensityCompositeOp,MagickTrue,
+    0,0,exception);
   blur_image=DestroyImage(blur_image);
   vignette_image=MergeImageLayers(canvas_image,FlattenLayer,exception);
   canvas_image=DestroyImage(canvas_image);
@@ -5307,7 +5526,8 @@ MagickExport Image *VignetteImage(const Image *image,const double radius,
 %  The format of the WaveImage method is:
 %
 %      Image *WaveImage(const Image *image,const double amplitude,
-%        const double wave_length,ExceptionInfo *exception)
+%        const double wave_length,const PixelInterpolateMethod method,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -5316,11 +5536,14 @@ MagickExport Image *VignetteImage(const Image *image,const double radius,
 %    o amplitude, wave_length:  Define the amplitude and wave length of the
 %      sine wave.
 %
+%    o interpolate: the pixel interpolation method.
+%
 %    o exception: return any errors or warnings in this structure.
 %
 */
 MagickExport Image *WaveImage(const Image *image,const double amplitude,
-  const double wave_length,ExceptionInfo *exception)
+  const double wave_length,const PixelInterpolateMethod method,
+  ExceptionInfo *exception)
 {
 #define WaveImageTag  "Wave/Image"
 
@@ -5337,9 +5560,6 @@ MagickExport Image *WaveImage(const Image *image,const double amplitude,
   MagickOffsetType
     progress;
 
-  PixelInfo
-    zero;
-
   MagickRealType
     *sine_map;
 
@@ -5387,19 +5607,15 @@ MagickExport Image *WaveImage(const Image *image,const double amplitude,
   */
   status=MagickTrue;
   progress=0;
-  GetPixelInfo(wave_image,&zero);
   image_view=AcquireCacheView(image);
   wave_view=AcquireCacheView(wave_image);
   (void) SetCacheViewVirtualPixelMethod(image_view,
     BackgroundVirtualPixelMethod);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status)
 #endif
   for (y=0; y < (ssize_t) wave_image->rows; y++)
   {
-    PixelInfo
-      pixel;
-
     register Quantum
       *restrict q;
 
@@ -5410,18 +5626,15 @@ MagickExport Image *WaveImage(const Image *image,const double amplitude,
       continue;
     q=QueueCacheViewAuthenticPixels(wave_view,0,y,wave_image->columns,1,
       exception);
-    if (q == (const Quantum *) NULL)
+    if (q == (Quantum *) NULL)
       {
         status=MagickFalse;
         continue;
       }
-    pixel=zero;
     for (x=0; x < (ssize_t) wave_image->columns; x++)
     {
-      (void) InterpolatePixelInfo(image,image_view,
-        UndefinedInterpolatePixel,(double) x,(double) (y-sine_map[x]),&pixel,
-        exception);
-      SetPixelPixelInfo(wave_image,&pixel,q);
+      status=InterpolatePixelChannels(image,image_view,wave_image,method,
+        (double) x,(double) (y-sine_map[x]),q,exception);
       q+=GetPixelChannels(wave_image);
     }
     if (SyncCacheViewAuthenticPixels(wave_view,exception) == MagickFalse)
@@ -5432,7 +5645,7 @@ MagickExport Image *WaveImage(const Image *image,const double amplitude,
           proceed;
 
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp critical (MagickCore_WaveImage)
+        #pragma omp critical (MagickCore_WaveImage)
 #endif
         proceed=SetImageProgress(image,WaveImageTag,progress++,image->rows);
         if (proceed == MagickFalse)