]> granicus.if.org Git - imagemagick/commitdiff
Added black/white threshold to Magick++.
authordirk <dirk@git.imagemagick.org>
Thu, 1 Aug 2013 20:21:45 +0000 (20:21 +0000)
committerdirk <dirk@git.imagemagick.org>
Thu, 1 Aug 2013 20:21:45 +0000 (20:21 +0000)
Code cleanup.

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

index 198aac83a163861737414df46825302e870a7c28..dcd2886d4066ee8abcae2adbb0686cb51a130056 100644 (file)
@@ -41,39 +41,39 @@ static bool magick_initialized=false;
 //
 
 MagickPPExport int Magick::operator == ( const Magick::Image& left_,
-                                        const Magick::Image& right_ )
+                                         const Magick::Image& right_ )
 {
   // If image pixels and signature are the same, then the image is identical
   return ( ( left_.rows() == right_.rows() ) &&
-          ( left_.columns() == right_.columns() ) &&
-          ( left_.signature() == right_.signature() )
-          );
+           ( left_.columns() == right_.columns() ) &&
+           ( left_.signature() == right_.signature() )
+         );
 }
 MagickPPExport int Magick::operator != ( const Magick::Image& left_,
-                                        const Magick::Image& right_ )
+                                         const Magick::Image& right_ )
 {
   return ( ! (left_ == right_) );
 }
 MagickPPExport int Magick::operator >  ( const Magick::Image& left_,
-                                        const Magick::Image& right_ )
+                                         const Magick::Image& right_ )
 {
   return ( !( left_ < right_ ) && ( left_ != right_ ) );
 }
 MagickPPExport int Magick::operator <  ( const Magick::Image& left_,
-                                        const Magick::Image& right_ )
+                                         const Magick::Image& right_ )
 {
   // If image pixels are less, then image is smaller
   return ( ( left_.rows() * left_.columns() ) <
-          ( right_.rows() * right_.columns() )
-          );
+           ( right_.rows() * right_.columns() )
+         );
 }
 MagickPPExport int Magick::operator >= ( const Magick::Image& left_,
-                                        const Magick::Image& right_ )
+                                         const Magick::Image& right_ )
 {
   return ( ( left_ > right_ ) || ( left_ == right_ ) );
 }
 MagickPPExport int Magick::operator <= ( const Magick::Image& left_,
-                                        const Magick::Image& right_ )
+                                         const Magick::Image& right_ )
 {
   return ( ( left_ < right_ ) || ( left_ == right_ ) );
 }
@@ -83,7 +83,7 @@ MagickPPExport int Magick::operator <= ( const Magick::Image& left_,
 //
 
 // Construct from image file or image specification
-Magick::Image::Image( const std::string &imageSpec_ )
+Magick::Image::Image ( const std::string &imageSpec_ )
   : _imgRef(new ImageRef)
 {
   try
@@ -104,8 +104,8 @@ Magick::Image::Image( const std::string &imageSpec_ )
 }
 
 // Construct a blank image canvas of specified size and color
-Magick::Image::Image( const Geometry &size_,
-                     const Color &color_ )
+Magick::Image::Image ( const Geometry &size_,
+                       const Color &color_ )
   : _imgRef(new ImageRef)
 {
   // xc: prefix specifies an X11 color string
@@ -155,7 +155,7 @@ Magick::Image::Image ( const Blob &blob_ )
 
 // Construct Image of specified size from in-memory BLOB
 Magick::Image::Image ( const Blob &blob_,
-                      const Geometry &size_ )
+                       const Geometry &size_ )
   : _imgRef(new ImageRef)
 {
   try
@@ -177,8 +177,8 @@ Magick::Image::Image ( const Blob &blob_,
 
 // Construct Image of specified size and depth from in-memory BLOB
 Magick::Image::Image ( const Blob &blob_,
-                      const Geometry &size_,
-                      const size_t depth_ )
+                       const Geometry &size_,
+                       const size_t depth_ )
   : _imgRef(new ImageRef)
 {
   try
@@ -200,9 +200,9 @@ Magick::Image::Image ( const Blob &blob_,
 
 // Construct Image of specified size, depth, and format from in-memory BLOB
 Magick::Image::Image ( const Blob &blob_,
-                      const Geometry &size_,
-                      const size_t depth_,
-                      const std::string &magick_ )
+                       const Geometry &size_,
+                       const size_t depth_,
+                       const std::string &magick_ )
   : _imgRef(new ImageRef)
 {
   try
@@ -224,8 +224,8 @@ Magick::Image::Image ( const Blob &blob_,
 
 // Construct Image of specified size, and format from in-memory BLOB
 Magick::Image::Image ( const Blob &blob_,
-                      const Geometry &size_,
-                      const std::string &magick_ )
+                       const Geometry &size_,
+                       const std::string &magick_ )
   : _imgRef(new ImageRef)
 {
   try
@@ -271,7 +271,7 @@ Magick::Image::Image ( const size_t width_,
 }
 
 // Default constructor
-Magick::Image::Image( void )
+Magick::Image::Image ( void )
   : _imgRef(new ImageRef)
 {
 }
@@ -295,12 +295,12 @@ Magick::Image::~Image()
 }
 
 // Adaptive-blur image
-void Magick::Image::adaptiveBlur( const double radius_, const double sigma_ )
+void Magick::Image::adaptiveBlur ( const double radius_, const double sigma_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    AdaptiveBlurImage( image(), radius_, sigma_, &exceptionInfo);
+    AdaptiveBlurImage( constImage(), radius_, sigma_, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -364,36 +364,33 @@ void Magick::Image::adaptiveThreshold ( const size_t width_,
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    AdaptiveThresholdImage( constImage(), width_, height_, offset_, &exceptionInfo );
+    AdaptiveThresholdImage( constImage(), width_, height_, offset_,
+                            &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Add noise to image
-void Magick::Image::addNoise( const NoiseType noiseType_ )
+void Magick::Image::addNoise ( const NoiseType noiseType_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    AddNoiseImage ( image(),
-                   noiseType_, 1.0,
-                   &exceptionInfo );
+    AddNoiseImage ( constImage(), noiseType_, 1.0, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
-void Magick::Image::addNoiseChannel( const ChannelType channel_,
+void Magick::Image::addNoiseChannel ( const ChannelType channel_,
                                      const NoiseType noiseType_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   ChannelType channel_mask = SetImageChannelMask( image(), channel_);
   MagickCore::Image* newImage =
-    AddNoiseImage ( image(),
-                           noiseType_, 1.0,
-                           &exceptionInfo );
+    AddNoiseImage ( constImage(), noiseType_, 1.0, &exceptionInfo );
   (void) SetPixelChannelMask( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
@@ -405,17 +402,17 @@ void Magick::Image::affineTransform ( const DrawableAffine &affine_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  
+
   AffineMatrix _affine;
   _affine.sx = affine_.sx();
   _affine.sy = affine_.sy();
   _affine.rx = affine_.rx();
   _affine.ry = affine_.ry();
-  _affine.tx = affine_.tx();  
+  _affine.tx = affine_.tx();
   _affine.ty = affine_.ty();
-  
+
   MagickCore::Image* newImage =
-    AffineTransformImage( image(), &_affine, &exceptionInfo);     
+    AffineTransformImage( constImage(), &_affine, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -423,23 +420,23 @@ void Magick::Image::affineTransform ( const DrawableAffine &affine_ )
 
 // Annotate using specified text, and placement location
 void Magick::Image::annotate ( const std::string &text_,
-                              const Geometry &location_ )
+                               const Geometry &location_ )
 {
   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_,
-                              const GravityType gravity_ )
+                               const Geometry &boundingArea_,
+                               const GravityType gravity_ )
 {
   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_,
-                              const Geometry &boundingArea_,
-                              const GravityType gravity_,
-                              const double degrees_ )
+                               const Geometry &boundingArea_,
+                               const GravityType gravity_,
+                               const double degrees_ )
 {
   modifyImage();
 
@@ -451,19 +448,20 @@ void Magick::Image::annotate ( const std::string &text_,
   char boundingArea[MaxTextExtent];
 
   drawInfo->geometry = 0;
-  if ( boundingArea_.isValid() ){
-    if ( boundingArea_.width() == 0 || boundingArea_.height() == 0 )
-      {
-        FormatLocaleString( boundingArea, MaxTextExtent, "%+.20g%+.20g",
-          (double) boundingArea_.xOff(), (double) boundingArea_.yOff() );
-      }
-    else
-      {
-        (void) CopyMagickString( boundingArea, string(boundingArea_).c_str(),
-          MaxTextExtent);
-      }
-    drawInfo->geometry = boundingArea;
-  }
+  if ( boundingArea_.isValid() )
+   {
+     if ( boundingArea_.width() == 0 || boundingArea_.height() == 0 )
+       {
+         FormatLocaleString( boundingArea, MaxTextExtent, "%+.20g%+.20g",
+           (double) boundingArea_.xOff(), (double) boundingArea_.yOff() );
+       }
+     else
+       {
+         (void) CopyMagickString( boundingArea, string(boundingArea_).c_str(),
+           MaxTextExtent);
+       }
+     drawInfo->geometry = boundingArea;
+   }
 
   drawInfo->gravity = gravity_;
 
@@ -506,7 +504,7 @@ void Magick::Image::annotate ( const std::string &text_,
 }
 // Annotate with text (bounding area is entire image) and placement gravity.
 void Magick::Image::annotate ( const std::string &text_,
-                              const GravityType gravity_ )
+                               const GravityType gravity_ )
 {
   modifyImage();
 
@@ -548,7 +546,7 @@ void Magick::Image::autoGamma ( void )
   modifyImage();
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  AutoGammaImage( image(), &exceptionInfo);
+  AutoGammaImage( image(), &exceptionInfo );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
@@ -559,7 +557,7 @@ void Magick::Image::autoGammaChannel ( const ChannelType channel_ )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
-  AutoGammaImage( image(), &exceptionInfo);
+  AutoGammaImage( image(), &exceptionInfo );
   (void) SetPixelChannelMask( image(), channel_mask );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -596,32 +594,55 @@ void Magick::Image::autoOrient ( void )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    AutoOrientImage( constImage(), image()->orientation, &exceptionInfo);
+    AutoOrientImage( constImage(), image()->orientation, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
+void Magick::Image::blackThreshold ( const std::string &threshold_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  BlackThresholdImage( image(), threshold_.c_str(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+void Magick::Image::blackThresholdChannel ( const ChannelType channel_,
+                                            const std::string &threshold_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
+  BlackThresholdImage( image(), threshold_.c_str(), &exceptionInfo );
+  (void) SetPixelChannelMask( image(), channel_mask );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
 // Blur image
-void Magick::Image::blur( const double radius_, const double sigma_ )
+void Magick::Image::blur ( const double radius_, const double sigma_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    BlurImage( image(), radius_, sigma_, &exceptionInfo);
+    BlurImage( constImage(), radius_, sigma_, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
-void Magick::Image::blurChannel( const ChannelType channel_,
-                                 const double radius_, const double sigma_ )
+void Magick::Image::blurChannel ( const ChannelType channel_,
+                                  const double radius_, const double sigma_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
   MagickCore::Image* newImage =
-    BlurImage( image(), radius_, sigma_, &exceptionInfo);
+    BlurImage( constImage(), radius_, sigma_, &exceptionInfo );
   (void) SetPixelChannelMask( image(), channel_mask );
   replaceImage( newImage );
   throwException( exceptionInfo );
@@ -2448,24 +2469,44 @@ void Magick::Image::wave ( const double amplitude_, const double wavelength_ )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    WaveImage( image(),
-              amplitude_,
-              wavelength_,
-              image()->interpolate,
-              &exceptionInfo);
+    WaveImage( constImage(),  amplitude_, wavelength_, image()->interpolate,
+               &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
+void Magick::Image::whiteThreshold ( const std::string &threshold_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  WhiteThresholdImage( image(), threshold_.c_str(), &exceptionInfo );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+void Magick::Image::whiteThresholdChannel ( const ChannelType channel_,
+                                            const std::string &threshold_ )
+{
+  modifyImage();
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  ChannelType channel_mask = SetImageChannelMask( image(), channel_ );
+  WhiteThresholdImage( image(), threshold_.c_str(), &exceptionInfo );
+  (void) SetPixelChannelMask( image(), channel_mask );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
 // Write image to file
-void Magick::Image::write( const std::string &imageSpec_ )
+void Magick::Image::write ( const std::string &imageSpec_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   modifyImage();
   fileName( imageSpec_ );
-  WriteImage( imageInfo(), image(), &exceptionInfo );
+  WriteImage( constImageInfo(), image(), &exceptionInfo );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
@@ -2477,35 +2518,31 @@ void Magick::Image::write ( Blob *blob_ )
   size_t length = 2048; // Efficient size for small images
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  void* data = ImagesToBlob( imageInfo(),
-                           image(),
-                           &length,
-                           &exceptionInfo);
+  void* data = ImagesToBlob( constImageInfo(), image(), &length,
+                             &exceptionInfo);
   throwException( exceptionInfo );
   blob_->updateNoCopy( data, length, Blob::MallocAllocator );
   throwImageException();
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 void Magick::Image::write ( Blob *blob_,
-                           const std::string &magick_ )
+                            const std::string &magick_ )
 {
   modifyImage();
   magick(magick_);
   size_t length = 2048; // Efficient size for small images
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  void* data = ImagesToBlob( imageInfo(),
-                           image(),
-                           &length,
-                           &exceptionInfo);
+  void* data = ImagesToBlob( constImageInfo(), image(), &length,
+                             &exceptionInfo );
   throwException( exceptionInfo );
   blob_->updateNoCopy( data, length, Blob::MallocAllocator );
   throwImageException();
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 void Magick::Image::write ( Blob *blob_,
-                           const std::string &magick_,
-                           const size_t depth_ )
+                            const std::string &magick_,
+                            const size_t depth_ )
 {
   modifyImage();
   magick(magick_);
@@ -2513,10 +2550,8 @@ void Magick::Image::write ( Blob *blob_,
   size_t length = 2048; // Efficient size for small images
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  void* data = ImagesToBlob( imageInfo(),
-                           image(),
-                           &length,
-                           &exceptionInfo);
+  void* data = ImagesToBlob( constImageInfo(), image(), &length,
+                             &exceptionInfo );
   throwException( exceptionInfo );
   blob_->updateNoCopy( data, length, Blob::MallocAllocator );
   throwImageException();
@@ -2537,14 +2572,14 @@ void Magick::Image::write ( const ssize_t x_,
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   ExportImagePixels( image(), x_, y_, columns_, rows_, map_.c_str(), type_,
-                 pixels_,
+                     pixels_,
     &exceptionInfo);
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
 // Zoom image
-void Magick::Image::zoom( const Geometry &geometry_ )
+void Magick::Image::zoom ( const Geometry &geometry_ )
 {
   // Calculate new size.  This code should be supported using binary arguments
   // in the ImageMagick library.
@@ -2560,11 +2595,7 @@ void Magick::Image::zoom( const Geometry &geometry_ )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
-    ResizeImage( image(),
-               width,
-               height,
-               image()->filter,
-               &exceptionInfo);
+    ResizeImage( constImage(), width, height, image()->filter, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
index 537b952c7b81cbaa3ad6b95a9ad721d915ebd453..5ec9f905a1fadb9fe5cae2dce44bb922fbc3539c 100644 (file)
@@ -31,20 +31,20 @@ namespace Magick
   // Compare two Image objects regardless of LHS/RHS
   // Image sizes and signatures are used as basis of comparison
   int MagickPPExport operator == ( const Magick::Image& left_,
-                                  const Magick::Image& right_ );
+                                   const Magick::Image& right_ );
   int MagickPPExport operator != ( const Magick::Image& left_,
-                                  const Magick::Image& right_ );
+                                   const Magick::Image& right_ );
   int MagickPPExport operator >  ( const Magick::Image& left_,
-                                  const Magick::Image& right_ );
+                                   const Magick::Image& right_ );
   int MagickPPExport operator <  ( const Magick::Image& left_,
-                                  const Magick::Image& right_ );
+                                   const Magick::Image& right_ );
   int MagickPPExport operator >= ( const Magick::Image& left_,
-                                  const Magick::Image& right_ );
+                                   const Magick::Image& right_ );
   int MagickPPExport operator <= ( const Magick::Image& left_,
-                                  const Magick::Image& right_ );
+                                   const Magick::Image& right_ );
 
   // C library initialization routine
-  void MagickPPExport InitializeMagick(const char *path_);
+  void MagickPPExport InitializeMagick ( const char *path_ );
 
   //
   // Image is the representation of an image.  In reality, it actually
@@ -55,10 +55,10 @@ namespace Magick
   {
   public:
     // Construct from image file or image specification
-    Image( const std::string &imageSpec_ );
+    Image ( const std::string &imageSpec_ );
     
     // Construct a blank image canvas of specified size and color
-    Image( const Geometry &size_, const Color &color_ );
+    Image ( const Geometry &size_, const Color &color_ );
 
     // Construct Image from in-memory BLOB
     Image ( const Blob &blob_ );
@@ -89,14 +89,14 @@ namespace Magick
             const void *pixels_ );
 
     // Default constructor
-    Image( void );
-    
+    Image ( void );
+
     // Destructor
-    virtual ~Image();
-    
+    virtual ~Image ();
+
     /// Copy constructor
     Image ( const Image & image_ );
-    
+
     // Assignment operator
     Image& operator= ( const Image &image_ );
 
@@ -111,7 +111,7 @@ namespace Magick
     // pixels, not counting the center pixel.  The sigma_ parameter
     // specifies the standard deviation of the Laplacian, in pixels.
     void            adaptiveBlur ( const double radius_ = 0.0,
-                           const double sigma_ = 1.0  );
+                                   const double sigma_ = 1.0 );
 
     // This is shortcut function for a fast interpolative resize using mesh
     // interpolation.  It works well for small resizes of less than +/- 50%
@@ -140,7 +140,7 @@ namespace Magick
     // Add noise to image with specified noise type
     void            addNoise ( const NoiseType noiseType_ );
     void            addNoiseChannel ( const ChannelType channel_,
-                                      const NoiseType noiseType_);
+                                      const NoiseType noiseType_ );
 
     // Transform image by specified affine (or free transform) matrix.
     void            affineTransform ( const DrawableAffine &affine );
@@ -162,22 +162,22 @@ namespace Magick
 
     // Annotate using specified text, and placement location
     void            annotate ( const std::string &text_,
-             const Geometry &location_ );
+                               const Geometry &location_ );
     // Annotate using specified text, bounding area, and placement
     // gravity
     void            annotate ( const std::string &text_,
-             const Geometry &boundingArea_,
-             const GravityType gravity_ );
+                               const Geometry &boundingArea_,
+                               const GravityType gravity_ );
     // Annotate with text using specified text, bounding area,
     // placement gravity, and rotation.
     void            annotate ( const std::string &text_,
-             const Geometry &boundingArea_,
-             const GravityType gravity_,
-             const double degrees_ );
+                               const Geometry &boundingArea_,
+                               const GravityType gravity_,
+                               const double degrees_ );
     // Annotate with text (bounding area is entire image) and placement
     // gravity.
     void            annotate ( const std::string &text_,
-             const GravityType gravity_ );
+                               const GravityType gravity_ );
 
     // Inserts the artifact with the specified name and value into
     // the artifact tree of the image.
@@ -199,6 +199,12 @@ namespace Magick
     // Adjusts an image so that its orientation is suitable for viewing.
     void            autoOrient ( void );
 
+    // Forces all pixels below the threshold into black while leaving all
+    // pixels at or above the threshold unchanged.
+    void            blackThreshold ( const std::string &threshold_ );
+    void            blackThresholdChannel ( const ChannelType channel_,
+                                            const std::string &threshold_ );
+
     // 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
@@ -207,8 +213,8 @@ namespace Magick
                            const double sigma_ = 1.0  );
     void            blurChannel ( const ChannelType channel_,
                                   const double radius_ = 0.0,
-                                  const double sigma_ = 1.0  );
-    
+                                  const double sigma_ = 1.0 );
+
     // Border image (add border to image)
     void            border ( const Geometry &geometry_
                              = borderGeometryDefault );
@@ -754,7 +760,13 @@ namespace Magick
     // Map image pixels to a sine wave
     void            wave ( const double amplitude_ = 25.0,
                            const double wavelength_ = 150.0 );
-    
+
+    // Forces all pixels below the threshold into black while leaving all
+    // pixels at or below the threshold unchanged.
+    void            whiteThreshold ( const std::string &threshold_ );
+    void            whiteThresholdChannel ( const ChannelType channel_,
+                                            const std::string &threshold_ );
+
     // Write single image frame to a file
     void            write ( const std::string &imageSpec_ );
 
@@ -762,10 +774,10 @@ namespace Magick
     // format and adjoin parameters.
     void            write ( Blob *blob_ );
     void            write ( Blob *blob_,
-          const std::string &magick_ );
+                            const std::string &magick_ );
     void            write ( Blob *blob_,
-          const std::string &magick_,
-          const size_t depth_ );
+                            const std::string &magick_,
+                            const size_t depth_ );
 
     // Write single image frame to an array of pixels with storage
     // type specified by user (DispatchImage), e.g.