Commit cf473b95 authored by dirk's avatar dirk

Added adaptive resize/sharpen to Magick++.

parent 2d1ecb87
......@@ -307,6 +307,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
......
......@@ -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
......
......@@ -686,6 +686,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::AddNoiseImageChannel;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment