]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/enhance.c
(no commit message)
[imagemagick] / MagickCore / enhance.c
index ce72d778dcb56b3fe8f7e358d25f6b3e28d9ce41..19108a48ce2445d8b3b16367b8630c2c930a4cf6 100644 (file)
 %                    MagickCore Image Enhancement Methods                     %
 %                                                                             %
 %                              Software Design                                %
-%                                John Cristy                                  %
+%                                   Cristy                                    %
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2014 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  %
@@ -888,10 +888,13 @@ MagickExport MagickBooleanType ContrastImage(Image *image,
           green,
           red;
 
+        red=0.0;
+        green=0.0;
+        blue=0.0;
         Contrast(sign,&red,&green,&blue);
         image->colormap[i].red=(MagickRealType) red;
-        image->colormap[i].red=(MagickRealType) red;
-        image->colormap[i].red=(MagickRealType) red;
+        image->colormap[i].green=(MagickRealType) green;
+        image->colormap[i].blue=(MagickRealType) blue;
       }
     }
   /*
@@ -1377,6 +1380,7 @@ MagickExport Image *EnhanceImage(const Image *image,ExceptionInfo *exception)
 
       if (GetPixelReadMask(image,p) == 0)
         {
+          SetPixelBackgoundColor(enhance_image,q);
           p+=GetPixelChannels(image);
           q+=GetPixelChannels(enhance_image);
           continue;
@@ -1489,11 +1493,11 @@ MagickExport MagickBooleanType EqualizeImage(Image *image,
     progress;
 
   double
-    black[CompositePixelChannel],
+    black[CompositePixelChannel+1],
     *equalize_map,
     *histogram,
     *map,
-    white[CompositePixelChannel];
+    white[CompositePixelChannel+1];
 
   register ssize_t
     i;
@@ -1584,6 +1588,8 @@ MagickExport MagickBooleanType EqualizeImage(Image *image,
   }
   (void) ResetMagickMemory(equalize_map,0,(MaxMap+1)*GetPixelChannels(image)*
     sizeof(*equalize_map));
+  (void) ResetMagickMemory(black,0,sizeof(*black));
+  (void) ResetMagickMemory(white,0,sizeof(*white));
   number_channels=GetPixelChannels(image);
   for (i=0; i < (ssize_t) number_channels; i++)
   {
@@ -1972,24 +1978,6 @@ MagickExport MagickBooleanType GrayscaleImage(Image *image,
       if( IfMagickFalse(SetImageStorageClass(image,DirectClass,exception)) )
         return(MagickFalse);
     }
-  switch (image->intensity)
-  {
-    case Rec601LuminancePixelIntensityMethod:
-    case Rec709LuminancePixelIntensityMethod:
-    {
-      (void) SetImageColorspace(image,RGBColorspace,exception);
-      break;
-    }
-    case Rec601LumaPixelIntensityMethod:
-    case Rec709LumaPixelIntensityMethod:
-    case UndefinedPixelIntensityMethod:
-    {
-      (void) SetImageColorspace(image,sRGBColorspace,exception);
-      break;
-    }
-    default:
-      break;
-  }
   /*
     Grayscale image.
   */
@@ -2488,6 +2476,7 @@ MagickExport MagickBooleanType LevelImage(Image *image,const double black_point,
       }
   }
   image_view=DestroyCacheView(image_view);
+  (void) ClampImage(image,exception);
   return(status);
 }
 \f
@@ -2713,21 +2702,21 @@ MagickExport MagickBooleanType LevelImageColors(Image *image,
       if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
         {
           channel_mask=SetImageChannelMask(image,RedChannel);
-          status|=LevelImage(image,black_color->red,white_color->red,1.0,
+          status&=LevelImage(image,black_color->red,white_color->red,1.0,
             exception);
           (void) SetImageChannelMask(image,channel_mask);
         }
       if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
         {
           channel_mask=SetImageChannelMask(image,GreenChannel);
-          status|=LevelImage(image,black_color->green,white_color->green,1.0,
+          status&=LevelImage(image,black_color->green,white_color->green,1.0,
             exception);
           (void) SetImageChannelMask(image,channel_mask);
         }
       if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
         {
           channel_mask=SetImageChannelMask(image,BlueChannel);
-          status|=LevelImage(image,black_color->blue,white_color->blue,1.0,
+          status&=LevelImage(image,black_color->blue,white_color->blue,1.0,
             exception);
           (void) SetImageChannelMask(image,channel_mask);
         }
@@ -2735,7 +2724,7 @@ MagickExport MagickBooleanType LevelImageColors(Image *image,
           (image->colorspace == CMYKColorspace))
         {
           channel_mask=SetImageChannelMask(image,BlackChannel);
-          status|=LevelImage(image,black_color->black,white_color->black,1.0,
+          status&=LevelImage(image,black_color->black,white_color->black,1.0,
             exception);
           (void) SetImageChannelMask(image,channel_mask);
         }
@@ -2743,7 +2732,7 @@ MagickExport MagickBooleanType LevelImageColors(Image *image,
           (image->alpha_trait == BlendPixelTrait))
         {
           channel_mask=SetImageChannelMask(image,AlphaChannel);
-          status|=LevelImage(image,black_color->alpha,white_color->alpha,1.0,
+          status&=LevelImage(image,black_color->alpha,white_color->alpha,1.0,
             exception);
           (void) SetImageChannelMask(image,channel_mask);
         }
@@ -2753,21 +2742,21 @@ MagickExport MagickBooleanType LevelImageColors(Image *image,
       if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
         {
           channel_mask=SetImageChannelMask(image,RedChannel);
-          status|=LevelizeImage(image,black_color->red,white_color->red,1.0,
+          status&=LevelizeImage(image,black_color->red,white_color->red,1.0,
             exception);
           (void) SetImageChannelMask(image,channel_mask);
         }
       if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
         {
           channel_mask=SetImageChannelMask(image,GreenChannel);
-          status|=LevelizeImage(image,black_color->green,white_color->green,1.0,
+          status&=LevelizeImage(image,black_color->green,white_color->green,1.0,
             exception);
           (void) SetImageChannelMask(image,channel_mask);
         }
       if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
         {
           channel_mask=SetImageChannelMask(image,BlueChannel);
-          status|=LevelizeImage(image,black_color->blue,white_color->blue,1.0,
+          status&=LevelizeImage(image,black_color->blue,white_color->blue,1.0,
             exception);
           (void) SetImageChannelMask(image,channel_mask);
         }
@@ -2775,7 +2764,7 @@ MagickExport MagickBooleanType LevelImageColors(Image *image,
           (image->colorspace == CMYKColorspace))
         {
           channel_mask=SetImageChannelMask(image,BlackChannel);
-          status|=LevelizeImage(image,black_color->black,white_color->black,1.0,
+          status&=LevelizeImage(image,black_color->black,white_color->black,1.0,
             exception);
           (void) SetImageChannelMask(image,channel_mask);
         }
@@ -2783,7 +2772,7 @@ MagickExport MagickBooleanType LevelImageColors(Image *image,
           (image->alpha_trait == BlendPixelTrait))
         {
           channel_mask=SetImageChannelMask(image,AlphaChannel);
-          status|=LevelizeImage(image,black_color->alpha,white_color->alpha,1.0,
+          status&=LevelizeImage(image,black_color->alpha,white_color->alpha,1.0,
             exception);
           (void) SetImageChannelMask(image,channel_mask);
         }