]> granicus.if.org Git - imagemagick/commitdiff
Added blueShift, brightnessContrast, clamp, clut, contrastStretch to Magick++.
authordirk <dirk@git.imagemagick.org>
Sat, 3 Aug 2013 07:47:08 +0000 (07:47 +0000)
committerdirk <dirk@git.imagemagick.org>
Sat, 3 Aug 2013 07:47:08 +0000 (07:47 +0000)
Code cleanup.

Magick++/lib/Image.cpp
Magick++/lib/Magick++/Image.h
Magick++/lib/Magick++/Include.h

index dcd2886d4066ee8abcae2adbb0686cb51a130056..98e52cc11e3c4930c25f8a2812bc986da97dedbb 100644 (file)
@@ -424,6 +424,7 @@ void Magick::Image::annotate ( const std::string &text_,
 {
   annotate ( text_, location_,  NorthWestGravity, 0.0 );
 }
+
 // Annotate using specified text, bounding area, and placement gravity
 void Magick::Image::annotate ( const std::string &text_,
                                const Geometry &boundingArea_,
@@ -431,6 +432,7 @@ void Magick::Image::annotate ( const std::string &text_,
 {
   annotate ( text_, boundingArea_, gravity_, 0.0 );
 }
+
 // Annotate with text using specified text, bounding area, placement
 // gravity, and rotation.
 void Magick::Image::annotate ( const std::string &text_,
@@ -502,6 +504,7 @@ void Magick::Image::annotate ( const std::string &text_,
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
+
 // Annotate with text (bounding area is entire image) and placement gravity.
 void Magick::Image::annotate ( const std::string &text_,
                                const GravityType gravity_ )
@@ -623,6 +626,17 @@ void Magick::Image::blackThresholdChannel ( const ChannelType channel_,
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
+void Magick::Image::blueShift ( const double factor_ )
+{
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  MagickCore::Image* newImage =
+    BlueShiftImage( constImage(), factor_, &exceptionInfo );
+  replaceImage( newImage );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
 // Blur image
 void Magick::Image::blur ( const double radius_, const double sigma_ )
 {
@@ -657,20 +671,44 @@ void Magick::Image::border( const Geometry &geometry_ )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    BorderImage( image(), &borderInfo, image()->compose, &exceptionInfo);
+    BorderImage( image(), &borderInfo, image()->compose, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
+void Magick::Image::brightnessContrast ( const double brightness_,
+                                         const double contrast_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  BrightnessContrastImage( image(), brightness_, contrast_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+void Magick::Image::brightnessContrastChannel ( const ChannelType channel_,
+                                                const double brightness_,
+                                                const double contrast_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
+  BrightnessContrastImage( image(), brightness_, contrast_, &exceptionInfo );
+  (void) SetPixelChannelMask( image(), channel_mask );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
 // Extract channel from image
 void Magick::Image::channel ( const ChannelType channel_ )
 {
-  modifyImage();
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    SeparateImage( image(), channel_, &exceptionInfo);
+    SeparateImage( image(), channel_, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -682,10 +720,11 @@ void Magick::Image::channelDepth ( const size_t depth_ )
   modifyImage();
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  SetImageDepth( image(), depth_, &exceptionInfo);
+  SetImageDepth( image(), depth_, &exceptionInfo );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
+
 size_t Magick::Image::channelDepth ( )
 {
   size_t channel_depth;
@@ -698,9 +737,8 @@ size_t Magick::Image::channelDepth ( )
   return channel_depth;
 }
 
-
 // Charcoal-effect image
-void Magick::Image::charcoal( const double radius_, const double sigma_ )
+void Magick::Image::charcoal ( const double radius_, const double sigma_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
@@ -712,13 +750,13 @@ void Magick::Image::charcoal( const double radius_, const double sigma_ )
 }
 
 // Chop image
-void Magick::Image::chop( const Geometry &geometry_ )
+void Magick::Image::chop ( const Geometry &geometry_ )
 {
   RectangleInfo chopInfo = geometry_;
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    ChopImage( image(), &chopInfo, &exceptionInfo);
+    ChopImage( image(), &chopInfo, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -736,20 +774,65 @@ void Magick::Image::cdl ( const std::string &cdl_ )
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
+void Magick::Image::clamp ( void )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  ClampImage( image(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+void Magick::Image::clampChannel ( const ChannelType channel_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
+  ClampImage( image(), &exceptionInfo );
+  (void) SetPixelChannelMask( image(), channel_mask );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+void Magick::Image::clut ( const Image &clutImage_,
+                           const PixelInterpolateMethod method )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  ClutImage( image(), clutImage_.constImage(), method, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+void Magick::Image::clutChannel ( const Image &clutImage_,
+                                  const PixelInterpolateMethod method,
+                                  const ChannelType channel_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
+  ClutImage( image(), clutImage_.constImage(), method, &exceptionInfo );
+  (void) SetPixelChannelMask( image(), channel_mask );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
 // Colorize
 void Magick::Image::colorize ( const unsigned int alphaRed_,
                                const unsigned int alphaGreen_,
                                const unsigned int alphaBlue_,
-                              const Color &penColor_ )
+                               const Color &penColor_ )
 {
   if ( !penColor_.isValid() )
-  {
-    throwExceptionExplicit( OptionError,
-                           "Pen color argument is invalid");
-  }
+    throwExceptionExplicit( OptionError, "Pen color argument is invalid" );
 
   char blend[MaxTextExtent];
-  FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,alphaBlue_);
+  FormatLocaleString( blend, MaxTextExtent, "%u/%u/%u",
+                      alphaRed_, alphaGreen_, alphaBlue_ );
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
@@ -766,16 +849,17 @@ void Magick::Image::colorize ( const unsigned int alphaRed_,
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
+
 void Magick::Image::colorize ( const unsigned int alpha_,
-                              const Color &penColor_ )
+                               const Color &penColor_ )
 {
   colorize( alpha_, alpha_, alpha_, penColor_ );
 }
 
 // Apply a color matrix to the image channels.  The user supplied
 // matrix may be of order 1 to 6 (1x1 through 6x6).
-void Magick::Image::colorMatrix (const size_t order_,
-         const double *color_matrix_)
+void Magick::Image::colorMatrix ( const size_t order_,
+                                  const double *color_matrix_ )
 {
   KernelInfo
     *kernel_info;
@@ -819,9 +903,9 @@ bool Magick::Image::compare ( const Image &reference_ )
 
 // Composite two images
 void Magick::Image::composite ( const Image &compositeImage_,
-                               const ssize_t xOffset_,
-                               const ssize_t yOffset_,
-                               const CompositeOperator compose_ )
+                                const ssize_t xOffset_,
+                                const ssize_t yOffset_,
+                                const CompositeOperator compose_ )
 {
   // Image supplied as compositeImage is composited with current image and
   // results in updating current image.
@@ -829,17 +913,15 @@ void Magick::Image::composite ( const Image &compositeImage_,
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  CompositeImage( image(),
-                 compositeImage_.constImage(),
-                 compose_, MagickFalse,
-                 xOffset_,
-                  yOffset_, &exceptionInfo );
+  CompositeImage( image(), compositeImage_.constImage(), compose_, MagickFalse,
+                  xOffset_, yOffset_, &exceptionInfo );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
+
 void Magick::Image::composite ( const Image &compositeImage_,
-                               const Geometry &offset_,
-                               const CompositeOperator compose_ )
+                                const Geometry &offset_,
+                                const CompositeOperator compose_ )
 {
   modifyImage();
 
@@ -848,22 +930,21 @@ void Magick::Image::composite ( const Image &compositeImage_,
   size_t width = columns();
   size_t height = rows();
 
-  ParseMetaGeometry (static_cast<std::string>(offset_).c_str(),
-                     &x, &y,
-                     &width, &height );
+  ParseMetaGeometry ( static_cast<std::string>(offset_).c_str(),
+                      &x, &y,
+                      &width, &height );
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  CompositeImage( image(),
-                 compositeImage_.constImage(),
-                 compose_, MagickFalse,
-                 x, y, &exceptionInfo );
+  CompositeImage( image(), compositeImage_.constImage(), compose_, MagickFalse,
+                  x, y, &exceptionInfo );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
+
 void Magick::Image::composite ( const Image &compositeImage_,
-                               const GravityType gravity_,
-                               const CompositeOperator compose_ )
+                                const GravityType gravity_,
+                                const CompositeOperator compose_ )
 {
   modifyImage();
 
@@ -874,10 +955,8 @@ void Magick::Image::composite ( const Image &compositeImage_,
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  CompositeImage( image(),
-                 compositeImage_.constImage(),
-                 compose_, MagickFalse,
-                 geometry.x, geometry.y, &exceptionInfo );
+  CompositeImage( image(), compositeImage_.constImage(), compose_, MagickFalse,
+                  geometry.x, geometry.y, &exceptionInfo );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
@@ -893,6 +972,31 @@ void Magick::Image::contrast ( const size_t sharpen_ )
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
+void Magick::Image::contrastStretch ( const double black_point_,
+                                      const double white_point_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  ContrastStretchImage ( image(), black_point_, white_point_, &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+void Magick::Image::contrastStretchChannel ( const ChannelType channel_,
+                                             const double black_point_,
+                                             const double white_point_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
+  ContrastStretchImage ( image(), black_point_, white_point_, &exceptionInfo );
+  (void) SetPixelChannelMask( image(), channel_mask );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
 // Convolve image.  Applies a general image convolution kernel to the image.
 //  order_ represents the number of columns and rows in the filter kernel.
 //  kernel_ is an array of doubles representing the convolution kernel.
index 5ec9f905a1fadb9fe5cae2dce44bb922fbc3539c..22d025220412b36eb8c4e28ad7c01b5e709d33e2 100644 (file)
@@ -205,6 +205,9 @@ namespace Magick
     void            blackThresholdChannel ( const ChannelType channel_,
                                             const std::string &threshold_ );
 
+     // Simulate a scene at nighttime in the moonlight.
+    void            blueShift ( const double factor_ = 1.5 );
+
     // Blur image with specified blur factor
     // The radius_ parameter specifies the radius of the Gaussian, in
     // pixels, not counting the center pixel.  The sigma_ parameter
@@ -219,12 +222,21 @@ namespace Magick
     void            border ( const Geometry &geometry_
                              = borderGeometryDefault );
 
+    // Changes the brightness and/or contrast of an image. It converts the
+    // brightness and contrast parameters into slope and intercept and calls
+    // a polynomical function to apply to the image.
+    void            brightnessContrast ( const double brightness_ = 0.0,
+                                         const double contrast_ = 0.0);
+    void            brightnessContrastChannel ( const ChannelType channel_,
+                                                const double brightness_ = 0.0,
+                                                const double contrast_ = 0.0 );
+
     // Extract channel from image
     void            channel ( const ChannelType channel_ );
 
     // Set or obtain modulus channel depth
     void            channelDepth ( const size_t depth_ );
-    size_t    channelDepth ( );
+    size_t          channelDepth ( );
 
     // Charcoal effect image (looks like charcoal sketch)
     // The radius_ parameter specifies the radius of the Gaussian, in
@@ -243,29 +255,34 @@ namespace Magick
     // (CCC) file which solely contains one or more color corrections and
     // applies the correction to the image.
     void            cdl ( const std::string &cdl_ );
-    
+
+    // Set each pixel whose value is below zero to zero and any the
+    // pixel whose value is above the quantum range to the quantum range (e.g.
+    // 65535) otherwise the pixel value remains unchanged.
+    void            clamp ( void );
+    void            clampChannel ( const ChannelType channel_ );
+
+    // Apply a color lookup table (CLUT) to the image.
+    void            clut ( const Image &clutImage_,
+                           const PixelInterpolateMethod method );
+    void            clutChannel ( const Image &clutImage_,
+                                  const PixelInterpolateMethod method,
+                                  const ChannelType channel_ );
+
     // Colorize image with pen color, using specified percent alpha
     // for red, green, and blue quantums
     void            colorize ( const unsigned int alphaRed_,
                                const unsigned int alphaGreen_,
                                const unsigned int alphaBlue_,
-             const Color &penColor_ );
+                               const Color &penColor_ );
     // Colorize image with pen color, using specified percent alpha.
     void            colorize ( const unsigned int alpha_,
-             const Color &penColor_ );
+                               const Color &penColor_ );
     
     // Apply a color matrix to the image channels.  The user supplied
     // matrix may be of order 1 to 5 (1x1 through 5x5).
-    void            colorMatrix (const size_t order_,
-         const double *color_matrix_);
-
-    // Comment image (add comment string to image)
-    void            comment ( const std::string &comment_ );
-
-    // Composition operator to be used when composition is implicitly
-    // used (such as for image flattening).
-    void            compose (const CompositeOperator compose_);
-    CompositeOperator compose ( void ) const;
+    void            colorMatrix ( const size_t order_,
+                                  const double *color_matrix_);
 
     // Compare current image with another image
     // Sets meanErrorPerPixel, normalizedMaxError, and normalizedMeanError
@@ -275,22 +292,34 @@ namespace Magick
     // Compose an image onto another at specified offset and using
     // specified algorithm
     void            composite ( const Image &compositeImage_,
-        const ::ssize_t xOffset_,
-        const ::ssize_t yOffset_,
-        const CompositeOperator compose_
-                                = InCompositeOp );
+                                const ::ssize_t xOffset_,
+                                const ::ssize_t yOffset_,
+                                const CompositeOperator compose_
+                                  = InCompositeOp );
     void            composite ( const Image &compositeImage_,
-        const Geometry &offset_,
-        const CompositeOperator compose_
-                                = InCompositeOp );
+                                const Geometry &offset_,
+                                const CompositeOperator compose_
+                                  = InCompositeOp );
     void            composite ( const Image &compositeImage_,
-        const GravityType gravity_,
-        const CompositeOperator compose_
-                                = InCompositeOp );
-    
+                                const GravityType gravity_,
+                                const CompositeOperator compose_
+                                  = InCompositeOp );
+
     // Contrast image (enhance intensity differences in image)
     void            contrast ( const size_t sharpen_ );
 
+    // A simple image enhancement technique that attempts to improve the
+    // contrast in an image by 'stretching' the range of intensity values
+    // it contains to span a desired range of values. It differs from the
+    // more sophisticated histogram equalization in that it can only apply a
+    // linear scaling function to the image pixel values. As a result the
+    // 'enhancement' is less harsh.
+    void            contrastStretch ( const double black_point_,
+                                      const double white_point_ );
+    void            contrastStretchChannel ( const ChannelType channel_,
+                                             const double black_point_,
+                                             const double white_point_ );
+
     // Convolve image.  Applies a user-specified convolution to the image.
     //  order_ represents the number of columns and rows in the filter kernel.
     //  kernel_ is an array of doubles representing the convolution kernel.
@@ -909,11 +938,17 @@ namespace Magick
     ColorspaceType  colorspaceType ( void ) const;
 
     // Image width
-    size_t    columns ( void ) const;
-    
-    // Image comment
+    size_t          columns ( void ) const;
+
+    // Comment image (add comment string to image)
+    void            comment ( const std::string &comment_ );
     std::string     comment ( void ) const;
-    
+
+    // Composition operator to be used when composition is implicitly
+    // used (such as for image flattening).
+    void              compose ( const CompositeOperator compose_ );
+    CompositeOperator compose ( void ) const;
+
     // Compression type
     void            compressType ( const CompressionType compressType_ );
     CompressionType compressType ( void ) const;
index 347df43ccd0bdefeba779b240373c62a524eb3a8..34359f243a45e5ef8855cc929fa8dc00c477b203 100644 (file)
@@ -533,6 +533,21 @@ namespace Magick
   using MagickCore::FillToBorderMethod;
   using MagickCore::ResetMethod;
 
+  // PixelInterpolate methods
+  using MagickCore::PixelInterpolateMethod;
+  using MagickCore::UndefinedInterpolatePixel;
+  using MagickCore::AverageInterpolatePixel;
+  using MagickCore::Average9InterpolatePixel;
+  using MagickCore::Average16InterpolatePixel;
+  using MagickCore::BackgroundInterpolatePixel;
+  using MagickCore::BilinearInterpolatePixel;
+  using MagickCore::BlendInterpolatePixel;
+  using MagickCore::CatromInterpolatePixel;
+  using MagickCore::IntegerInterpolatePixel;
+  using MagickCore::MeshInterpolatePixel;
+  using MagickCore::NearestInterpolatePixel;
+  using MagickCore::SplineInterpolatePixel;
+
   // Pixel traits
   using MagickCore::UndefinedPixelTrait;
   using MagickCore::BlendPixelTrait;