% July 2009 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
#include "MagickCore/pixel-accessor.h"
#include "MagickCore/property.h"
#include "MagickCore/quantum-private.h"
+#include "MagickCore/resource_.h"
#include "MagickCore/thread-private.h"
#if defined(MAGICKCORE_FFTW_DELEGATE)
#if defined(MAGICKCORE_HAVE_COMPLEX_H)
*/
typedef struct _FourierInfo
{
- ChannelType
+ PixelChannel
channel;
MagickBooleanType
if (phase_image == (Image *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),ImageError,
- "ImageSequenceRequired","`%s'",image->filename);
+ "TwoOrMoreImagesRequired","'%s'",image->filename);
return(MagickFalse);
}
/*
if (phase_source == (double *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",image->filename);
magnitude_source=(double *) RelinquishMagickMemory(magnitude_source);
return(MagickFalse);
}
i++;
}
}
- magnitude_view=AcquireCacheView(magnitude_image);
- phase_view=AcquireCacheView(phase_image);
+ magnitude_view=AcquireAuthenticCacheView(magnitude_image,exception);
i=0L;
for (y=0L; y < (ssize_t) fourier_info->height; y++)
{
{
switch (fourier_info->channel)
{
- case RedChannel:
+ case RedPixelChannel:
default:
{
SetPixelRed(magnitude_image,ClampToQuantum(QuantumRange*
magnitude_source[i]),q);
break;
}
- case GreenChannel:
+ case GreenPixelChannel:
{
SetPixelGreen(magnitude_image,ClampToQuantum(QuantumRange*
magnitude_source[i]),q);
break;
}
- case BlueChannel:
+ case BluePixelChannel:
{
SetPixelBlue(magnitude_image,ClampToQuantum(QuantumRange*
magnitude_source[i]),q);
break;
}
- case BlackChannel:
+ case BlackPixelChannel:
{
SetPixelBlack(magnitude_image,ClampToQuantum(QuantumRange*
magnitude_source[i]),q);
break;
}
- case AlphaChannel:
+ case AlphaPixelChannel:
{
SetPixelAlpha(magnitude_image,ClampToQuantum(QuantumRange*
magnitude_source[i]),q);
break;
}
- case GrayChannels:
- {
- SetPixelGray(magnitude_image,ClampToQuantum(QuantumRange*
- magnitude_source[i]),q);
- break;
- }
}
i++;
q+=GetPixelChannels(magnitude_image);
if (status == MagickFalse)
break;
}
+ magnitude_view=DestroyCacheView(magnitude_view);
i=0L;
+ phase_view=AcquireAuthenticCacheView(phase_image,exception);
for (y=0L; y < (ssize_t) fourier_info->height; y++)
{
q=GetCacheViewAuthenticPixels(phase_view,0L,y,fourier_info->height,1UL,
{
switch (fourier_info->channel)
{
- case RedChannel:
+ case RedPixelChannel:
default:
{
SetPixelRed(phase_image,ClampToQuantum(QuantumRange*
phase_source[i]),q);
break;
}
- case GreenChannel:
+ case GreenPixelChannel:
{
SetPixelGreen(phase_image,ClampToQuantum(QuantumRange*
phase_source[i]),q);
break;
}
- case BlueChannel:
+ case BluePixelChannel:
{
SetPixelBlue(phase_image,ClampToQuantum(QuantumRange*
phase_source[i]),q);
break;
}
- case BlackChannel:
+ case BlackPixelChannel:
{
SetPixelBlack(phase_image,ClampToQuantum(QuantumRange*
phase_source[i]),q);
break;
}
- case AlphaChannel:
+ case AlphaPixelChannel:
{
SetPixelAlpha(phase_image,ClampToQuantum(QuantumRange*
phase_source[i]),q);
break;
}
- case GrayChannels:
- {
- SetPixelGray(phase_image,ClampToQuantum(QuantumRange*
- phase_source[i]),q);
- break;
- }
}
i++;
q+=GetPixelChannels(phase_image);
break;
}
phase_view=DestroyCacheView(phase_view);
- magnitude_view=DestroyCacheView(magnitude_view);
phase_source=(double *) RelinquishMagickMemory(phase_source);
magnitude_source=(double *) RelinquishMagickMemory(magnitude_source);
return(status);
if (source == (double *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",image->filename);
return(MagickFalse);
}
ResetMagickMemory(source,0,fourier_info->height*fourier_info->width*
sizeof(*source));
i=0L;
- image_view=AcquireCacheView(image);
+ image_view=AcquireVirtualCacheView(image,exception);
for (y=0L; y < (ssize_t) fourier_info->height; y++)
{
p=GetCacheViewVirtualPixels(image_view,0L,y,fourier_info->width,1UL,
{
switch (fourier_info->channel)
{
- case RedChannel:
+ case RedPixelChannel:
default:
{
source[i]=QuantumScale*GetPixelRed(image,p);
break;
}
- case GreenChannel:
+ case GreenPixelChannel:
{
source[i]=QuantumScale*GetPixelGreen(image,p);
break;
}
- case BlueChannel:
+ case BluePixelChannel:
{
source[i]=QuantumScale*GetPixelBlue(image,p);
break;
}
- case BlackChannel:
+ case BlackPixelChannel:
{
source[i]=QuantumScale*GetPixelBlack(image,p);
break;
}
- case AlphaChannel:
+ case AlphaPixelChannel:
{
source[i]=QuantumScale*GetPixelAlpha(image,p);
break;
}
- case GrayChannels:
- {
- source[i]=QuantumScale*GetPixelGray(image,p);
- break;
- }
}
i++;
p+=GetPixelChannels(image);
if (fourier == (fftw_complex *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",image->filename);
source=(double *) RelinquishMagickMemory(source);
return(MagickFalse);
}
}
static MagickBooleanType ForwardFourierTransformChannel(const Image *image,
- const ChannelType channel,const MagickBooleanType modulus,
+ const PixelChannel channel,const MagickBooleanType modulus,
Image *fourier_image,ExceptionInfo *exception)
{
double
if (magnitude == (double *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",image->filename);
return(MagickFalse);
}
phase=(double *) AcquireQuantumMemory((size_t) fourier_info.height,
if (phase == (double *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",image->filename);
magnitude=(double *) RelinquishMagickMemory(magnitude);
return(MagickFalse);
}
if (fourier == (fftw_complex *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",image->filename);
phase=(double *) RelinquishMagickMemory(phase);
magnitude=(double *) RelinquishMagickMemory(magnitude);
return(MagickFalse);
#if !defined(MAGICKCORE_FFTW_DELEGATE)
(void) modulus;
(void) ThrowMagickException(exception,GetMagickModule(),
- MissingDelegateWarning,"DelegateLibrarySupportNotBuiltIn","`%s' (FFTW)",
+ MissingDelegateWarning,"DelegateLibrarySupportNotBuiltIn","'%s' (FFTW)",
image->filename);
#else
{
status=MagickTrue;
is_gray=IsImageGray(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel sections
+ #pragma omp parallel sections
#endif
{
#if defined(MAGICKCORE_OPENMP_SUPPORT)
if (is_gray != MagickFalse)
thread_status=ForwardFourierTransformChannel(image,
- GrayChannels,modulus,fourier_image,exception);
+ GrayPixelChannel,modulus,fourier_image,exception);
else
thread_status=ForwardFourierTransformChannel(image,
- RedChannel,modulus,fourier_image,exception);
+ RedPixelChannel,modulus,fourier_image,exception);
if (thread_status == MagickFalse)
status=thread_status;
}
thread_status=MagickTrue;
if (is_gray == MagickFalse)
thread_status=ForwardFourierTransformChannel(image,
- GreenChannel,modulus,fourier_image,exception);
+ GreenPixelChannel,modulus,fourier_image,exception);
if (thread_status == MagickFalse)
status=thread_status;
}
thread_status=MagickTrue;
if (is_gray == MagickFalse)
thread_status=ForwardFourierTransformChannel(image,
- BlueChannel,modulus,fourier_image,exception);
+ BluePixelChannel,modulus,fourier_image,exception);
if (thread_status == MagickFalse)
status=thread_status;
}
thread_status=MagickTrue;
if (image->colorspace == CMYKColorspace)
thread_status=ForwardFourierTransformChannel(image,
- BlackChannel,modulus,fourier_image,exception);
+ BlackPixelChannel,modulus,fourier_image,exception);
if (thread_status == MagickFalse)
status=thread_status;
}
thread_status=MagickTrue;
if (image->matte != MagickFalse)
thread_status=ForwardFourierTransformChannel(image,
- AlphaChannel,modulus,fourier_image,exception);
+ AlphaPixelChannel,modulus,fourier_image,exception);
if (thread_status == MagickFalse)
status=thread_status;
}
if (magnitude_source == (double *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",
magnitude_image->filename);
return(MagickFalse);
}
if (phase_source == (double *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",
magnitude_image->filename);
magnitude_source=(double *) RelinquishMagickMemory(magnitude_source);
return(MagickFalse);
}
i=0L;
- magnitude_view=AcquireCacheView(magnitude_image);
+ magnitude_view=AcquireVirtualCacheView(magnitude_image,exception);
for (y=0L; y < (ssize_t) fourier_info->height; y++)
{
p=GetCacheViewVirtualPixels(magnitude_view,0L,y,fourier_info->width,1UL,
{
switch (fourier_info->channel)
{
- case RedChannel:
+ case RedPixelChannel:
default:
{
magnitude_source[i]=QuantumScale*GetPixelRed(magnitude_image,p);
break;
}
- case GreenChannel:
+ case GreenPixelChannel:
{
magnitude_source[i]=QuantumScale*GetPixelGreen(magnitude_image,p);
break;
}
- case BlueChannel:
+ case BluePixelChannel:
{
magnitude_source[i]=QuantumScale*GetPixelBlue(magnitude_image,p);
break;
}
- case BlackChannel:
+ case BlackPixelChannel:
{
magnitude_source[i]=QuantumScale*GetPixelBlack(magnitude_image,p);
break;
}
- case AlphaChannel:
+ case AlphaPixelChannel:
{
magnitude_source[i]=QuantumScale*GetPixelAlpha(magnitude_image,p);
break;
}
- case GrayChannels:
- {
- magnitude_source[i]=QuantumScale*GetPixelGray(magnitude_image,p);
- break;
- }
}
i++;
p+=GetPixelChannels(magnitude_image);
}
}
i=0L;
- phase_view=AcquireCacheView(phase_image);
+ phase_view=AcquireVirtualCacheView(phase_image,exception);
for (y=0L; y < (ssize_t) fourier_info->height; y++)
{
p=GetCacheViewVirtualPixels(phase_view,0,y,fourier_info->width,1,
{
switch (fourier_info->channel)
{
- case RedChannel:
+ case RedPixelChannel:
default:
{
phase_source[i]=QuantumScale*GetPixelRed(phase_image,p);
break;
}
- case GreenChannel:
+ case GreenPixelChannel:
{
phase_source[i]=QuantumScale*GetPixelGreen(phase_image,p);
break;
}
- case BlueChannel:
+ case BluePixelChannel:
{
phase_source[i]=QuantumScale*GetPixelBlue(phase_image,p);
break;
}
- case BlackChannel:
+ case BlackPixelChannel:
{
phase_source[i]=QuantumScale*GetPixelBlack(phase_image,p);
break;
}
- case AlphaChannel:
+ case AlphaPixelChannel:
{
phase_source[i]=QuantumScale*GetPixelAlpha(phase_image,p);
break;
}
- case GrayChannels:
- {
- phase_source[i]=QuantumScale*GetPixelGray(phase_image,p);
- break;
- }
}
i++;
p+=GetPixelChannels(phase_image);
if (magnitude == (double *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",
magnitude_image->filename);
magnitude_source=(double *) RelinquishMagickMemory(magnitude_source);
phase_source=(double *) RelinquishMagickMemory(phase_source);
if (phase == (double *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",
magnitude_image->filename);
phase_source=(double *) RelinquishMagickMemory(phase_source);
return(MagickFalse);
if (source == (double *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",image->filename);
return(MagickFalse);
}
#if defined(MAGICKCORE_OPENMP_SUPPORT)
fftw_destroy_plan(fftw_c2r_plan);
}
i=0L;
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
for (y=0L; y < (ssize_t) fourier_info->height; y++)
{
if (y >= (ssize_t) image->rows)
{
switch (fourier_info->channel)
{
- case RedChannel:
+ case RedPixelChannel:
default:
{
SetPixelRed(image,ClampToQuantum(QuantumRange*source[i]),q);
break;
}
- case GreenChannel:
+ case GreenPixelChannel:
{
SetPixelGreen(image,ClampToQuantum(QuantumRange*source[i]),q);
break;
}
- case BlueChannel:
+ case BluePixelChannel:
{
SetPixelBlue(image,ClampToQuantum(QuantumRange*source[i]),q);
break;
}
- case BlackChannel:
+ case BlackPixelChannel:
{
SetPixelBlack(image,ClampToQuantum(QuantumRange*source[i]),q);
break;
}
- case AlphaChannel:
+ case AlphaPixelChannel:
{
SetPixelAlpha(image,ClampToQuantum(QuantumRange*source[i]),q);
break;
}
- case GrayChannels:
- {
- SetPixelGray(image,ClampToQuantum(QuantumRange*source[i]),q);
- break;
- }
}
i++;
q+=GetPixelChannels(image);
static MagickBooleanType InverseFourierTransformChannel(
const Image *magnitude_image,const Image *phase_image,
- const ChannelType channel,const MagickBooleanType modulus,
+ const PixelChannel channel,const MagickBooleanType modulus,
Image *fourier_image,ExceptionInfo *exception)
{
double
if (magnitude == (double *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",
magnitude_image->filename);
return(MagickFalse);
}
if (phase == (double *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",
magnitude_image->filename);
magnitude=(double *) RelinquishMagickMemory(magnitude);
return(MagickFalse);
if (fourier == (fftw_complex *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitError,"MemoryAllocationFailed","`%s'",
+ ResourceLimitError,"MemoryAllocationFailed","'%s'",
magnitude_image->filename);
phase=(double *) RelinquishMagickMemory(phase);
magnitude=(double *) RelinquishMagickMemory(magnitude);
if (phase_image == (Image *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),ImageError,
- "ImageSequenceRequired","`%s'",magnitude_image->filename);
+ "TwoOrMoreImagesRequired","'%s'",magnitude_image->filename);
return((Image *) NULL);
}
#if !defined(MAGICKCORE_FFTW_DELEGATE)
fourier_image=(Image *) NULL;
(void) modulus;
(void) ThrowMagickException(exception,GetMagickModule(),
- MissingDelegateWarning,"DelegateLibrarySupportNotBuiltIn","`%s' (FFTW)",
+ MissingDelegateWarning,"DelegateLibrarySupportNotBuiltIn","'%s' (FFTW)",
magnitude_image->filename);
#else
{
if (is_gray != MagickFalse)
thread_status=InverseFourierTransformChannel(magnitude_image,
- phase_image,GrayChannels,modulus,fourier_image,exception);
+ phase_image,GrayPixelChannel,modulus,fourier_image,exception);
else
thread_status=InverseFourierTransformChannel(magnitude_image,
- phase_image,RedChannel,modulus,fourier_image,exception);
+ phase_image,RedPixelChannel,modulus,fourier_image,exception);
if (thread_status == MagickFalse)
status=thread_status;
}
thread_status=MagickTrue;
if (is_gray == MagickFalse)
thread_status=InverseFourierTransformChannel(magnitude_image,
- phase_image,GreenChannel,modulus,fourier_image,exception);
+ phase_image,GreenPixelChannel,modulus,fourier_image,exception);
if (thread_status == MagickFalse)
status=thread_status;
}
thread_status=MagickTrue;
if (is_gray == MagickFalse)
thread_status=InverseFourierTransformChannel(magnitude_image,
- phase_image,BlueChannel,modulus,fourier_image,exception);
+ phase_image,BluePixelChannel,modulus,fourier_image,exception);
if (thread_status == MagickFalse)
status=thread_status;
}
thread_status=MagickTrue;
if (magnitude_image->colorspace == CMYKColorspace)
thread_status=InverseFourierTransformChannel(magnitude_image,
- phase_image,BlackChannel,modulus,fourier_image,exception);
+ phase_image,BlackPixelChannel,modulus,fourier_image,exception);
if (thread_status == MagickFalse)
status=thread_status;
}
thread_status=MagickTrue;
if (magnitude_image->matte != MagickFalse)
thread_status=InverseFourierTransformChannel(magnitude_image,
- phase_image,AlphaChannel,modulus,fourier_image,exception);
+ phase_image,AlphaPixelChannel,modulus,fourier_image,exception);
if (thread_status == MagickFalse)
status=thread_status;
}