]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/fx.c
(no commit message)
[imagemagick] / MagickCore / fx.c
index 670af0d28a2a24a7c0ab4520f2527407e059ac86..2f816cfdefb98054755c845c1d2eabd1c2baf3d3 100644 (file)
@@ -17,7 +17,7 @@
 %                                 October 1996                                %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2013 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  %
@@ -48,6 +48,7 @@
 #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"
@@ -81,6 +82,7 @@
 #include "MagickCore/resample.h"
 #include "MagickCore/resample-private.h"
 #include "MagickCore/resize.h"
+#include "MagickCore/resource_.h"
 #include "MagickCore/splay-tree.h"
 #include "MagickCore/statistic.h"
 #include "MagickCore/string_.h"
@@ -142,7 +144,8 @@ struct _FxInfo
 %
 %  The format of the AcquireFxInfo method is:
 %
-%      FxInfo *AcquireFxInfo(Image *image,const char *expression)
+%      FxInfo *AcquireFxInfo(Image *image,const char *expression,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -150,8 +153,11 @@ struct _FxInfo
 %
 %    o expression: the expression.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
-MagickPrivate FxInfo *AcquireFxInfo(const Image *image,const char *expression)
+MagickPrivate FxInfo *AcquireFxInfo(const Image *image,const char *expression,
+  ExceptionInfo *exception)
 {
   char
     fx_op[2];
@@ -183,7 +189,7 @@ MagickPrivate FxInfo *AcquireFxInfo(const Image *image,const char *expression)
   next=GetFirstImageInList(fx_info->images);
   for ( ; next != (Image *) NULL; next=next->next)
   {
-    fx_info->view[i]=AcquireCacheView(next);
+    fx_info->view[i]=AcquireVirtualCacheView(next,exception);
     i++;
   }
   fx_info->random_info=AcquireRandomInfo();
@@ -194,6 +200,8 @@ MagickPrivate FxInfo *AcquireFxInfo(const Image *image,const char *expression)
     Force right-to-left associativity for unary negation.
   */
   (void) SubstituteString(&fx_info->expression,"-","-1.0*");
+  (void) SubstituteString(&fx_info->expression,"E-1.0*","E-");
+  (void) SubstituteString(&fx_info->expression,"e-1.0*","e-");
   /*
     Convert complex to simple operators.
   */
@@ -275,6 +283,11 @@ MagickExport Image *AddNoiseImage(const Image *image,const NoiseType noise_type,
   ssize_t
     y;
 
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
+  unsigned long
+    key;
+#endif
+
   /*
     Initialize noise image attributes.
   */
@@ -292,16 +305,20 @@ MagickExport Image *AddNoiseImage(const Image *image,const NoiseType noise_type,
       noise_image=DestroyImage(noise_image);
       return((Image *) NULL);
     }
+  if (IsGrayColorspace(image->colorspace) != MagickFalse)
+    (void) TransformImageColorspace(noise_image,RGBColorspace,exception);
   /*
     Add noise in each row.
   */
   status=MagickTrue;
   progress=0;
   random_info=AcquireRandomInfoThreadSet();
-  image_view=AcquireCacheView(image);
-  noise_view=AcquireCacheView(noise_image);
+  image_view=AcquireVirtualCacheView(image,exception);
+  noise_view=AcquireAuthenticCacheView(noise_image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static,4) shared(progress,status)
+  key=GetRandomSecretKey(random_info[0]);
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,key == ~0UL)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
@@ -323,7 +340,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))
       {
@@ -344,13 +361,14 @@ MagickExport Image *AddNoiseImage(const Image *image,const NoiseType noise_type,
           noise_traits,
           traits;
 
-        channel=GetPixelChannelMapChannel(image,i);
-        traits=GetPixelChannelMapTraits(image,channel);
-        noise_traits=GetPixelChannelMapTraits(noise_image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
+        noise_traits=GetPixelChannelTraits(noise_image,channel);
         if ((traits == UndefinedPixelTrait) ||
             (noise_traits == UndefinedPixelTrait))
           continue;
-        if ((noise_traits & CopyPixelTrait) != 0)
+        if (((noise_traits & CopyPixelTrait) != 0) ||
+            (GetPixelMask(image,p) != 0))
           {
             SetPixelChannel(noise_image,channel,p[i],q);
             continue;
@@ -445,8 +463,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)
@@ -459,10 +476,11 @@ MagickExport Image *BlueShiftImage(const Image *image,const double factor,
   */
   status=MagickTrue;
   progress=0;
-  image_view=AcquireCacheView(image);
-  shift_view=AcquireCacheView(shift_image);
+  image_view=AcquireVirtualCacheView(image,exception);
+  shift_view=AcquireAuthenticCacheView(shift_image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
@@ -527,7 +545,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);
@@ -560,7 +578,7 @@ MagickExport Image *BlueShiftImage(const Image *image,const double factor,
 %  The format of the CharcoalImage method is:
 %
 %      Image *CharcoalImage(const Image *image,const double radius,
-%        const double sigma,const double bias,ExceptionInfo *exception)
+%        const double sigma,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -570,13 +588,11 @@ MagickExport Image *BlueShiftImage(const Image *image,const double factor,
 %
 %    o sigma: the standard deviation of the Gaussian, in pixels.
 %
-%    o bias: the bias.
-%
 %    o exception: return any errors or warnings in this structure.
 %
 */
 MagickExport Image *CharcoalImage(const Image *image,const double radius,
-  const double sigma,const double bias,ExceptionInfo *exception)
+  const double sigma,ExceptionInfo *exception)
 {
   Image
     *charcoal_image,
@@ -597,7 +613,7 @@ MagickExport Image *CharcoalImage(const Image *image,const double radius,
   clone_image=DestroyImage(clone_image);
   if (edge_image == (Image *) NULL)
     return((Image *) NULL);
-  charcoal_image=BlurImage(edge_image,radius,sigma,bias,exception);
+  charcoal_image=BlurImage(edge_image,radius,sigma,exception);
   edge_image=DestroyImage(edge_image);
   if (charcoal_image == (Image *) NULL)
     return((Image *) NULL);
@@ -644,6 +660,8 @@ 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)*(100.0-(blend_percentage))+(colorize)*(blend_percentage))/100.0)
 
   CacheView
     *colorize_view,
@@ -665,7 +683,7 @@ MagickExport Image *ColorizeImage(const Image *image,const char *blend,
     flags;
 
   PixelInfo
-    pixel;
+    blend_percentage;
 
   ssize_t
     y;
@@ -688,40 +706,44 @@ MagickExport Image *ColorizeImage(const Image *image,const char *blend,
       colorize_image=DestroyImage(colorize_image);
       return((Image *) NULL);
     }
+  if ((IsGrayColorspace(image->colorspace) != MagickFalse) &&
+      (IsPixelInfoGray(colorize) != MagickFalse))
+    (void) SetImageColorspace(colorize_image,RGBColorspace,exception);
+  if ((colorize_image->alpha_trait != BlendPixelTrait) &&
+      (colorize->alpha_trait == BlendPixelTrait))
+    (void) SetImageAlpha(colorize_image,OpaqueAlpha,exception);
   if (blend == (const char *) NULL)
     return(colorize_image);
-  /*
-    Determine RGB values of the pen color.
-  */
-  GetPixelInfo(image,&pixel);
+  GetPixelInfo(image,&blend_percentage);
   flags=ParseGeometry(blend,&geometry_info);
-  pixel.red=geometry_info.rho;
-  pixel.green=geometry_info.rho;
-  pixel.blue=geometry_info.rho;
-  pixel.alpha=100.0;
+  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;
-  if (pixel.colorspace == CMYKColorspace)
+    blend_percentage.alpha=geometry_info.psi;
+  if (blend_percentage.colorspace == CMYKColorspace)
     {
-      pixel.black=geometry_info.rho;
       if ((flags & PsiValue) != 0)
-        pixel.black=geometry_info.psi;
+        blend_percentage.black=geometry_info.psi;
       if ((flags & ChiValue) != 0)
-        pixel.alpha=geometry_info.chi;
+        blend_percentage.alpha=geometry_info.chi;
     }
   /*
     Colorize DirectClass image.
   */
   status=MagickTrue;
   progress=0;
-  image_view=AcquireCacheView(image);
-  colorize_view=AcquireCacheView(colorize_image);
+  image_view=AcquireVirtualCacheView(image,exception);
+  colorize_view=AcquireAuthenticCacheView(colorize_image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
@@ -731,12 +753,12 @@ MagickExport Image *ColorizeImage(const Image *image,const char *blend,
     register const Quantum
       *restrict p;
 
-    register ssize_t
-      x;
-
     register Quantum
       *restrict q;
 
+    register ssize_t
+      x;
+
     if (status == MagickFalse)
       continue;
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
@@ -761,55 +783,21 @@ MagickExport Image *ColorizeImage(const Image *image,const char *blend,
           colorize_traits,
           traits;
 
-        channel=GetPixelChannelMapChannel(image,i);
-        traits=GetPixelChannelMapTraits(image,channel);
-        colorize_traits=GetPixelChannelMapTraits(colorize_image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
+        colorize_traits=GetPixelChannelTraits(colorize_image,channel);
         if ((traits == UndefinedPixelTrait) ||
             (colorize_traits == UndefinedPixelTrait))
           continue;
-        if ((colorize_traits & CopyPixelTrait) != 0)
+        if (((colorize_traits & CopyPixelTrait) != 0) ||
+            (GetPixelMask(image,p) != 0))
           {
             SetPixelChannel(colorize_image,channel,p[i],q);
             continue;
           }
-        switch (channel)
-        {
-          case RedPixelChannel:
-          {
-            SetPixelChannel(colorize_image,channel,ClampToQuantum((p[i]*
-              (100.0-pixel.red)+colorize->red*pixel.red)/100.0),q);
-            break;
-          }
-          case GreenPixelChannel:
-          {
-            SetPixelChannel(colorize_image,channel,ClampToQuantum((p[i]*
-              (100.0-pixel.green)+colorize->green*pixel.green)/100.0),q);
-            break;
-          }
-          case BluePixelChannel:
-          {
-            SetPixelChannel(colorize_image,channel,ClampToQuantum((p[i]*
-              (100.0-pixel.blue)+colorize->blue*pixel.blue)/100.0),q);
-            break;
-          }
-          case BlackPixelChannel:
-          {
-            SetPixelChannel(colorize_image,channel,ClampToQuantum((p[i]*
-              (100.0-pixel.black)+colorize->black*pixel.black)/100.0),q);
-            break;
-          }
-          case AlphaPixelChannel:
-          {
-            SetPixelChannel(colorize_image,channel,ClampToQuantum((p[i]*
-              (100.0-pixel.alpha)+colorize->alpha*pixel.alpha)/100.0),q);
-            break;
-          }
-          default:
-          {
-            SetPixelChannel(colorize_image,channel,p[i],q);
-            break;
-          }
-        }
+        SetPixelChannel(colorize_image,channel,
+          ClampToQuantum(Colorize(p[i],GetPixelInfoChannel(&blend_percentage,
+          channel),GetPixelInfoChannel(colorize,channel))),q);
       }
       p+=GetPixelChannels(image);
       q+=GetPixelChannels(colorize_image);
@@ -823,7 +811,7 @@ MagickExport Image *ColorizeImage(const Image *image,const char *blend,
           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)
@@ -870,6 +858,11 @@ MagickExport Image *ColorizeImage(const Image *image,const char *blend,
 %    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)
 {
@@ -908,7 +901,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);
@@ -960,18 +953,19 @@ 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);
+  image_view=AcquireVirtualCacheView(image,exception);
+  color_view=AcquireAuthenticCacheView(color_image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
-    MagickRealType
+    PixelInfo
       pixel;
 
     register const Quantum
@@ -993,6 +987,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
@@ -1001,35 +996,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]*
+        double
+          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);
-        if (image->matte != MagickFalse)
-          pixel+=ColorMatrix[v][4]*GetPixelAlpha(image,p);
-        pixel+=QuantumRange*ColorMatrix[v][5];
+          sum+=ColorMatrix[v][3]*GetPixelBlack(image,p);
+        if (image->alpha_trait == BlendPixelTrait)
+          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);
     }
@@ -1041,7 +1032,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);
@@ -1111,11 +1102,11 @@ MagickPrivate FxInfo *DestroyFxInfo(FxInfo *fx_info)
 %
 %  The format of the FxEvaluateExpression method is:
 %
-%      MagickRealType FxEvaluateChannelExpression(FxInfo *fx_info,
+%      double FxEvaluateChannelExpression(FxInfo *fx_info,
 %        const PixelChannel channel,const ssize_t x,const ssize_t y,
-%        MagickRealType *alpha,Exceptioninfo *exception)
-%      MagickRealType FxEvaluateExpression(FxInfo *fx_info,
-%        MagickRealType *alpha,Exceptioninfo *exception)
+%        double *alpha,Exceptioninfo *exception)
+%      double FxEvaluateExpression(FxInfo *fx_info,
+%        double *alpha,Exceptioninfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -1145,9 +1136,12 @@ static inline double MagickMin(const double x,const double y)
   return(y);
 }
 
-static MagickRealType FxChannelStatistics(FxInfo *fx_info,const Image *image,
+static double FxChannelStatistics(FxInfo *fx_info,Image *image,
   PixelChannel channel,const char *symbol,ExceptionInfo *exception)
 {
+  ChannelType
+    channel_mask;
+
   char
     key[MaxTextExtent],
     statistic[MaxTextExtent];
@@ -1158,24 +1152,30 @@ static MagickRealType FxChannelStatistics(FxInfo *fx_info,const Image *image,
   register const char
     *p;
 
+  channel_mask=UndefinedChannel;
   for (p=symbol; (*p != '.') && (*p != '\0'); p++) ;
   if (*p == '.')
-    switch (*++p)  /* e.g. depth.r */
     {
-      case 'r': channel=RedPixelChannel; break;
-      case 'g': channel=GreenPixelChannel; break;
-      case 'b': channel=BluePixelChannel; break;
-      case 'c': channel=CyanPixelChannel; break;
-      case 'm': channel=MagentaPixelChannel; break;
-      case 'y': channel=YellowPixelChannel; break;
-      case 'k': channel=BlackPixelChannel; break;
-      default: break;
+      ssize_t
+        option;
+
+      option=ParseCommandOption(MagickPixelChannelOptions,MagickTrue,p+1);
+      if (option >= 0)
+        {
+          channel=(PixelChannel) option;
+          channel_mask=(ChannelType) (channel_mask | (1 << channel));
+          SetPixelChannelMask(image,channel_mask);
+        }
     }
   (void) FormatLocaleString(key,MaxTextExtent,"%p.%.20g.%s",(void *) image,
     (double) channel,symbol);
   value=(const char *) GetValueFromSplayTree(fx_info->symbols,key);
   if (value != (const char *) NULL)
-    return(QuantumScale*StringToDouble(value,(char **) NULL));
+    {
+      if (channel_mask != UndefinedChannel)
+        SetPixelChannelMask(image,channel_mask);
+      return(QuantumScale*StringToDouble(value,(char **) NULL));
+    }
   (void) DeleteNodeFromSplayTree(fx_info->symbols,key);
   if (LocaleNCompare(symbol,"depth",5) == 0)
     {
@@ -1240,14 +1240,16 @@ static MagickRealType FxChannelStatistics(FxInfo *fx_info,const Image *image,
       (void) FormatLocaleString(statistic,MaxTextExtent,"%g",
         standard_deviation);
     }
+  if (channel_mask != UndefinedChannel)
+    SetPixelChannelMask(image,channel_mask);
   (void) AddValueToSplayTree(fx_info->symbols,ConstantString(key),
     ConstantString(statistic));
   return(QuantumScale*StringToDouble(statistic,(char **) NULL));
 }
 
-static MagickRealType
+static double
   FxEvaluateSubexpression(FxInfo *,const PixelChannel,const ssize_t,
-    const ssize_t,const char *,MagickRealType *,ExceptionInfo *);
+    const ssize_t,const char *,double *,ExceptionInfo *);
 
 static MagickOffsetType FxGCD(MagickOffsetType alpha,MagickOffsetType beta)
 {
@@ -1279,11 +1281,11 @@ static inline const char *FxSubexpression(const char *expression,
   }
   if (*subexpression == '\0')
     (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
-      "UnbalancedParenthesis","`%s'",expression);
+      "UnbalancedParenthesis","'%s'",expression);
   return(subexpression);
 }
 
-static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
+static double FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
   const ssize_t x,const ssize_t y,const char *expression,
   ExceptionInfo *exception)
 {
@@ -1302,7 +1304,7 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
   PixelInfo
     pixel;
 
-  MagickRealType
+  double
     alpha,
     beta;
 
@@ -1313,9 +1315,7 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
     i;
 
   size_t
-    length;
-
-  size_t
+    length,
     level;
 
   p=expression;
@@ -1429,16 +1429,14 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
   if (image == (Image *) NULL)
     {
       (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
-        "NoSuchImage","`%s'",expression);
+        "NoSuchImage","'%s'",expression);
       return(0.0);
     }
   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))
     {
@@ -1469,12 +1467,19 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
               p+=strlen(name);
             }
           else
-            if (QueryColorCompliance(name,AllCompliance,&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);
@@ -1491,7 +1496,7 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
           if (image->colorspace != CMYKColorspace)
             {
               (void) ThrowMagickException(exception,GetMagickModule(),
-                ImageError,"ColorSeparatedImageRequired","`%s'",
+                ImageError,"ColorSeparatedImageRequired","'%s'",
                 image->filename);
               return(0.0);
             }
@@ -1499,12 +1504,12 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
         }
         case AlphaPixelChannel:
         {
-          MagickRealType
+          double
             alpha;
 
-          if (pixel.matte == MagickFalse)
+          if (pixel.alpha_trait != BlendPixelTrait)
             return(1.0);
-          alpha=(MagickRealType) (QuantumScale*pixel.alpha);
+          alpha=(double) (QuantumScale*pixel.alpha);
           return(alpha);
         }
         case IndexPixelChannel:
@@ -1517,7 +1522,7 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
           break;
       }
       (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
-        "UnableToParseExpression","`%s'",p);
+        "UnableToParseExpression","'%s'",p);
       return(0.0);
     }
   switch (*symbol)
@@ -1526,7 +1531,7 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
     case 'a':
     {
       if (LocaleCompare(symbol,"a") == 0)
-        return((MagickRealType) (QuantumScale*pixel.alpha));
+        return((double) (QuantumScale*pixel.alpha));
       break;
     }
     case 'B':
@@ -1649,7 +1654,7 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
           if (image->colorspace != CMYKColorspace)
             {
               (void) ThrowMagickException(exception,GetMagickModule(),
-                OptionError,"ColorSeparatedImageRequired","`%s'",
+                OptionError,"ColorSeparatedImageRequired","'%s'",
                 image->filename);
               return(0.0);
             }
@@ -1661,7 +1666,7 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
     case 'h':
     {
       if (LocaleCompare(symbol,"h") == 0)
-        return((MagickRealType) image->rows);
+        return((double) image->rows);
       if (LocaleCompare(symbol,"hue") == 0)
         {
           double
@@ -1693,14 +1698,14 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
       if (LocaleCompare(symbol,"intensity") == 0)
         return(QuantumScale*GetPixelInfoIntensity(&pixel));
       if (LocaleCompare(symbol,"i") == 0)
-        return((MagickRealType) x);
+        return((double) x);
       break;
     }
     case 'J':
     case 'j':
     {
       if (LocaleCompare(symbol,"j") == 0)
-        return((MagickRealType) y);
+        return((double) y);
       break;
     }
     case 'L':
@@ -1722,7 +1727,7 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
           double
             luminence;
 
-          luminence=0.2126*pixel.red+0.7152*pixel.green+0.0722*pixel.blue;
+          luminence=0.21267f*pixel.red+0.71516f*pixel.green+0.07217f*pixel.blue;
           return(QuantumScale*luminence);
         }
       break;
@@ -1744,7 +1749,7 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
     case 'n':
     {
       if (LocaleCompare(symbol,"n") == 0)
-        return((MagickRealType) GetImageListLength(fx_info->images));
+        return((double) GetImageListLength(fx_info->images));
       break;
     }
     case 'O':
@@ -1758,13 +1763,13 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
     case 'p':
     {
       if (LocaleCompare(symbol,"page.height") == 0)
-        return((MagickRealType) image->page.height);
+        return((double) image->page.height);
       if (LocaleCompare(symbol,"page.width") == 0)
-        return((MagickRealType) image->page.width);
+        return((double) image->page.width);
       if (LocaleCompare(symbol,"page.x") == 0)
-        return((MagickRealType) image->page.x);
+        return((double) image->page.x);
       if (LocaleCompare(symbol,"page.y") == 0)
-        return((MagickRealType) image->page.y);
+        return((double) image->page.y);
       break;
     }
     case 'R':
@@ -1802,14 +1807,14 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
     case 't':
     {
       if (LocaleCompare(symbol,"t") == 0)
-        return((MagickRealType) GetImageIndexInList(fx_info->images));
+        return((double) GetImageIndexInList(fx_info->images));
       break;
     }
     case 'W':
     case 'w':
     {
       if (LocaleCompare(symbol,"w") == 0)
-        return((MagickRealType) image->columns);
+        return((double) image->columns);
       break;
     }
     case 'Y':
@@ -1824,10 +1829,10 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
     {
       if (LocaleCompare(symbol,"z") == 0)
         {
-          MagickRealType
+          double
             depth;
 
-          depth=(MagickRealType) GetImageDepth(image,fx_info->exception);
+          depth=(double) GetImageDepth(image,fx_info->exception);
           return(depth);
         }
       break;
@@ -1837,9 +1842,9 @@ static MagickRealType FxGetSymbol(FxInfo *fx_info,const PixelChannel channel,
   }
   value=(const char *) GetValueFromSplayTree(fx_info->symbols,symbol);
   if (value != (const char *) NULL)
-    return((MagickRealType) StringToDouble(value,(char **) NULL));
+    return((double) StringToDouble(value,(char **) NULL));
   (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
-    "UnableToParseExpression","`%s'",symbol);
+    "UnableToParseExpression","'%s'",symbol);
   return(0.0);
 }
 
@@ -1919,6 +1924,11 @@ static const char *FxOperatorPrecedence(const char *expression,
             break;
           }
 #endif
+        if (LocaleNCompare(expression,"atan2",5) == 0)
+          {
+            expression+=5;
+            break;
+          }
         break;
       }
       case 'E':
@@ -2094,15 +2104,15 @@ static const char *FxOperatorPrecedence(const char *expression,
   return(subexpression);
 }
 
-static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
+static double FxEvaluateSubexpression(FxInfo *fx_info,
   const PixelChannel channel,const ssize_t x,const ssize_t y,
-  const char *expression,MagickRealType *beta,ExceptionInfo *exception)
+  const char *expression,double *beta,ExceptionInfo *exception)
 {
   char
     *q,
     subexpression[MaxTextExtent];
 
-  MagickRealType
+  double
     alpha,
     gamma;
 
@@ -2117,7 +2127,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
   if (*expression == '\0')
     {
       (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
-        "MissingExpression","`%s'",expression);
+        "MissingExpression","'%s'",expression);
       return(0.0);
     }
   *subexpression='\0';
@@ -2133,7 +2143,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         case '~':
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
-          *beta=(MagickRealType) (~(size_t) *beta);
+          *beta=(double) (~(size_t) *beta);
           return(*beta);
         }
         case '!':
@@ -2160,7 +2170,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
             {
               if (exception->severity == UndefinedException)
                 (void) ThrowMagickException(exception,GetMagickModule(),
-                  OptionError,"DivideByZero","`%s'",expression);
+                  OptionError,"DivideByZero","'%s'",expression);
               return(0.0);
             }
           return(alpha/(*beta));
@@ -2172,7 +2182,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
           if (*beta == 0.0)
             {
               (void) ThrowMagickException(exception,GetMagickModule(),
-                OptionError,"DivideByZero","`%s'",expression);
+                OptionError,"DivideByZero","'%s'",expression);
               return(0.0);
             }
           return(fmod((double) alpha,(double) *beta));
@@ -2190,15 +2200,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=(double) ((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=(double) ((size_t) (alpha+0.5) >> (size_t) (gamma+0.5));
           return(*beta);
         }
         case '<':
@@ -2224,25 +2232,23 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         case EqualOperator:
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
-          return(fabs(alpha-(*beta)) <= MagickEpsilon ? 1.0 : 0.0);
+          return(fabs(alpha-(*beta)) < MagickEpsilon ? MagickEpsilon : 0.0);
         }
         case NotEqualOperator:
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
-          return(fabs(alpha-(*beta)) > MagickEpsilon ? 1.0 : 0.0);
+          return(fabs(alpha-(*beta)) >= MagickEpsilon ? 1.0 : 0.0);
         }
         case '&':
         {
           gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
-          *beta=(MagickRealType) ((size_t) (alpha+0.5) & (size_t)
-            (gamma+0.5));
+          *beta=(double) ((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=(double) ((size_t) (alpha+0.5) | (size_t) (gamma+0.5));
           return(*beta);
         }
         case LogicalAndOperator:
@@ -2259,7 +2265,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         }
         case '?':
         {
-          MagickRealType
+          double
             gamma;
 
           (void) CopyMagickString(subexpression,++p,MaxTextExtent);
@@ -2268,10 +2274,10 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
           if (q == (char *) NULL)
             {
               (void) ThrowMagickException(exception,GetMagickModule(),
-                OptionError,"UnableToParseExpression","`%s'",subexpression);
+                OptionError,"UnableToParseExpression","'%s'",subexpression);
               return(0.0);
             }
-          if (fabs((double) alpha) > MagickEpsilon)
+          if (fabs((double) alpha) >= MagickEpsilon)
             gamma=FxEvaluateSubexpression(fx_info,channel,x,y,p,beta,exception);
           else
             gamma=FxEvaluateSubexpression(fx_info,channel,x,y,q,beta,exception);
@@ -2288,7 +2294,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
           if (*q != '\0')
             {
               (void) ThrowMagickException(exception,GetMagickModule(),
-                OptionError,"UnableToParseExpression","`%s'",subexpression);
+                OptionError,"UnableToParseExpression","'%s'",subexpression);
               return(0.0);
             }
           ClearMagickException(exception);
@@ -2344,7 +2350,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
     {
       gamma=FxEvaluateSubexpression(fx_info,channel,x,y,expression+1,beta,
         exception);
-      return((MagickRealType) (~(size_t) (gamma+0.5)));
+      return((double) (~(size_t) (gamma+0.5)));
     }
     case 'A':
     case 'a':
@@ -2353,21 +2359,21 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
             exception);
-          return((MagickRealType) fabs((double) alpha));
+          return((double) fabs((double) alpha));
         }
 #if defined(MAGICKCORE_HAVE_ACOSH)
       if (LocaleNCompare(expression,"acosh",5) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
             exception);
-          return((MagickRealType) acosh((double) alpha));
+          return((double) acosh((double) alpha));
         }
 #endif
       if (LocaleNCompare(expression,"acos",4) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
             exception);
-          return((MagickRealType) acos((double) alpha));
+          return((double) acos((double) alpha));
         }
 #if defined(MAGICKCORE_HAVE_J1)
       if (LocaleNCompare(expression,"airy",4) == 0)
@@ -2385,14 +2391,14 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
             exception);
-          return((MagickRealType) asinh((double) alpha));
+          return((double) asinh((double) alpha));
         }
 #endif
       if (LocaleNCompare(expression,"asin",4) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
             exception);
-          return((MagickRealType) asin((double) alpha));
+          return((double) asin((double) alpha));
         }
       if (LocaleNCompare(expression,"alt",3) == 0)
         {
@@ -2404,21 +2410,21 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
             exception);
-          return((MagickRealType) atan2((double) alpha,(double) *beta));
+          return((double) atan2((double) alpha,(double) *beta));
         }
 #if defined(MAGICKCORE_HAVE_ATANH)
       if (LocaleNCompare(expression,"atanh",5) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
             exception);
-          return((MagickRealType) atanh((double) alpha));
+          return((double) atanh((double) alpha));
         }
 #endif
       if (LocaleNCompare(expression,"atan",4) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
             exception);
-          return((MagickRealType) atan((double) alpha));
+          return((double) atan((double) alpha));
         }
       if (LocaleCompare(expression,"a") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
@@ -2438,19 +2444,19 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
             exception);
-          return((MagickRealType) ceil((double) alpha));
+          return((double) ceil((double) alpha));
         }
       if (LocaleNCompare(expression,"cosh",4) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
             exception);
-          return((MagickRealType) cosh((double) alpha));
+          return((double) cosh((double) alpha));
         }
       if (LocaleNCompare(expression,"cos",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
             exception);
-          return((MagickRealType) cos((double) alpha));
+          return((double) cos((double) alpha));
         }
       if (LocaleCompare(expression,"c") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
@@ -2489,17 +2495,16 @@ 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)));
+          return((double) (alpha/(*beta*(alpha-1.0)+1.0)));
         }
       break;
     }
@@ -2507,15 +2512,15 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
     case 'e':
     {
       if (LocaleCompare(expression,"epsilon") == 0)
-        return((MagickRealType) MagickEpsilon);
+        return((double) MagickEpsilon);
       if (LocaleNCompare(expression,"exp",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
             exception);
-          return((MagickRealType) exp((double) alpha));
+          return((double) exp((double) alpha));
         }
       if (LocaleCompare(expression,"e") == 0)
-        return((MagickRealType) 2.7182818284590452354);
+        return((double) 2.7182818284590452354);
       break;
     }
     case 'F':
@@ -2525,7 +2530,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
             exception);
-          return((MagickRealType) floor((double) alpha));
+          return((double) floor((double) alpha));
         }
       break;
     }
@@ -2537,7 +2542,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
           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);
+          return((double) gamma);
         }
       if (LocaleNCompare(expression,"gcd",3) == 0)
         {
@@ -2546,9 +2551,9 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
 
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
             exception);
-          gcd=FxGCD((MagickOffsetType) (alpha+0.5),(MagickOffsetType)
-            (*beta+0.5));
-          return((MagickRealType) gcd);
+          gcd=FxGCD((MagickOffsetType) (alpha+0.5),(MagickOffsetType) (*beta+
+            0.5));
+          return((double) gcd);
         }
       if (LocaleCompare(expression,"g") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
@@ -2565,7 +2570,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
             exception);
-          return((MagickRealType) hypot((double) alpha,(double) *beta));
+          return((double) hypot((double) alpha,(double) *beta));
         }
       break;
     }
@@ -2585,14 +2590,14 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
             exception);
-          return((MagickRealType) floor(alpha));
+          return((double) 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));
+          return((double) !!isnan((double) alpha));
         }
 #endif
       if (LocaleCompare(expression,"i") == 0)
@@ -2609,7 +2614,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,beta,
             exception);
-          return((MagickRealType) j0((double) alpha));
+          return((double) j0((double) alpha));
         }
 #endif
 #if defined(MAGICKCORE_HAVE_J1)
@@ -2617,7 +2622,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,beta,
             exception);
-          return((MagickRealType) j1((double) alpha));
+          return((double) j1((double) alpha));
         }
 #endif
 #if defined(MAGICKCORE_HAVE_J1)
@@ -2627,8 +2632,7 @@ 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=(double) (2.0*j1((double) (MagickPI*alpha))/(MagickPI*alpha));
           return(gamma);
         }
 #endif
@@ -2641,19 +2645,19 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,beta,
             exception);
-          return((MagickRealType) log((double) alpha));
+          return((double) log((double) alpha));
         }
       if (LocaleNCompare(expression,"logtwo",6) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+6,beta,
             exception);
-          return((MagickRealType) log10((double) alpha))/log10(2.0);
+          return((double) log10((double) alpha))/log10(2.0);
         }
       if (LocaleNCompare(expression,"log",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
             exception);
-          return((MagickRealType) log10((double) alpha));
+          return((double) log10((double) alpha));
         }
       if (LocaleCompare(expression,"lightness") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
@@ -2663,7 +2667,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
     case 'm':
     {
       if (LocaleCompare(expression,"MaxRGB") == 0)
-        return((MagickRealType) QuantumRange);
+        return((double) QuantumRange);
       if (LocaleNCompare(expression,"maxima",6) == 0)
         break;
       if (LocaleNCompare(expression,"max",3) == 0)
@@ -2698,7 +2702,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
             exception);
-          return((MagickRealType) (alpha < MagickEpsilon));
+          return((double) (alpha < MagickEpsilon));
         }
       if (LocaleCompare(expression,"n") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
@@ -2717,14 +2721,14 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
     case 'p':
     {
       if (LocaleCompare(expression,"phi") == 0)
-        return((MagickRealType) MagickPHI);
+        return((double) MagickPHI);
       if (LocaleCompare(expression,"pi") == 0)
-        return((MagickRealType) MagickPI);
+        return((double) MagickPI);
       if (LocaleNCompare(expression,"pow",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
             exception);
-          return((MagickRealType) pow((double) alpha,(double) *beta));
+          return((double) pow((double) alpha,(double) *beta));
         }
       if (LocaleCompare(expression,"p") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
@@ -2734,21 +2738,21 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
     case 'q':
     {
       if (LocaleCompare(expression,"QuantumRange") == 0)
-        return((MagickRealType) QuantumRange);
+        return((double) QuantumRange);
       if (LocaleCompare(expression,"QuantumScale") == 0)
-        return((MagickRealType) QuantumScale);
+        return((double) QuantumScale);
       break;
     }
     case 'R':
     case 'r':
     {
       if (LocaleNCompare(expression,"rand",4) == 0)
-        return((MagickRealType) GetPseudoRandomValue(fx_info->random_info));
+        return((double) GetPseudoRandomValue(fx_info->random_info));
       if (LocaleNCompare(expression,"round",5) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
             exception);
-          return((MagickRealType) floor((double) alpha+0.5));
+          return((double) floor((double) alpha+0.5));
         }
       if (LocaleCompare(expression,"r") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
@@ -2771,7 +2775,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
             exception);
           if (alpha == 0)
             return(1.0);
-          gamma=(MagickRealType) (sin((double) (MagickPI*alpha))/
+          gamma=(double) (sin((double) (MagickPI*alpha))/
             (MagickPI*alpha));
           return(gamma);
         }
@@ -2779,25 +2783,25 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
             exception);
-          return((MagickRealType) sinh((double) alpha));
+          return((double) sinh((double) alpha));
         }
       if (LocaleNCompare(expression,"sin",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
             exception);
-          return((MagickRealType) sin((double) alpha));
+          return((double) sin((double) alpha));
         }
       if (LocaleNCompare(expression,"sqrt",4) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
             exception);
-          return((MagickRealType) sqrt((double) alpha));
+          return((double) 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)))));
+          return((double) (1.0/(1.0+exp((double) (-alpha)))));
         }
       if (LocaleCompare(expression,"s") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
@@ -2810,13 +2814,13 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,beta,
             exception);
-          return((MagickRealType) tanh((double) alpha));
+          return((double) tanh((double) alpha));
         }
       if (LocaleNCompare(expression,"tan",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
             exception);
-          return((MagickRealType) tan((double) alpha));
+          return((double) tan((double) alpha));
         }
       if (LocaleCompare(expression,"Transparent") == 0)
         return(0.0);
@@ -2825,8 +2829,8 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
             exception);
           if (alpha >= 0.0)
-            return((MagickRealType) floor((double) alpha));
-          return((MagickRealType) ceil((double) alpha));
+            return((double) floor((double) alpha));
+          return((double) ceil((double) alpha));
         }
       if (LocaleCompare(expression,"t") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
@@ -2856,7 +2860,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
             alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,beta,
               exception);
           } while (fabs((double) alpha) >= MagickEpsilon);
-          return((MagickRealType) *beta);
+          return((double) *beta);
         }
       if (LocaleCompare(expression,"w") == 0)
         return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
@@ -2887,7 +2891,7 @@ static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
 }
 
 MagickPrivate MagickBooleanType FxEvaluateExpression(FxInfo *fx_info,
-  MagickRealType *alpha,ExceptionInfo *exception)
+  double *alpha,ExceptionInfo *exception)
 {
   MagickBooleanType
     status;
@@ -2898,7 +2902,7 @@ MagickPrivate MagickBooleanType FxEvaluateExpression(FxInfo *fx_info,
 }
 
 MagickExport MagickBooleanType FxPreprocessExpression(FxInfo *fx_info,
-  MagickRealType *alpha,ExceptionInfo *exception)
+  double *alpha,ExceptionInfo *exception)
 {
   FILE
     *file;
@@ -2916,9 +2920,9 @@ MagickExport MagickBooleanType FxPreprocessExpression(FxInfo *fx_info,
 
 MagickPrivate MagickBooleanType FxEvaluateChannelExpression(FxInfo *fx_info,
   const PixelChannel channel,const ssize_t x,const ssize_t y,
-  MagickRealType *alpha,ExceptionInfo *exception)
+  double *alpha,ExceptionInfo *exception)
 {
-  MagickRealType
+  double
     beta;
 
   beta=0.0;
@@ -2961,7 +2965,7 @@ static FxInfo **DestroyFxThreadSet(FxInfo **fx_info)
     i;
 
   assert(fx_info != (FxInfo **) NULL);
-  for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
+  for (i=0; i < (ssize_t) GetMagickResourceLimit(ThreadResource); i++)
     if (fx_info[i] != (FxInfo *) NULL)
       fx_info[i]=DestroyFxInfo(fx_info[i]);
   fx_info=(FxInfo **) RelinquishMagickMemory(fx_info);
@@ -2977,7 +2981,7 @@ static FxInfo **AcquireFxThreadSet(const Image *image,const char *expression,
   FxInfo
     **fx_info;
 
-  MagickRealType
+  double
     alpha;
 
   register ssize_t
@@ -2986,10 +2990,14 @@ static FxInfo **AcquireFxThreadSet(const Image *image,const char *expression,
   size_t
     number_threads;
 
-  number_threads=GetOpenMPMaximumThreads();
+  number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
   fx_info=(FxInfo **) AcquireQuantumMemory(number_threads,sizeof(*fx_info));
   if (fx_info == (FxInfo **) NULL)
-    return((FxInfo **) NULL);
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),
+        ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
+      return((FxInfo **) NULL);
+    }
   (void) ResetMagickMemory(fx_info,0,number_threads*sizeof(*fx_info));
   if (*expression != '@')
     fx_expression=ConstantString(expression);
@@ -2997,12 +3005,19 @@ static FxInfo **AcquireFxThreadSet(const Image *image,const char *expression,
     fx_expression=FileToString(expression+1,~0,exception);
   for (i=0; i < (ssize_t) number_threads; i++)
   {
-    fx_info[i]=AcquireFxInfo(image,fx_expression);
+    MagickBooleanType
+      status;
+
+    fx_info[i]=AcquireFxInfo(image,fx_expression,exception);
     if (fx_info[i] == (FxInfo *) NULL)
-      return(DestroyFxThreadSet(fx_info));
-    (void) FxPreprocessExpression(fx_info[i],&alpha,fx_info[i]->exception);
+      break;
+    status=FxPreprocessExpression(fx_info[i],&alpha,exception);
+    if (status == MagickFalse)
+      break;
   }
   fx_expression=DestroyString(fx_expression);
+  if (i < (ssize_t) number_threads)
+    fx_info=DestroyFxThreadSet(fx_info);
   return(fx_info);
 }
 
@@ -3027,9 +3042,6 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
   MagickOffsetType
     progress;
 
-  MagickRealType
-    alpha;
-
   ssize_t
     y;
 
@@ -3037,25 +3049,19 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+  fx_info=AcquireFxThreadSet(image,expression,exception);
+  if (fx_info == (FxInfo **) NULL)
+    return((Image *) NULL);
   fx_image=CloneImage(image,image->columns,image->rows,MagickTrue,exception);
   if (fx_image == (Image *) NULL)
-    return((Image *) NULL);
-  if (SetImageStorageClass(fx_image,DirectClass,exception) == MagickFalse)
     {
-      fx_image=DestroyImage(fx_image);
+      fx_info=DestroyFxThreadSet(fx_info);
       return((Image *) NULL);
     }
-  fx_info=AcquireFxThreadSet(image,expression,exception);
-  if (fx_info == (FxInfo **) NULL)
-    {
-      fx_image=DestroyImage(fx_image);
-      ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
-    }
-  status=FxPreprocessExpression(fx_info[0],&alpha,exception);
-  if (status == MagickFalse)
+  if (SetImageStorageClass(fx_image,DirectClass,exception) == MagickFalse)
     {
-      fx_image=DestroyImage(fx_image);
       fx_info=DestroyFxThreadSet(fx_info);
+      fx_image=DestroyImage(fx_image);
       return((Image *) NULL);
     }
   /*
@@ -3063,10 +3069,11 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
   */
   status=MagickTrue;
   progress=0;
-  image_view=AcquireCacheView(image);
-  fx_view=AcquireCacheView(fx_image);
+  image_view=AcquireVirtualCacheView(image,exception);
+  fx_view=AcquireAuthenticCacheView(fx_image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) fx_image->rows; y++)
   {
@@ -3085,7 +3092,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;
@@ -3098,7 +3105,7 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
 
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
-        MagickRealType
+        double
           alpha;
 
         PixelChannel
@@ -3108,13 +3115,14 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
           fx_traits,
           traits;
 
-        channel=GetPixelChannelMapChannel(image,i);
-        traits=GetPixelChannelMapTraits(image,channel);
-        fx_traits=GetPixelChannelMapTraits(fx_image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
+        fx_traits=GetPixelChannelTraits(fx_image,channel);
         if ((traits == UndefinedPixelTrait) ||
             (fx_traits == UndefinedPixelTrait))
           continue;
-        if ((fx_traits & CopyPixelTrait) != 0)
+        if (((fx_traits & CopyPixelTrait) != 0) ||
+            (GetPixelMask(image,p) != 0))
           {
             SetPixelChannel(fx_image,channel,p[i],q);
             continue;
@@ -3122,7 +3130,7 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
         alpha=0.0;
         (void) FxEvaluateChannelExpression(fx_info[id],channel,x,y,&alpha,
           exception);
-        q[i]=ClampToQuantum((MagickRealType) QuantumRange*alpha);
+        q[i]=ClampToQuantum(QuantumRange*alpha);
       }
       p+=GetPixelChannels(image);
       q+=GetPixelChannels(fx_image);
@@ -3135,7 +3143,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)
@@ -3204,7 +3212,7 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
   MagickOffsetType
     progress;
 
-  MagickRealType
+  double
     radius;
 
   PointInfo
@@ -3233,7 +3241,7 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
       return((Image *) NULL);
     }
   if (implode_image->background_color.alpha != OpaqueAlpha)
-    implode_image->matte=MagickTrue;
+    implode_image->alpha_trait=BlendPixelTrait;
   /*
     Compute scaling factor.
   */
@@ -3255,14 +3263,15 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
   */
   status=MagickTrue;
   progress=0;
-  image_view=AcquireCacheView(image);
-  implode_view=AcquireCacheView(implode_image);
+  image_view=AcquireVirtualCacheView(image,exception);
+  implode_view=AcquireAuthenticCacheView(implode_image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
-    MagickRealType
+    double
       distance;
 
     PointInfo
@@ -3280,7 +3289,7 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
     if (status == MagickFalse)
       continue;
     p=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
-    q=GetCacheViewAuthenticPixels(implode_view,0,y,implode_image->columns,1,
+    q=QueueCacheViewAuthenticPixels(implode_view,0,y,implode_image->columns,1,
       exception);
     if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
       {
@@ -3296,12 +3305,31 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
       /*
         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))
+        for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
         {
-          for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
-            q[i]=p[i];
+          PixelChannel
+            channel;
+
+          PixelTrait
+            implode_traits,
+            traits;
+
+          channel=GetPixelChannelChannel(image,i);
+          traits=GetPixelChannelTraits(image,channel);
+          implode_traits=GetPixelChannelTraits(implode_image,channel);
+          if ((traits == UndefinedPixelTrait) ||
+              (implode_traits == UndefinedPixelTrait))
+            continue;
+          SetPixelChannel(implode_image,channel,p[i],q);
         }
       else
         {
@@ -3313,8 +3341,8 @@ 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);
+            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);
@@ -3330,7 +3358,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)
@@ -3389,7 +3417,7 @@ MagickExport Image *MorphImages(const Image *image,
   MagickOffsetType
     scene;
 
-  MagickRealType
+  double
     alpha,
     beta;
 
@@ -3455,18 +3483,18 @@ MagickExport Image *MorphImages(const Image *image,
         *image_view,
         *morph_view;
 
-      beta=(MagickRealType) (i+1.0)/(MagickRealType) (number_frames+1.0);
+      beta=(double) (i+1.0)/(double) (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);
@@ -3474,17 +3502,17 @@ 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);
           return((Image *) NULL);
         }
-      image_view=AcquireCacheView(morph_image);
-      morph_view=AcquireCacheView(morph_images);
+      image_view=AcquireVirtualCacheView(morph_image,exception);
+      morph_view=AcquireAuthenticCacheView(morph_images,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static,4) shared(status)
+      #pragma omp parallel for schedule(static,4) shared(status) \
+        dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
       for (y=0; y < (ssize_t) morph_images->rows; y++)
       {
@@ -3513,19 +3541,33 @@ 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;
+
+          for (i=0; i < (ssize_t) GetPixelChannels(morph_image); i++)
+          {
+            PixelChannel
+              channel;
+
+            PixelTrait
+              morph_traits,
+              traits;
+
+            channel=GetPixelChannelChannel(image,i);
+            traits=GetPixelChannelTraits(image,channel);
+            morph_traits=GetPixelChannelTraits(morph_image,channel);
+            if ((traits == UndefinedPixelTrait) ||
+                (morph_traits == UndefinedPixelTrait))
+              continue;
+            if (((morph_traits & CopyPixelTrait) != 0) ||
+                (GetPixelMask(image,p) != 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);
         }
@@ -3556,7 +3598,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));
@@ -3608,7 +3650,7 @@ MagickExport Image *MorphImages(const Image *image,
 */
 
 static inline Quantum PlasmaPixel(RandomInfo *random_info,
-  const MagickRealType pixel,const MagickRealType noise)
+  const double pixel,const double noise)
 {
   Quantum
     plasma;
@@ -3623,7 +3665,7 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
   const SegmentInfo *segment,size_t attenuate,size_t depth,
   ExceptionInfo *exception)
 {
-  MagickRealType
+  double
     plasma;
 
   PixelChannel
@@ -3691,25 +3733,25 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
   /*
     Average pixels and apply plasma.
   */
-  plasma=(MagickRealType) QuantumRange/(2.0*attenuate);
+  plasma=(double) QuantumRange/(2.0*attenuate);
   if ((segment->x1 != (double) x_mid) || (segment->x2 != (double) x_mid))
     {
       /*
         Left pixel.
       */
       x=(ssize_t) ceil(segment->x1-0.5);
-      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);
+      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 ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
           (q == (Quantum *) NULL))
         return(MagickTrue);
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
-        channel=GetPixelChannelMapChannel(image,i);
-        traits=GetPixelChannelMapTraits(image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
         q[i]=PlasmaPixel(random_info,(u[channel]+v[channel])/2.0,plasma);
@@ -3731,8 +3773,8 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
             return(MagickTrue);
           for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
           {
-            channel=GetPixelChannelMapChannel(image,i);
-            traits=GetPixelChannelMapTraits(image,channel);
+            channel=GetPixelChannelChannel(image,i);
+            traits=GetPixelChannelTraits(image,channel);
             if (traits == UndefinedPixelTrait)
               continue;
             q[i]=PlasmaPixel(random_info,(u[channel]+v[channel])/2.0,plasma);
@@ -3758,8 +3800,8 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
             return(MagickTrue);
           for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
           {
-            channel=GetPixelChannelMapChannel(image,i);
-            traits=GetPixelChannelMapTraits(image,channel);
+            channel=GetPixelChannelChannel(image,i);
+            traits=GetPixelChannelTraits(image,channel);
             if (traits == UndefinedPixelTrait)
               continue;
             q[i]=PlasmaPixel(random_info,(u[channel]+v[channel])/2.0,plasma);
@@ -3782,8 +3824,8 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
             return(MagickTrue);
           for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
           {
-            channel=GetPixelChannelMapChannel(image,i);
-            traits=GetPixelChannelMapTraits(image,channel);
+            channel=GetPixelChannelChannel(image,i);
+            traits=GetPixelChannelTraits(image,channel);
             if (traits == UndefinedPixelTrait)
               continue;
             q[i]=PlasmaPixel(random_info,(u[channel]+v[channel])/2.0,plasma);
@@ -3808,8 +3850,8 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
         return(MagickTrue);
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
-        channel=GetPixelChannelMapChannel(image,i);
-        traits=GetPixelChannelMapTraits(image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
         q[i]=PlasmaPixel(random_info,(u[channel]+v[channel])/2.0,plasma);
@@ -3844,9 +3886,9 @@ MagickExport MagickBooleanType PlasmaImage(Image *image,
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
   if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
     return(MagickFalse);
-  image_view=AcquireCacheView(image);
-  u_view=AcquireCacheView(image);
-  v_view=AcquireCacheView(image);
+  image_view=AcquireAuthenticCacheView(image,exception);
+  u_view=AcquireVirtualCacheView(image,exception);
+  v_view=AcquireVirtualCacheView(image,exception);
   random_info=AcquireRandomInfo();
   status=PlasmaImageProxy(image,image_view,u_view,v_view,random_info,segment,
     attenuate,depth,exception);
@@ -3983,12 +4025,12 @@ MagickExport Image *PolaroidImage(const Image *image,const DrawInfo *draw_info,
     }
   picture_image->background_color=image->border_color;
   (void) SetImageBackgroundColor(picture_image,exception);
-  (void) CompositeImage(picture_image,OverCompositeOp,image,quantum,quantum,
-    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),exception);
+      (void) CompositeImage(picture_image,caption_image,OverCompositeOp,
+        MagickTrue,quantum,(ssize_t) (image->rows+3*quantum/2),exception);
       caption_image=DestroyImage(caption_image);
     }
   (void) QueryColorCompliance("none",AllCompliance,
@@ -4011,7 +4053,7 @@ MagickExport Image *PolaroidImage(const Image *image,const DrawInfo *draw_info,
     return((Image *) NULL);
   picture_image=rotate_image;
   picture_image->background_color=image->background_color;
-  polaroid_image=ShadowImage(picture_image,80.0,2.0,0.0,quantum/3,quantum/3,
+  polaroid_image=ShadowImage(picture_image,80.0,2.0,quantum/3,quantum/3,
     exception);
   if (polaroid_image == (Image *) NULL)
     {
@@ -4026,8 +4068,8 @@ 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,exception);
+  (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) QueryColorCompliance("none",AllCompliance,
     &polaroid_image->background_color,exception);
@@ -4104,7 +4146,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)
@@ -4117,10 +4159,11 @@ MagickExport Image *SepiaToneImage(const Image *image,const double threshold,
   */
   status=MagickTrue;
   progress=0;
-  image_view=AcquireCacheView(image);
-  sepia_view=AcquireCacheView(sepia_image);
+  image_view=AcquireVirtualCacheView(image,exception);
+  sepia_view=AcquireAuthenticCacheView(sepia_image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
@@ -4136,7 +4179,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))
       {
@@ -4145,23 +4188,23 @@ MagickExport Image *SepiaToneImage(const Image *image,const double threshold,
       }
     for (x=0; x < (ssize_t) image->columns; x++)
     {
-      MagickRealType
+      double
         intensity,
         tone;
 
-      intensity=(MagickRealType) GetPixelIntensity(image,p);
-      tone=intensity > threshold ? (MagickRealType) QuantumRange : intensity+
-        (MagickRealType) QuantumRange-threshold;
+      intensity=GetPixelIntensity(image,p);
+      tone=intensity > threshold ? (double) QuantumRange : intensity+
+        (double) QuantumRange-threshold;
       SetPixelRed(sepia_image,ClampToQuantum(tone),q);
-      tone=intensity > (7.0*threshold/6.0) ? (MagickRealType) QuantumRange :
-        intensity+(MagickRealType) QuantumRange-7.0*threshold/6.0;
+      tone=intensity > (7.0*threshold/6.0) ? (double) QuantumRange :
+        intensity+(double) QuantumRange-7.0*threshold/6.0;
       SetPixelGreen(sepia_image,ClampToQuantum(tone),q);
       tone=intensity < (threshold/6.0) ? 0 : intensity-threshold/6.0;
       SetPixelBlue(sepia_image,ClampToQuantum(tone),q);
       tone=threshold/7.0;
-      if ((MagickRealType) GetPixelGreen(image,q) < tone)
+      if ((double) GetPixelGreen(image,q) < tone)
         SetPixelGreen(sepia_image,ClampToQuantum(tone),q);
-      if ((MagickRealType) GetPixelBlue(image,q) < tone)
+      if ((double) GetPixelBlue(image,q) < tone)
         SetPixelBlue(sepia_image,ClampToQuantum(tone),q);
       p+=GetPixelChannels(image);
       q+=GetPixelChannels(sepia_image);
@@ -4174,7 +4217,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);
@@ -4207,8 +4250,8 @@ MagickExport Image *SepiaToneImage(const Image *image,const double threshold,
 %  The format of the ShadowImage method is:
 %
 %      Image *ShadowImage(const Image *image,const double alpha,
-%        const double sigma,const double bias,const ssize_t x_offset,
-%        const ssize_t y_offset,ExceptionInfo *exception)
+%        const double sigma,const ssize_t x_offset,const ssize_t y_offset,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -4218,8 +4261,6 @@ MagickExport Image *SepiaToneImage(const Image *image,const double threshold,
 %
 %    o sigma: the standard deviation of the Gaussian, in pixels.
 %
-%    o bias: the bias.
-%
 %    o x_offset: the shadow x-offset.
 %
 %    o y_offset: the shadow y-offset.
@@ -4228,8 +4269,8 @@ MagickExport Image *SepiaToneImage(const Image *image,const double threshold,
 %
 */
 MagickExport Image *ShadowImage(const Image *image,const double alpha,
-  const double sigma,const double bias,const ssize_t x_offset,
-  const ssize_t y_offset,ExceptionInfo *exception)
+  const double sigma,const ssize_t x_offset,const ssize_t y_offset,
+  ExceptionInfo *exception)
 {
 #define ShadowImageTag  "Shadow/Image"
 
@@ -4262,25 +4303,28 @@ MagickExport Image *ShadowImage(const Image *image,const double alpha,
   clone_image=CloneImage(image,0,0,MagickTrue,exception);
   if (clone_image == (Image *) NULL)
     return((Image *) NULL);
-  (void) SetImageVirtualPixelMethod(clone_image,EdgeVirtualPixelMethod);
+  if (IsGrayColorspace(image->colorspace) != MagickFalse)
+    (void) TransformImageColorspace(clone_image,RGBColorspace,exception);
+  (void) SetImageVirtualPixelMethod(clone_image,TransparentVirtualPixelMethod,
+    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) QueryColorCompliance("none",AllCompliance,&clone_image->border_color,
     exception);
-  clone_image->matte=MagickTrue;
+  clone_image->alpha_trait=BlendPixelTrait;
   border_image=BorderImage(clone_image,&border_info,OverCompositeOp,exception);
   clone_image=DestroyImage(clone_image);
   if (border_image == (Image *) NULL)
     return((Image *) NULL);
-  if (border_image->matte == MagickFalse)
+  if (border_image->alpha_trait != BlendPixelTrait)
     (void) SetImageAlphaChannel(border_image,OpaqueAlphaChannel,exception);
   /*
     Shadow image.
   */
   status=MagickTrue;
-  image_view=AcquireCacheView(border_image);
+  image_view=AcquireAuthenticCacheView(border_image,exception);
   for (y=0; y < (ssize_t) border_image->rows; y++)
   {
     PixelInfo
@@ -4302,10 +4346,10 @@ MagickExport Image *ShadowImage(const Image *image,const double alpha,
         continue;
       }
     background_color=border_image->background_color;
-    background_color.matte=MagickTrue;
+    background_color.alpha_trait=BlendPixelTrait;
     for (x=0; x < (ssize_t) border_image->columns; x++)
     {
-      if (border_image->matte != MagickFalse)
+      if (border_image->alpha_trait == BlendPixelTrait)
         background_color.alpha=GetPixelAlpha(border_image,q)*alpha/100.0;
       SetPixelInfoPixel(border_image,&background_color,q);
       q+=GetPixelChannels(border_image);
@@ -4319,12 +4363,12 @@ MagickExport Image *ShadowImage(const Image *image,const double alpha,
       border_image=DestroyImage(border_image);
       return((Image *) NULL);
     }
-  channel_mask=SetPixelChannelMask(border_image,AlphaChannel);
-  shadow_image=BlurImage(border_image,0.0,sigma,bias,exception);
+  channel_mask=SetImageChannelMask(border_image,AlphaChannel);
+  shadow_image=BlurImage(border_image,0.0,sigma,exception);
   border_image=DestroyImage(border_image);
   if (shadow_image == (Image *) NULL)
     return((Image *) NULL);
-  (void) SetPixelChannelMapMask(shadow_image,channel_mask);
+  (void) SetPixelChannelMask(shadow_image,channel_mask);
   if (shadow_image->page.width == 0)
     shadow_image->page.width=shadow_image->columns;
   if (shadow_image->page.height == 0)
@@ -4356,8 +4400,7 @@ MagickExport Image *ShadowImage(const Image *image,const double alpha,
 %  The format of the SketchImage method is:
 %
 %    Image *SketchImage(const Image *image,const double radius,
-%      const double sigma,const double angle,const double bias,
-%      ExceptionInfo *exception)
+%      const double sigma,const double angle,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -4370,14 +4413,11 @@ MagickExport Image *ShadowImage(const Image *image,const double alpha,
 %
 %    o angle: apply the effect along this angle.
 %
-%    o bias: the bias.
-%
 %    o exception: return any errors or warnings in this structure.
 %
 */
 MagickExport Image *SketchImage(const Image *image,const double radius,
-  const double sigma,const double angle,const double bias,
-  ExceptionInfo *exception)
+  const double sigma,const double angle,ExceptionInfo *exception)
 {
   CacheView
     *random_view;
@@ -4398,6 +4438,11 @@ MagickExport Image *SketchImage(const Image *image,const double radius,
   ssize_t
     y;
 
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
+  unsigned long
+    key;
+#endif
+
   /*
     Sketch image.
   */
@@ -4407,9 +4452,13 @@ MagickExport Image *SketchImage(const Image *image,const double radius,
     return((Image *) NULL);
   status=MagickTrue;
   random_info=AcquireRandomInfoThreadSet();
-  random_view=AcquireCacheView(random_image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static,4) shared(status)
+  key=GetRandomSecretKey(random_info[0]);
+#endif
+  random_view=AcquireAuthenticCacheView(random_image,exception);
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
+  #pragma omp parallel for schedule(static,4) shared(status) \
+    dynamic_number_threads(image,image->columns,image->rows,key == ~0UL)
 #endif
   for (y=0; y < (ssize_t) random_image->rows; y++)
   {
@@ -4433,12 +4482,17 @@ MagickExport Image *SketchImage(const Image *image,const double radius,
       }
     for (x=0; x < (ssize_t) random_image->columns; x++)
     {
-      MagickRealType
+      double
         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++)
       {
@@ -4448,8 +4502,8 @@ MagickExport Image *SketchImage(const Image *image,const double radius,
         PixelTrait
           traits;
 
-        channel=GetPixelChannelMapChannel(image,i);
-        traits=GetPixelChannelMapTraits(image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
         q[i]=ClampToQuantum(QuantumRange*value);
@@ -4466,7 +4520,7 @@ MagickExport Image *SketchImage(const Image *image,const double radius,
       random_image=DestroyImage(random_image);
       return(random_image);
     }
-  blur_image=MotionBlurImage(random_image,radius,sigma,angle,bias,exception);
+  blur_image=MotionBlurImage(random_image,radius,sigma,angle,exception);
   random_image=DestroyImage(random_image);
   if (blur_image == (Image *) NULL)
     return((Image *) NULL);
@@ -4483,8 +4537,8 @@ MagickExport Image *SketchImage(const Image *image,const double radius,
       dodge_image=DestroyImage(dodge_image);
       return((Image *) NULL);
     }
-  (void) CompositeImage(sketch_image,ColorDodgeCompositeOp,dodge_image,0,0,
-    exception);
+  (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)
@@ -4493,8 +4547,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,
-    exception);
+  (void) CompositeImage(sketch_image,blend_image,BlendCompositeOp,MagickTrue,
+    0,0,exception);
   blend_image=DestroyImage(blend_image);
   return(sketch_image);
 }
@@ -4560,13 +4614,13 @@ MagickExport MagickBooleanType SolarizeImage(Image *image,
       */
       for (i=0; i < (ssize_t) image->colors; i++)
       {
-        if ((MagickRealType) image->colormap[i].red > threshold)
-          image->colormap[i].red=(Quantum) QuantumRange-image->colormap[i].red;
-        if ((MagickRealType) image->colormap[i].green > threshold)
-          image->colormap[i].green=(Quantum) QuantumRange-
+        if ((double) image->colormap[i].red > threshold)
+          image->colormap[i].red=QuantumRange-image->colormap[i].red;
+        if ((double) image->colormap[i].green > threshold)
+          image->colormap[i].green=QuantumRange-
             image->colormap[i].green;
-        if ((MagickRealType) image->colormap[i].blue > threshold)
-          image->colormap[i].blue=(Quantum) QuantumRange-
+        if ((double) image->colormap[i].blue > threshold)
+          image->colormap[i].blue=QuantumRange-
             image->colormap[i].blue;
       }
     }
@@ -4575,9 +4629,10 @@ MagickExport MagickBooleanType SolarizeImage(Image *image,
   */
   status=MagickTrue;
   progress=0;
-  image_view=AcquireCacheView(image);
+  image_view=AcquireAuthenticCacheView(image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
@@ -4600,6 +4655,11 @@ MagickExport MagickBooleanType SolarizeImage(Image *image,
       register ssize_t
         i;
 
+      if (GetPixelMask(image,q) != 0)
+        {
+          q+=GetPixelChannels(image);
+          continue;
+        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel
@@ -4608,12 +4668,12 @@ MagickExport MagickBooleanType SolarizeImage(Image *image,
         PixelTrait
           traits;
 
-        channel=GetPixelChannelMapChannel(image,i);
-        traits=GetPixelChannelMapTraits(image,channel);
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
         if ((traits == UndefinedPixelTrait) ||
             ((traits & CopyPixelTrait) != 0))
           continue;
-        if ((MagickRealType) q[i] > threshold)
+        if ((double) q[i] > threshold)
           q[i]=QuantumRange-q[i];
       }
       q+=GetPixelChannels(image);
@@ -4626,7 +4686,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)
@@ -4721,12 +4781,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.
   */
@@ -4734,26 +4794,23 @@ 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);
+  watermark_view=AcquireVirtualCacheView(watermark,exception);
+  stegano_view=AcquireAuthenticCacheView(stegano_image,exception);
   for (i=(ssize_t) depth-1; (i >= 0) && (j < (ssize_t) depth); i--)
   {
     for (y=0; (y < (ssize_t) watermark->rows) && (j < (ssize_t) depth); y++)
     {
       for (x=0; (x < (ssize_t) watermark->columns) && (j < (ssize_t) depth); x++)
       {
-        Quantum
-          virtual_pixel[CompositePixelChannel];
+        ssize_t
+          offset;
 
-        (void) GetOneCacheViewVirtualPixel(watermark_view,x,y,virtual_pixel,
+        (void) GetOneCacheViewVirtualPixelInfo(watermark_view,x,y,&pixel,
           exception);
-        pixel.red=(double) virtual_pixel[RedPixelChannel];
-        pixel.green=(double) virtual_pixel[GreenPixelChannel];
-        pixel.blue=(double) virtual_pixel[BluePixelChannel];
-        pixel.alpha=(double) virtual_pixel[AlphaPixelChannel];
-        if ((k/(ssize_t) stegano_image->columns) >= (ssize_t) stegano_image->rows)
+        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,
@@ -4764,20 +4821,20 @@ MagickExport Image *SteganoImage(const Image *image,const Image *watermark,
         {
           case 0:
           {
-            SetPixelRed(image,SetBit(GetPixelRed(image,q),j,GetBit(
-              GetPixelInfoIntensity(&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(
-              GetPixelInfoIntensity(&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(
-              GetPixelInfoIntensity(&pixel),i)),q);
+            SetPixelBlue(stegano_image,SetBit(GetPixelBlue(stegano_image,q),j,
+              GetBit(GetPixelInfoIntensity(&pixel),i)),q);
             break;
           }
         }
@@ -4789,7 +4846,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++;
       }
     }
@@ -4806,8 +4863,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,exception);
   if (status == MagickFalse)
     {
       stegano_image=DestroyImage(stegano_image);
@@ -4905,6 +4960,7 @@ MagickExport Image *StereoAnaglyphImage(const Image *left_image,
       stereo_image=DestroyImage(stereo_image);
       return((Image *) NULL);
     }
+  (void) SetImageColorspace(stereo_image,sRGBColorspace,exception);
   /*
     Copy left image to red channel and right image to blue channel.
   */
@@ -5010,7 +5066,7 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
   MagickOffsetType
     progress;
 
-  MagickRealType
+  double
     radius;
 
   PointInfo
@@ -5038,7 +5094,7 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
       return((Image *) NULL);
     }
   if (swirl_image->background_color.alpha != OpaqueAlpha)
-    swirl_image->matte=MagickTrue;
+    swirl_image->alpha_trait=BlendPixelTrait;
   /*
     Compute scaling factor.
   */
@@ -5058,14 +5114,15 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
   */
   status=MagickTrue;
   progress=0;
-  image_view=AcquireCacheView(image);
-  swirl_view=AcquireCacheView(swirl_image);
+  image_view=AcquireVirtualCacheView(image,exception);
+  swirl_view=AcquireAuthenticCacheView(swirl_image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
-    MagickRealType
+    double
       distance;
 
     PointInfo
@@ -5083,7 +5140,7 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
     if (status == MagickFalse)
       continue;
     p=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
-    q=GetCacheViewAuthenticPixels(swirl_view,0,y,swirl_image->columns,1,
+    q=QueueCacheViewAuthenticPixels(swirl_view,0,y,swirl_image->columns,1,
       exception);
     if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
       {
@@ -5093,22 +5150,43 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
     delta.y=scale.y*(double) (y-center.y);
     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(swirl_image);
+          continue;
+        }
       delta.x=scale.x*(double) (x-center.x);
       distance=delta.x*delta.x+delta.y*delta.y;
       if (distance >= (radius*radius))
         {
+          register ssize_t
+            i;
+
           for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
-            q[i]=p[i];
+          {
+            PixelChannel
+              channel;
+
+            PixelTrait
+              swirl_traits,
+              traits;
+
+            channel=GetPixelChannelChannel(image,i);
+            traits=GetPixelChannelTraits(image,channel);
+            swirl_traits=GetPixelChannelTraits(swirl_image,channel);
+            if ((traits == UndefinedPixelTrait) ||
+                (swirl_traits == UndefinedPixelTrait))
+              continue;
+            SetPixelChannel(swirl_image,channel,p[i],q);
+          }
         }
       else
         {
-          MagickRealType
+          double
             cosine,
             factor,
             sine;
@@ -5134,7 +5212,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)
@@ -5200,12 +5278,11 @@ MagickExport Image *TintImage(const Image *image,const char *blend,
   MagickOffsetType
     progress;
 
-  MagickRealType
+  double
     intensity;
 
   PixelInfo
-    color_vector,
-    pixel;
+    color_vector;
 
   MagickStatusType
     flags;
@@ -5230,46 +5307,55 @@ MagickExport Image *TintImage(const Image *image,const char *blend,
       tint_image=DestroyImage(tint_image);
       return((Image *) NULL);
     }
+  if ((IsGrayColorspace(image->colorspace) != MagickFalse) &&
+      (IsPixelInfoGray(tint) == MagickFalse))
+    (void) SetImageColorspace(tint_image,RGBColorspace,exception);
   if (blend == (const char *) NULL)
     return(tint_image);
   /*
     Determine RGB values of the color.
   */
-  GetPixelInfo(image,&pixel);
+  GetPixelInfo(image,&color_vector);
   flags=ParseGeometry(blend,&geometry_info);
-  pixel.red=geometry_info.rho;
-  pixel.green=geometry_info.rho;
-  pixel.blue=geometry_info.rho;
-  pixel.alpha=OpaqueAlpha;
+  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;
+    color_vector.green=geometry_info.sigma;
   if ((flags & XiValue) != 0)
-    pixel.blue=geometry_info.xi;
+    color_vector.blue=geometry_info.xi;
   if ((flags & PsiValue) != 0)
-    pixel.alpha=geometry_info.psi;
+    color_vector.alpha=geometry_info.psi;
   if (image->colorspace == CMYKColorspace)
     {
-      pixel.black=geometry_info.rho;
+      color_vector.black=geometry_info.rho;
       if ((flags & PsiValue) != 0)
-        pixel.black=geometry_info.psi;
+        color_vector.black=geometry_info.psi;
       if ((flags & ChiValue) != 0)
-        pixel.alpha=geometry_info.chi;
+        color_vector.alpha=geometry_info.chi;
     }
-  intensity=(MagickRealType) GetPixelInfoIntensity(tint);
-  color_vector.red=(MagickRealType) (pixel.red*tint->red/100.0-intensity);
-  color_vector.green=(MagickRealType) (pixel.green*tint->green/100.0-intensity);
-  color_vector.blue=(MagickRealType) (pixel.blue*tint->blue/100.0-intensity);
-  color_vector.black=(MagickRealType) (pixel.black*tint->black/100.0-intensity);
-  color_vector.alpha=(MagickRealType) (pixel.alpha*tint->alpha/100.0-intensity);
+  intensity=(double) GetPixelInfoIntensity(tint);
+  color_vector.red=(double) (color_vector.red*tint->red/100.0-
+    intensity);
+  color_vector.green=(double) (color_vector.green*tint->green/100.0-
+    intensity);
+  color_vector.blue=(double) (color_vector.blue*tint->blue/100.0-
+    intensity);
+  color_vector.black=(double) (color_vector.black*tint->black/100.0-
+    intensity);
+  color_vector.alpha=(double) (color_vector.alpha*tint->alpha/100.0-
+    intensity);
   /*
     Tint image.
   */
   status=MagickTrue;
   progress=0;
-  image_view=AcquireCacheView(image);
-  tint_view=AcquireCacheView(tint_image);
+  image_view=AcquireVirtualCacheView(image,exception);
+  tint_view=AcquireAuthenticCacheView(tint_image,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
@@ -5297,39 +5383,48 @@ MagickExport Image *TintImage(const Image *image,const char *blend,
       PixelInfo
         pixel;
 
-      MagickRealType
+      double
         weight;
 
-      if ((GetPixelRedTraits(tint_image) & UpdatePixelTrait) != 0)
-        {
-          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);
-        }
-      if ((GetPixelGreenTraits(tint_image) & UpdatePixelTrait) != 0)
-        {
-          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);
-        }
-      if ((GetPixelBlueTraits(tint_image) & UpdatePixelTrait) != 0)
-        {
-          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);
-        }
-      if ((GetPixelBlackTraits(tint_image) & UpdatePixelTrait) != 0)
-        {
-          weight=QuantumScale*GetPixelBlack(image,p)-0.5;
-          pixel.black=(MagickRealType) GetPixelBlack(image,p)+
-            color_vector.black*(1.0-(4.0*(weight*weight)));
-          SetPixelBlack(tint_image,ClampToQuantum(pixel.black),q);
-        }
-      if ((GetPixelAlphaTraits(tint_image) & CopyPixelTrait) != 0)
-        SetPixelAlpha(tint_image,GetPixelAlpha(image,p),q);
+      register ssize_t
+        i;
+
+      for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+      {
+        PixelChannel
+          channel;
+
+        PixelTrait
+          tint_traits,
+          traits;
+
+        channel=GetPixelChannelChannel(image,i);
+        traits=GetPixelChannelTraits(image,channel);
+        tint_traits=GetPixelChannelTraits(tint_image,channel);
+        if ((traits == UndefinedPixelTrait) ||
+            (tint_traits == UndefinedPixelTrait))
+          continue;
+        if (((tint_traits & CopyPixelTrait) != 0) ||
+            (GetPixelMask(image,p) != 0))
+          {
+            SetPixelChannel(tint_image,channel,p[i],q);
+            continue;
+          }
+      }
+      GetPixelInfo(image,&pixel);
+      weight=QuantumScale*GetPixelRed(image,p)-0.5;
+      pixel.red=(double) GetPixelRed(image,p)+color_vector.red*(1.0-(4.0*
+        (weight*weight)));
+      weight=QuantumScale*GetPixelGreen(image,p)-0.5;
+      pixel.green=(double) GetPixelGreen(image,p)+color_vector.green*(1.0-(4.0*
+        (weight*weight)));
+      weight=QuantumScale*GetPixelBlue(image,p)-0.5;
+      pixel.blue=(double) GetPixelBlue(image,p)+color_vector.blue*(1.0-(4.0*
+        (weight*weight)));
+      weight=QuantumScale*GetPixelBlack(image,p)-0.5;
+      pixel.black=(double) GetPixelBlack(image,p)+color_vector.black*(1.0-(4.0*
+        (weight*weight)));
+      SetPixelInfoPixel(tint_image,&pixel,q);
       p+=GetPixelChannels(image);
       q+=GetPixelChannels(tint_image);
     }
@@ -5341,7 +5436,7 @@ MagickExport Image *TintImage(const Image *image,const char *blend,
           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)
@@ -5371,7 +5466,7 @@ MagickExport Image *TintImage(const Image *image,const char *blend,
 %  The format of the VignetteImage method is:
 %
 %      Image *VignetteImage(const Image *image,const double radius,
-%        const double sigma,const double bias,const ssize_t x,const ssize_t y,
+%        const double sigma,const ssize_t x,const ssize_t y,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -5382,16 +5477,13 @@ MagickExport Image *TintImage(const Image *image,const char *blend,
 %
 %    o sigma: the standard deviation of the Gaussian, in pixels.
 %
-%    o bias: the bias.
-%
 %    o x, y:  Define the x and y ellipse offset.
 %
 %    o exception: return any errors or warnings in this structure.
 %
 */
 MagickExport Image *VignetteImage(const Image *image,const double radius,
-  const double sigma,const double bias,const ssize_t x,const ssize_t y,
-  ExceptionInfo *exception)
+  const double sigma,const ssize_t x,const ssize_t y,ExceptionInfo *exception)
 {
   char
     ellipse[MaxTextExtent];
@@ -5419,7 +5511,7 @@ MagickExport Image *VignetteImage(const Image *image,const double radius,
       canvas_image=DestroyImage(canvas_image);
       return((Image *) NULL);
     }
-  canvas_image->matte=MagickTrue;
+  canvas_image->alpha_trait=BlendPixelTrait;
   oval_image=CloneImage(canvas_image,canvas_image->columns,canvas_image->rows,
     MagickTrue,exception);
   if (oval_image == (Image *) NULL)
@@ -5435,25 +5527,27 @@ MagickExport Image *VignetteImage(const Image *image,const double radius,
     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);
+  (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,exception);
   draw_info=DestroyDrawInfo(draw_info);
-  blur_image=BlurImage(oval_image,radius,sigma,bias,exception);
+  blur_image=BlurImage(oval_image,radius,sigma,exception);
   oval_image=DestroyImage(oval_image);
   if (blur_image == (Image *) NULL)
     {
       canvas_image=DestroyImage(canvas_image);
       return((Image *) NULL);
     }
-  blur_image->matte=MagickFalse;
-  (void) CompositeImage(canvas_image,IntensityCompositeOp,blur_image,0,0,
-    exception);
+  blur_image->alpha_trait=UndefinedPixelTrait;
+  (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);
+  if (vignette_image != (Image *) NULL)
+    (void) TransformImageColorspace(vignette_image,image->colorspace,exception);
   return(vignette_image);
 }
 \f
@@ -5509,7 +5603,7 @@ MagickExport Image *WaveImage(const Image *image,const double amplitude,
   MagickOffsetType
     progress;
 
-  MagickRealType
+  double
     *sine_map;
 
   register ssize_t
@@ -5537,13 +5631,13 @@ MagickExport Image *WaveImage(const Image *image,const double amplitude,
       return((Image *) NULL);
     }
   if (wave_image->background_color.alpha != OpaqueAlpha)
-    wave_image->matte=MagickTrue;
+    wave_image->alpha_trait=BlendPixelTrait;
   /*
     Allocate sine map.
   */
-  sine_map=(MagickRealType *) AcquireQuantumMemory((size_t) wave_image->columns,
+  sine_map=(double *) AcquireQuantumMemory((size_t) wave_image->columns,
     sizeof(*sine_map));
-  if (sine_map == (MagickRealType *) NULL)
+  if (sine_map == (double *) NULL)
     {
       wave_image=DestroyImage(wave_image);
       ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
@@ -5556,12 +5650,13 @@ MagickExport Image *WaveImage(const Image *image,const double amplitude,
   */
   status=MagickTrue;
   progress=0;
-  image_view=AcquireCacheView(image);
-  wave_view=AcquireCacheView(wave_image);
+  image_view=AcquireVirtualCacheView(image,exception);
+  wave_view=AcquireAuthenticCacheView(wave_image,exception);
   (void) SetCacheViewVirtualPixelMethod(image_view,
     BackgroundVirtualPixelMethod);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(static,4) shared(progress,status)
+  #pragma omp parallel for schedule(static,4) shared(progress,status) \
+    dynamic_number_threads(image,image->columns,image->rows,1)
 #endif
   for (y=0; y < (ssize_t) wave_image->rows; y++)
   {
@@ -5594,7 +5689,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)
@@ -5603,7 +5698,7 @@ MagickExport Image *WaveImage(const Image *image,const double amplitude,
   }
   wave_view=DestroyCacheView(wave_view);
   image_view=DestroyCacheView(image_view);
-  sine_map=(MagickRealType *) RelinquishMagickMemory(sine_map);
+  sine_map=(double *) RelinquishMagickMemory(sine_map);
   if (status == MagickFalse)
     wave_image=DestroyImage(wave_image);
   return(wave_image);