% Software Design %
% Sean Burke %
% Fred Weinhaus %
-% John Cristy %
+% Cristy %
% July 2009 %
% %
% %
-% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 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/property.h"
#include "MagickCore/quantum-private.h"
#include "MagickCore/resource_.h"
+#include "MagickCore/string-private.h"
#include "MagickCore/thread-private.h"
#if defined(MAGICKCORE_FFTW_DELEGATE)
#if defined(MAGICKCORE_HAVE_COMPLEX_H)
% The format of the ComplexImages method is:
%
% MagickBooleanType ComplexImages(Image *images,
-% const ComplexOperator operator,ExceptionInfo *exception)
+% const ComplexOperator op,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
-% o operator: A complex operator.
+% o op: A complex op.
%
% o exception: return any errors or warnings in this structure.
%
*/
-MagickExport Image *ComplexImages(const Image *images,
- const ComplexOperator operator,ExceptionInfo *exception)
+MagickExport Image *ComplexImages(const Image *images,const ComplexOperator op,
+ ExceptionInfo *exception)
{
#define ComplexImageTag "Complex/Image"
*Ci_view,
*Cr_view;
+ const char
+ *artifact;
+
const Image
*Ai_image,
*Ar_image,
*Bi_image,
*Br_image;
+ double
+ snr;
+
Image
*Ci_image,
*complex_images,
/*
Apply complex mathematics to image pixels.
*/
+ artifact=GetImageArtifact(image,"complex:snr");
+ snr=0.0;
+ if (artifact != (const char *) NULL)
+ snr=StringToDouble(artifact,(char **) NULL);
Ar_image=images;
Ai_image=images->next;
Br_image=images;
for (i=0; i < (ssize_t) GetPixelChannels(images); i++)
{
- switch (operator)
+ switch (op)
{
case AddComplexOperator:
{
double
gamma;
- gamma=PerceptibleReciprocal(Br[i]*Br[i]+Bi[i]*Bi[i]);
+ gamma=PerceptibleReciprocal(Br[i]*Br[i]+Bi[i]*Bi[i]+snr);
Cr[i]=gamma*(Ar[i]*Br[i]+Ai[i]*Bi[i]);
Ci[i]=gamma*(Ai[i]*Br[i]-Ar[i]*Bi[i]);
break;
case MagnitudePhaseComplexOperator:
{
Cr[i]=sqrt(Ar[i]*Ar[i]+Ai[i]*Ai[i]);
- Ci[i]=atan2(Ai[i],Ar[i]);
+ Ci[i]=atan2(Ai[i],Ar[i])/(2.0*MagickPI)+0.5;
break;
}
case MultiplyComplexOperator:
}
case RealImaginaryComplexOperator:
{
- Cr[i]=Ar[i]*cos(Ai[i]);
- Ci[i]=Ar[i]*sin(Ai[i]);
+ Cr[i]=Ar[i]*cos(2.0*MagickPI*(Ai[i]-0.5));
+ Ci[i]=Ar[i]*sin(2.0*MagickPI*(Ai[i]-0.5));
break;
}
case SubtractComplexOperator: