From: cristy Date: Sat, 14 Nov 2009 18:15:08 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~10380 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=529fcc251289b181417ebc355b221dcaa91b1611;p=imagemagick --- diff --git a/Magick++/ChangeLog b/Magick++/ChangeLog index 1188c9ee1..734c6b4a9 100644 --- a/Magick++/ChangeLog +++ b/Magick++/ChangeLog @@ -1,3 +1,8 @@ +2009-11-14 6.5.7-8 Cristy + * Add forwardFourierTransform(), inverseFourierTransform(), and + inverseFourierTransformImage() methods to implement forward and inverse + discrete Fourier transform (DFT / IFT). + 2009-09-28 6.5.6-6 Cristy * Add splice() method to splice the background color into the image. diff --git a/Magick++/lib/Image.cpp b/Magick++/lib/Image.cpp index f61ef476d..0b460f99b 100644 --- a/Magick++/lib/Image.cpp +++ b/Magick++/lib/Image.cpp @@ -1037,12 +1037,12 @@ void Magick::Image::forwardFourierTransform ( void ) throwException( exceptionInfo ); (void) DestroyExceptionInfo( &exceptionInfo ); } -void Magick::Image::forwardFourierTransform ( const bool magnitude ) +void Magick::Image::forwardFourierTransform ( const bool magnitude_ ) { ExceptionInfo exceptionInfo; GetExceptionInfo( &exceptionInfo ); MagickCore::Image* newImage = ForwardFourierTransformImage ( image(), - magnitude == true ? MagickTrue : MagickFalse, &exceptionInfo ); + magnitude_ == true ? MagickTrue : MagickFalse, &exceptionInfo ); replaceImage( newImage ); throwException( exceptionInfo ); (void) DestroyExceptionInfo( &exceptionInfo ); @@ -1183,6 +1183,31 @@ void Magick::Image::implode ( const double factor_ ) (void) DestroyExceptionInfo( &exceptionInfo ); } +// implements the inverse discrete Fourier transform (IFT) of the image either +// as a magnitude / phase or real / imaginary image pair. +void Magick::Image::inverseFourierTransform ( const Image &phase_ ) +{ + ExceptionInfo exceptionInfo; + GetExceptionInfo( &exceptionInfo ); + MagickCore::Image* newImage = InverseFourierTransformImage( image(), + phase_.constImage(), MagickTrue, &exceptionInfo); + replaceImage( newImage ); + throwException( exceptionInfo ); + (void) DestroyExceptionInfo( &exceptionInfo ); +} +void Magick::Image::inverseFourierTransform ( const Image &phase_, + const bool magnitude_ ) +{ + ExceptionInfo exceptionInfo; + GetExceptionInfo( &exceptionInfo ); + MagickCore::Image* newImage = InverseFourierTransformImage( image(), + phase_.constImage(), magnitude_ == true ? MagickTrue : MagickFalse, + &exceptionInfo); + replaceImage( newImage ); + throwException( exceptionInfo ); + (void) DestroyExceptionInfo( &exceptionInfo ); +} + // Level image. Adjust the levels of the image by scaling the colors // falling between specified white and black points to the full // available quantum range. The parameters provided represent the diff --git a/Magick++/lib/Magick++/Image.h b/Magick++/lib/Magick++/Image.h index 9b4f0855b..5591f735d 100644 --- a/Magick++/lib/Magick++/Image.h +++ b/Magick++/lib/Magick++/Image.h @@ -391,6 +391,12 @@ namespace Magick // Implode image (special effect) void implode ( const double factor_ ); + // implements the inverse discrete Fourier transform (DFT) of the image + // either as a magnitude / phase or real / imaginary image pair. + // + void inverseFourierTransform ( const Image &phase_ ); + void inverseFourierTransform ( const Image &phase_, + const bool magnitude_ ); // Label image void label ( const std::string &label_ ); diff --git a/Magick++/lib/Magick++/STL.h b/Magick++/lib/Magick++/STL.h index facacacfd..101c9360f 100644 --- a/Magick++/lib/Magick++/STL.h +++ b/Magick++/lib/Magick++/STL.h @@ -598,6 +598,19 @@ namespace Magick double _factor; }; + // implements the inverse discrete Fourier transform (IFT) of the image + // either as a magnitude / phase or real / imaginary image pair. + class MagickDLLDecl inverseFourierTransformImage : public std::unary_function + { + public: + inverseFourierTransformImage( const Image &phaseImage_ ); + + void operator()( Image &image_ ) const; + + private: + Image _phaseImage; + }; + // Set image validity. Valid images become empty (inValid) if // argument is false. class MagickDLLDecl isValidImage : public std::unary_function diff --git a/Magick++/lib/STL.cpp b/Magick++/lib/STL.cpp index 435ff7574..17b80f72a 100644 --- a/Magick++/lib/STL.cpp +++ b/Magick++/lib/STL.cpp @@ -580,6 +580,17 @@ void Magick::implodeImage::operator()( Magick::Image &image_ ) const image_.implode( _factor ); } +// Implements the inverse discrete Fourier transform (IFT) of the image +// either as a magnitude / phase or real / imaginary image pair. +Magick::inverseFourierTransformImage::inverseFourierTransformImage( const Magick::Image &phaseImage_ ) + : _phaseImage( phaseImage_ ) +{ +} +void Magick::inverseFourierTransformImage::operator()( Magick::Image &image_ ) const +{ + image_.inverseFourierTransform( _phaseImage ); +} + // Set image validity. Valid images become empty (inValid) if argument // is false. Magick::isValidImage::isValidImage( const bool isValid_ )