]> granicus.if.org Git - imagemagick/commitdiff
Added adaptive resize/sharpen to Magick++.
authordirk <dirk@git.imagemagick.org>
Sun, 28 Jul 2013 18:49:03 +0000 (18:49 +0000)
committerdirk <dirk@git.imagemagick.org>
Sun, 28 Jul 2013 18:49:03 +0000 (18:49 +0000)
Magick++/lib/Image.cpp
Magick++/lib/Magick++/Image.h
Magick++/lib/Magick++/Include.h

index bd8b8ad051f50f9972c0251e03deacb920e4fd87..e588a0870b778d42d791cf5ad27a831e1169f6fb 100644 (file)
@@ -306,6 +306,52 @@ void Magick::Image::adaptiveBlur( const double radius_, const double sigma_ )
   (void) DestroyExceptionInfo( &exceptionInfo );
 }
 
+void Magick::Image::adaptiveResize ( const Geometry &geometry_ )
+{
+  ssize_t x = 0;
+  ssize_t y = 0;
+  size_t width = columns();
+  size_t height = rows();
+
+  ParseMetaGeometry( static_cast<std::string>(geometry_).c_str(),
+                     &x, &y,
+                     &width, &height );
+
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  MagickCore::Image* newImage =
+    AdaptiveResizeImage( constImage(), width, height, &exceptionInfo );
+  replaceImage( newImage );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+void Magick::Image::adaptiveSharpen ( const double radius_,
+                                      const double sigma_ )
+{
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  MagickCore::Image* newImage =
+    AdaptiveSharpenImage( constImage(), radius_, sigma_, &exceptionInfo );
+  replaceImage( newImage );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
+void Magick::Image::adaptiveSharpenChannel ( const ChannelType channel_,
+                                             const double radius_,
+                                             const double sigma_ )
+{
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  MagickCore::Image* newImage =
+    AdaptiveSharpenImageChannel( constImage(), channel_, radius_, sigma_,
+                                 &exceptionInfo );
+  replaceImage( newImage );
+  throwException( exceptionInfo );
+  (void) DestroyExceptionInfo( &exceptionInfo );
+}
+
 // Local adaptive threshold image
 // http://www.dai.ed.ac.uk/HIPR2/adpthrsh.htm
 // Width x height define the size of the pixel neighborhood
index a134307ee03ee30000ebb1cc6684c425a0046df0..43a301fc927c4116e18437bdf3817fbc28542bad 100644 (file)
@@ -112,7 +112,23 @@ namespace Magick
     // specifies the standard deviation of the Laplacian, in pixels.
     void            adaptiveBlur ( const double radius_ = 0.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%
+    // of the original image size.  For larger resizing on images a full
+    // filtered and slower resize function should be used instead.
+    void            adaptiveResize ( const Geometry &geometry_ );
+
+    // Adaptively sharpens the image by sharpening more intensely near image
+    // edges and less intensely far from edges. We sharpen the image with a 
+    // Gaussian operator of the given radius and standard deviation (sigma).
+    // For reasonable results, radius should be larger than sigma.
+    void            adaptiveSharpen ( const double radius_ = 0.0,
+                                      const double sigma_ = 1.0 );
+    void            adaptiveSharpenChannel ( const ChannelType channel_,
+                                             const double radius_ = 0.0,
+                                             const double sigma_ = 1.0 );
+
     // Local adaptive threshold image
     // http://www.dai.ed.ac.uk/HIPR2/adpthrsh.htm
     // Width x height define the size of the pixel neighborhood
index db671b6ef8a237c7a11af047f93479b8f17abe7b..d7eaa63eb32f0ebd6d236b4c6471e832e3c4facf 100644 (file)
@@ -695,6 +695,9 @@ namespace Magick
   using MagickCore::AcquireString;
   using MagickCore::AcquireStringInfo;
   using MagickCore::AdaptiveBlurImage;
+  using MagickCore::AdaptiveResizeImage;
+  using MagickCore::AdaptiveSharpenImage;
+  using MagickCore::AdaptiveSharpenImageChannel;
   using MagickCore::AdaptiveThresholdImage;
   using MagickCore::AddNoiseImage;
   using MagickCore::AffineMatrix;