#include "MagickCore/image-private.h"
#include "MagickCore/list.h"
#include "MagickCore/memory_.h"
+#include "MagickCore/memory-private.h"
#include "MagickCore/magick.h"
#include "MagickCore/pixel-accessor.h"
#include "MagickCore/property.h"
*/
struct _ResizeFilter
{
- MagickRealType
- (*filter)(const MagickRealType,const ResizeFilter *),
- (*window)(const MagickRealType,const ResizeFilter *),
+ double
+ (*filter)(const double,const ResizeFilter *),
+ (*window)(const double,const ResizeFilter *),
support, /* filter region of support - the filter support limit */
window_support, /* window support, usally equal to support (expert only) */
scale, /* dimension scaling to fit window support (usally 1.0) */
blur, /* x-scale (blur-sharpen) */
- coefficient[7]; /* cubic coefficents for BC-cubic spline filters */
+ coefficient[7]; /* cubic coefficents for BC-cubic filters */
size_t
signature;
/*
Forward declaractions.
*/
-static MagickRealType
- I0(MagickRealType x),
- BesselOrderOne(MagickRealType),
- Sinc(const MagickRealType, const ResizeFilter *),
- SincFast(const MagickRealType, const ResizeFilter *);
+static double
+ I0(double x),
+ BesselOrderOne(double),
+ Sinc(const double, const ResizeFilter *),
+ SincFast(const double, const ResizeFilter *);
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% The individual filter functions have this format...
%
-% static MagickRealtype *FilterName(const MagickRealType x,
-% const MagickRealType support)
+% static MagickRealtype *FilterName(const double x,
+% const double support)
%
% A description of each parameter follows:
%
%
*/
-static MagickRealType Blackman(const MagickRealType x,
+static double Blackman(const double x,
const ResizeFilter *magick_unused(resize_filter))
{
/*
Refactored by Chantal Racette and Nicolas Robidoux to one trig call and
five flops.
*/
- const MagickRealType cosine=cos((double) (MagickPI*x));
+ const double cosine=cos((double) (MagickPI*x));
return(0.34+cosine*(0.5+cosine*0.16));
}
-static MagickRealType Bohman(const MagickRealType x,
+static double Bohman(const double x,
const ResizeFilter *magick_unused(resize_filter))
{
/*
taking advantage of the fact that the support of Bohman is 1.0 (so that we
know that sin(pi x) >= 0).
*/
- const MagickRealType cosine=cos((double) (MagickPI*x));
- const MagickRealType sine=sqrt(1.0-cosine*cosine);
+ const double cosine=cos((double) (MagickPI*x));
+ const double sine=sqrt(1.0-cosine*cosine);
return((1.0-x)*cosine+(1.0/MagickPI)*sine);
}
-static MagickRealType Box(const MagickRealType magick_unused(x),
+static double Box(const double magick_unused(x),
const ResizeFilter *magick_unused(resize_filter))
{
/*
return(1.0);
}
-static MagickRealType Cosine(const MagickRealType x,
+static double Cosine(const double x,
const ResizeFilter *magick_unused(resize_filter))
{
/*
Cosine window function:
cos((pi/2)*x).
*/
- return((MagickRealType)cos((double) (MagickPI2*x)));
+ return((double)cos((double) (MagickPI2*x)));
}
-static MagickRealType CubicBC(const MagickRealType x,
+static double CubicBC(const double x,
const ResizeFilter *resize_filter)
{
/*
Cubic Filters using B,C determined values:
Mitchell-Netravali B = 1/3 C = 1/3 "Balanced" cubic spline filter
Catmull-Rom B = 0 C = 1/2 Interpolatory and exact on linears
- Cubic B-Spline B = 1 C = 0 Spline approximation of Gaussian
- Hermite B = 0 C = 0 Spline with small support (= 1)
+ Spline B = 1 C = 0 B-Spline Gaussian approximation
+ Hermite B = 0 C = 0 B-Spline interpolator
See paper by Mitchell and Netravali, Reconstruction Filters in Computer
Graphics Computer Graphics, Volume 22, Number 4, August 1988
return(0.0);
}
-static MagickRealType Gaussian(const MagickRealType x,
+static double Gaussian(const double x,
const ResizeFilter *resize_filter)
{
/*
return(exp((double)(-resize_filter->coefficient[1]*x*x)));
}
-static MagickRealType Hanning(const MagickRealType x,
+static double Hann(const double x,
const ResizeFilter *magick_unused(resize_filter))
{
/*
Cosine window function:
0.5+0.5*cos(pi*x).
*/
- const MagickRealType cosine=cos((double) (MagickPI*x));
+ const double cosine=cos((double) (MagickPI*x));
return(0.5+0.5*cosine);
}
-static MagickRealType Hamming(const MagickRealType x,
+static double Hamming(const double x,
const ResizeFilter *magick_unused(resize_filter))
{
/*
Offset cosine window function:
.54 + .46 cos(pi x).
*/
- const MagickRealType cosine=cos((double) (MagickPI*x));
+ const double cosine=cos((double) (MagickPI*x));
return(0.54+0.46*cosine);
}
-static MagickRealType Jinc(const MagickRealType x,
+static double Jinc(const double x,
const ResizeFilter *magick_unused(resize_filter))
{
/*
return(BesselOrderOne(MagickPI*x)/x);
}
-static MagickRealType Kaiser(const MagickRealType x,
+static double Kaiser(const double x,
const ResizeFilter *resize_filter)
{
/*
I0(resize_filter->coefficient[0]*sqrt((double) (1.0-x*x))));
}
-static MagickRealType Lagrange(const MagickRealType x,
+static double Lagrange(const double x,
const ResizeFilter *resize_filter)
{
- MagickRealType
+ double
value;
register ssize_t
return(value);
}
-static MagickRealType Quadratic(const MagickRealType x,
+static double Quadratic(const double x,
const ResizeFilter *magick_unused(resize_filter))
{
/*
return(0.0);
}
-static MagickRealType Sinc(const MagickRealType x,
+static double Sinc(const double x,
const ResizeFilter *magick_unused(resize_filter))
{
/*
*/
if (x != 0.0)
{
- const MagickRealType alpha=(MagickRealType) (MagickPI*x);
+ const double alpha=(double) (MagickPI*x);
return(sin((double) alpha)/alpha);
}
- return((MagickRealType) 1.0);
+ return((double) 1.0);
}
-static MagickRealType SincFast(const MagickRealType x,
+static double SincFast(const double x,
const ResizeFilter *magick_unused(resize_filter))
{
/*
*/
if (x > 4.0)
{
- const MagickRealType alpha=(MagickRealType) (MagickPI*x);
+ const double alpha=(double) (MagickPI*x);
return(sin((double) alpha)/alpha);
}
{
/*
The approximations only depend on x^2 (sinc is an even function).
*/
- const MagickRealType xx = x*x;
+ const double xx = x*x;
#if MAGICKCORE_QUANTUM_DEPTH <= 8
/*
Maximum absolute relative error 6.3e-6 < 1/2^17.
*/
- const MagickRealType c0 = 0.173610016489197553621906385078711564924e-2L;
- const MagickRealType c1 = -0.384186115075660162081071290162149315834e-3L;
- const MagickRealType c2 = 0.393684603287860108352720146121813443561e-4L;
- const MagickRealType c3 = -0.248947210682259168029030370205389323899e-5L;
- const MagickRealType c4 = 0.107791837839662283066379987646635416692e-6L;
- const MagickRealType c5 = -0.324874073895735800961260474028013982211e-8L;
- const MagickRealType c6 = 0.628155216606695311524920882748052490116e-10L;
- const MagickRealType c7 = -0.586110644039348333520104379959307242711e-12L;
- const MagickRealType p =
+ const double c0 = 0.173610016489197553621906385078711564924e-2L;
+ const double c1 = -0.384186115075660162081071290162149315834e-3L;
+ const double c2 = 0.393684603287860108352720146121813443561e-4L;
+ const double c3 = -0.248947210682259168029030370205389323899e-5L;
+ const double c4 = 0.107791837839662283066379987646635416692e-6L;
+ const double c5 = -0.324874073895735800961260474028013982211e-8L;
+ const double c6 = 0.628155216606695311524920882748052490116e-10L;
+ const double c7 = -0.586110644039348333520104379959307242711e-12L;
+ const double p =
c0+xx*(c1+xx*(c2+xx*(c3+xx*(c4+xx*(c5+xx*(c6+xx*c7))))));
return((xx-1.0)*(xx-4.0)*(xx-9.0)*(xx-16.0)*p);
#elif MAGICKCORE_QUANTUM_DEPTH <= 16
/*
Max. abs. rel. error 2.2e-8 < 1/2^25.
*/
- const MagickRealType c0 = 0.173611107357320220183368594093166520811e-2L;
- const MagickRealType c1 = -0.384240921114946632192116762889211361285e-3L;
- const MagickRealType c2 = 0.394201182359318128221229891724947048771e-4L;
- const MagickRealType c3 = -0.250963301609117217660068889165550534856e-5L;
- const MagickRealType c4 = 0.111902032818095784414237782071368805120e-6L;
- const MagickRealType c5 = -0.372895101408779549368465614321137048875e-8L;
- const MagickRealType c6 = 0.957694196677572570319816780188718518330e-10L;
- const MagickRealType c7 = -0.187208577776590710853865174371617338991e-11L;
- const MagickRealType c8 = 0.253524321426864752676094495396308636823e-13L;
- const MagickRealType c9 = -0.177084805010701112639035485248501049364e-15L;
- const MagickRealType p =
+ const double c0 = 0.173611107357320220183368594093166520811e-2L;
+ const double c1 = -0.384240921114946632192116762889211361285e-3L;
+ const double c2 = 0.394201182359318128221229891724947048771e-4L;
+ const double c3 = -0.250963301609117217660068889165550534856e-5L;
+ const double c4 = 0.111902032818095784414237782071368805120e-6L;
+ const double c5 = -0.372895101408779549368465614321137048875e-8L;
+ const double c6 = 0.957694196677572570319816780188718518330e-10L;
+ const double c7 = -0.187208577776590710853865174371617338991e-11L;
+ const double c8 = 0.253524321426864752676094495396308636823e-13L;
+ const double c9 = -0.177084805010701112639035485248501049364e-15L;
+ const double p =
c0+xx*(c1+xx*(c2+xx*(c3+xx*(c4+xx*(c5+xx*(c6+xx*(c7+xx*(c8+xx*c9))))))));
return((xx-1.0)*(xx-4.0)*(xx-9.0)*(xx-16.0)*p);
#else
/*
Max. abs. rel. error 1.2e-12 < 1/2^39.
*/
- const MagickRealType c0 = 0.173611111110910715186413700076827593074e-2L;
- const MagickRealType c1 = -0.289105544717893415815859968653611245425e-3L;
- const MagickRealType c2 = 0.206952161241815727624413291940849294025e-4L;
- const MagickRealType c3 = -0.834446180169727178193268528095341741698e-6L;
- const MagickRealType c4 = 0.207010104171026718629622453275917944941e-7L;
- const MagickRealType c5 = -0.319724784938507108101517564300855542655e-9L;
- const MagickRealType c6 = 0.288101675249103266147006509214934493930e-11L;
- const MagickRealType c7 = -0.118218971804934245819960233886876537953e-13L;
- const MagickRealType p =
+ const double c0 = 0.173611111110910715186413700076827593074e-2L;
+ const double c1 = -0.289105544717893415815859968653611245425e-3L;
+ const double c2 = 0.206952161241815727624413291940849294025e-4L;
+ const double c3 = -0.834446180169727178193268528095341741698e-6L;
+ const double c4 = 0.207010104171026718629622453275917944941e-7L;
+ const double c5 = -0.319724784938507108101517564300855542655e-9L;
+ const double c6 = 0.288101675249103266147006509214934493930e-11L;
+ const double c7 = -0.118218971804934245819960233886876537953e-13L;
+ const double p =
c0+xx*(c1+xx*(c2+xx*(c3+xx*(c4+xx*(c5+xx*(c6+xx*c7))))));
- const MagickRealType d0 = 1.0L;
- const MagickRealType d1 = 0.547981619622284827495856984100563583948e-1L;
- const MagickRealType d2 = 0.134226268835357312626304688047086921806e-2L;
- const MagickRealType d3 = 0.178994697503371051002463656833597608689e-4L;
- const MagickRealType d4 = 0.114633394140438168641246022557689759090e-6L;
- const MagickRealType q = d0+xx*(d1+xx*(d2+xx*(d3+xx*d4)));
+ const double d0 = 1.0L;
+ const double d1 = 0.547981619622284827495856984100563583948e-1L;
+ const double d2 = 0.134226268835357312626304688047086921806e-2L;
+ const double d3 = 0.178994697503371051002463656833597608689e-4L;
+ const double d4 = 0.114633394140438168641246022557689759090e-6L;
+ const double q = d0+xx*(d1+xx*(d2+xx*(d3+xx*d4)));
return((xx-1.0)*(xx-4.0)*(xx-9.0)*(xx-16.0)/q*p);
#endif
}
}
-static MagickRealType Triangle(const MagickRealType x,
+static double Triangle(const double x,
const ResizeFilter *magick_unused(resize_filter))
{
/*
return(0.0);
}
-static MagickRealType Welsh(const MagickRealType x,
+static double Welch(const double x,
const ResizeFilter *magick_unused(resize_filter))
{
/*
- Welsh parabolic windowing filter.
+ Welch parabolic windowing filter.
*/
if (x < 1.0)
return(1.0-x*x);
%
% FIR (Finite impulse Response) Filters
% Box Triangle Quadratic
-% Cubic Hermite Catrom
+% Spline Hermite Catrom
% Mitchell
%
% IIR (Infinite impulse Response) Filters
% Gaussian Sinc Jinc (Bessel)
%
% Windowed Sinc/Jinc Filters
-% Blackman Hanning Hamming
-% Kaiser Lanczos
+% Blackman Bohman Lanczos
+% Hann Hamming Cosine
+% Kaiser Welch Parzen
+% Bartlett
%
-% Special purpose Filters
-% SincFast LanczosSharp Lanczos2 Lanczos2Sharp
+% Special Purpose Filters
+% Cubic SincFast LanczosSharp Lanczos2 Lanczos2Sharp
% Robidoux RobidouxSharp
%
% The users "-filter" selection is used to lookup the default 'expert'
% using it for Distort.
%
% "filter:b"
-% "filter:c" Override the preset B,C values for a Cubic type of filter.
+% "filter:c" Override the preset B,C values for a Cubic filter.
% If only one of these are given it is assumes to be a 'Keys' type of
% filter such that B+2C=1, where Keys 'alpha' value = C.
%
filter_type,
window_type;
- MagickRealType
+ double
B,
C,
value;
{ BoxFilter, BoxFilter }, /* Box averaging filter */
{ TriangleFilter, BoxFilter }, /* Linear interpolation filter */
{ HermiteFilter, BoxFilter }, /* Hermite interpolation filter */
- { SincFastFilter, HanningFilter }, /* Hanning -- cosine-sinc */
- { SincFastFilter, HammingFilter }, /* Hamming -- '' variation */
+ { SincFastFilter, HannFilter }, /* Hann -- cosine-sinc */
+ { SincFastFilter, HammingFilter }, /* Hamming -- '' variation */
{ SincFastFilter, BlackmanFilter }, /* Blackman -- 2*cosine-sinc */
{ GaussianFilter, BoxFilter }, /* Gaussian blur filter */
{ QuadraticFilter, BoxFilter }, /* Quadratic Gaussian approx */
- { CubicFilter, BoxFilter }, /* Cubic B-Spline */
+ { CubicFilter, BoxFilter }, /* General Cubic Filter, Spline */
{ CatromFilter, BoxFilter }, /* Cubic-Keys interpolator */
{ MitchellFilter, BoxFilter }, /* 'Ideal' Cubic-Keys filter */
{ JincFilter, BoxFilter }, /* Raw 3-lobed Jinc function */
{ SincFilter, BoxFilter }, /* Raw 4-lobed Sinc function */
{ SincFastFilter, BoxFilter }, /* Raw fast sinc ("Pade"-type) */
{ SincFastFilter, KaiserFilter }, /* Kaiser -- square root-sinc */
- { SincFastFilter, WelshFilter }, /* Welsh -- parabolic-sinc */
+ { LanczosFilter, WelchFilter }, /* Welch -- parabolic (3 lobe) */
{ SincFastFilter, CubicFilter }, /* Parzen -- cubic-sinc */
{ SincFastFilter, BohmanFilter }, /* Bohman -- 2*cosine-sinc */
{ SincFastFilter, TriangleFilter }, /* Bartlett -- triangle-sinc */
{ Lanczos2SharpFilter, Lanczos2SharpFilter },
{ RobidouxFilter, BoxFilter }, /* Cubic Keys tuned for EWA */
{ RobidouxSharpFilter, BoxFilter }, /* Sharper Cubic Keys for EWA */
- { SincFastFilter, CosineFilter }, /* low level cosine window */
+ { LanczosFilter, CosineFilter }, /* Cosine window (3 lobes) */
+ { SplineFilter, BoxFilter }, /* Spline Cubic Filter */
};
/*
Table mapping the filter/window from the above table to an actual function.
*/
static struct
{
- MagickRealType
- (*function)(const MagickRealType,const ResizeFilter*),
+ double
+ (*function)(const double,const ResizeFilter*),
support, /* Default lobes/support size of the weighting filter. */
scale, /* Support when function used as a windowing function
Typically equal to the location of the first zero crossing. */
B,C; /* BC-spline coefficients, ignored if not a CubicBC filter. */
} const filters[SentinelFilter] =
{
- /* .--- support window
- | .--- first crossing (if used as a Windowing function)
+ /* .--- support window (if used as Weighting Function)
+ | .--- first crossing (if used as a Windowing Function)
| | .--- B value for Cubic Function
| | | .---- C value for Cubic Function
| | | | */
{ Box, 0.5, 0.5, 0.0, 0.0 }, /* Box */
{ Triangle, 1.0, 1.0, 0.0, 0.0 }, /* Triangle */
{ CubicBC, 1.0, 1.0, 0.0, 0.0 }, /* Hermite (cubic B=C=0) */
- { Hanning, 1.0, 1.0, 0.0, 0.0 }, /* Hanning, cosine window */
+ { Hann, 1.0, 1.0, 0.0, 0.0 }, /* Hann, cosine window */
{ Hamming, 1.0, 1.0, 0.0, 0.0 }, /* Hamming, '' variation */
{ Blackman, 1.0, 1.0, 0.0, 0.0 }, /* Blackman, 2*cosine window */
{ Gaussian, 2.0, 1.5, 0.0, 0.0 }, /* Gaussian */
{ Quadratic, 1.5, 1.5, 0.0, 0.0 }, /* Quadratic gaussian */
- { CubicBC, 2.0, 2.0, 1.0, 0.0 }, /* Cubic B-Spline (B=1,C=0) */
+ { CubicBC, 2.0, 2.0, 1.0, 0.0 }, /* General Cubic Filter */
{ CubicBC, 2.0, 1.0, 0.0, 0.5 }, /* Catmull-Rom (B=0,C=1/2) */
{ CubicBC, 2.0, 8.0/7.0, 1./3., 1./3. }, /* Mitchell (B=C=1/3) */
{ Jinc, 3.0, 1.2196698912665045, 0.0, 0.0 }, /* Raw 3-lobed Jinc */
{ Sinc, 4.0, 1.0, 0.0, 0.0 }, /* Raw 4-lobed Sinc */
{ SincFast, 4.0, 1.0, 0.0, 0.0 }, /* Raw fast sinc ("Pade"-type) */
{ Kaiser, 1.0, 1.0, 0.0, 0.0 }, /* Kaiser (square root window) */
- { Welsh, 1.0, 1.0, 0.0, 0.0 }, /* Welsh (parabolic window) */
+ { Welch, 1.0, 1.0, 0.0, 0.0 }, /* Welch (parabolic window) */
{ CubicBC, 2.0, 2.0, 1.0, 0.0 }, /* Parzen (B-Spline window) */
{ Bohman, 1.0, 1.0, 0.0, 0.0 }, /* Bohman, 2*Cosine window */
{ Triangle, 1.0, 1.0, 0.0, 0.0 }, /* Bartlett (triangle window) */
{ Lagrange, 2.0, 1.0, 0.0, 0.0 }, /* Lagrange sinc approximation */
{ SincFast, 3.0, 1.0, 0.0, 0.0 }, /* Lanczos, 3-lobed Sinc-Sinc */
- { SincFast, 3.0, 1.0, 0.0, 0.0 }, /* lanczos, Sharpened */
+ { SincFast, 3.0, 1.0, 0.0, 0.0 }, /* Lanczos, Sharpened */
{ SincFast, 2.0, 1.0, 0.0, 0.0 }, /* Lanczos, 2-lobed */
{ SincFast, 2.0, 1.0, 0.0, 0.0 }, /* Lanczos2, sharpened */
/* Robidoux: Keys cubic close to Lanczos2D sharpened */
/* RobidouxSharp: Sharper version of Robidoux */
{ CubicBC, 2.0, 1.105822933719019,
0.2620145123990142, 0.3689927438004929 },
- { Cosine, 1.0, 1.0, 0.0, 0.0 } /* Low level cosine window */
+ { Cosine, 1.0, 1.0, 0.0, 0.0 }, /* Low level cosine window */
+ { CubicBC, 2.0, 2.0, 1.0, 0.0 }, /* Cubic B-Spline (B=1,C=0) */
};
/*
The known zero crossings of the Jinc() or more accurately the Jinc(x*PI)
http://cose.math.bas.bg/webMathematica/webComputing/BesselZeros.jsp
using Jv-function with v=1, then dividing by PI.
*/
- static MagickRealType
+ static double
jinc_zeros[16] =
{
1.2196698912665045,
{
case BoxFilter:
/* Support for Cylindrical Box should be sqrt(2)/2 */
- resize_filter->support=(MagickRealType) MagickSQ1_2;
+ resize_filter->support=(double) MagickSQ1_2;
break;
case LanczosFilter:
case LanczosSharpFilter:
if (artifact != (const char *) NULL)
resize_filter->blur*=StringToDouble(artifact,(char **) NULL);
if (resize_filter->blur < MagickEpsilon)
- resize_filter->blur=(MagickRealType) MagickEpsilon;
+ resize_filter->blur=(double) MagickEpsilon;
/* Support Overrides */
artifact=GetImageArtifact(image,"filter:lobes");
lobes=(ssize_t) StringToLong(artifact);
if (lobes < 1)
lobes=1;
- resize_filter->support=(MagickRealType) lobes;
+ resize_filter->support=(double) lobes;
}
/* Convert a Jinc function lobes value to a real support value */
if (resize_filter->filter == Jinc)
% The format of the AdaptiveResizeImage method is:
%
% Image *AdaptiveResizeImage(const Image *image,const size_t columns,
-% const size_t rows, ExceptionInfo *exception)
+% const size_t rows,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
MagickExport Image *AdaptiveResizeImage(const Image *image,
const size_t columns,const size_t rows,ExceptionInfo *exception)
{
- Image
- *resize_image;
-
- resize_image=InterpolativeResizeImage(image,columns,rows,MeshInterpolatePixel,
- exception);
- return(resize_image);
+ return(InterpolativeResizeImage(image,columns,rows,MeshInterpolatePixel,
+ exception));
}
\f
/*
%
% The format of the BesselOrderOne method is:
%
-% MagickRealType BesselOrderOne(MagickRealType x)
+% double BesselOrderOne(double x)
%
% A description of each parameter follows:
%
-% o x: MagickRealType value.
+% o x: double value.
%
*/
#undef I0
-static MagickRealType I0(MagickRealType x)
+static double I0(double x)
{
- MagickRealType
+ double
sum,
t,
y;
for (i=2; t > MagickEpsilon; i++)
{
sum+=t;
- t*=y/((MagickRealType) i*i);
+ t*=y/((double) i*i);
}
return(sum);
}
#undef J1
-static MagickRealType J1(MagickRealType x)
+static double J1(double x)
{
- MagickRealType
+ double
p,
q;
}
#undef P1
-static MagickRealType P1(MagickRealType x)
+static double P1(double x)
{
- MagickRealType
+ double
p,
q;
}
#undef Q1
-static MagickRealType Q1(MagickRealType x)
+static double Q1(double x)
{
- MagickRealType
+ double
p,
q;
return(p/q);
}
-static MagickRealType BesselOrderOne(MagickRealType x)
+static double BesselOrderOne(double x)
{
- MagickRealType
+ double
p,
q;
%
% The format of the GetResizeFilterSupport method is:
%
-% MagickRealType GetResizeFilterSupport(const ResizeFilter *resize_filter)
+% double GetResizeFilterSupport(const ResizeFilter *resize_filter)
%
% A description of each parameter follows:
%
% o filter: Image filter to use.
%
*/
-MagickPrivate MagickRealType GetResizeFilterSupport(
+MagickPrivate double GetResizeFilterSupport(
const ResizeFilter *resize_filter)
{
assert(resize_filter != (ResizeFilter *) NULL);
%
% The format of the GetResizeFilterWeight method is:
%
-% MagickRealType GetResizeFilterWeight(const ResizeFilter *resize_filter,
-% const MagickRealType x)
+% double GetResizeFilterWeight(const ResizeFilter *resize_filter,
+% const double x)
%
% A description of each parameter follows:
%
% o x: the point.
%
*/
-MagickPrivate MagickRealType GetResizeFilterWeight(
- const ResizeFilter *resize_filter,const MagickRealType x)
+MagickPrivate double GetResizeFilterWeight(
+ const ResizeFilter *resize_filter,const double x)
{
- MagickRealType
+ double
scale,
weight,
x_blur;
scale.x=(double) image->columns/resize_image->columns;
scale.y=(double) image->rows/resize_image->rows;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static) shared(progress,status) \
+ #pragma omp parallel for schedule(static,4) shared(progress,status) \
dynamic_number_threads(image,image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) resize_image->rows; y++)
exception);
if (q == (Quantum *) NULL)
continue;
- offset.y=((MagickRealType) y+0.5)*scale.y-0.5;
+ offset.y=((double) y+0.5)*scale.y-0.5;
for (x=0; x < (ssize_t) resize_image->columns; x++)
{
register ssize_t
resize_traits,
traits;
- channel=GetPixelChannelMapChannel(image,i);
- traits=GetPixelChannelMapTraits(image,channel);
- resize_traits=GetPixelChannelMapTraits(resize_image,channel);
+ channel=GetPixelChannelChannel(image,i);
+ traits=GetPixelChannelTraits(image,channel);
+ resize_traits=GetPixelChannelTraits(resize_image,channel);
if ((traits == UndefinedPixelTrait) ||
(resize_traits == UndefinedPixelTrait))
continue;
- offset.x=((MagickRealType) x+0.5)*scale.x-0.5;
+ offset.x=((double) x+0.5)*scale.x-0.5;
status=InterpolatePixelChannels(image,image_view,resize_image,method,
offset.x,offset.y,q,exception);
}
rescale_traits,
traits;
- channel=GetPixelChannelMapChannel(image,i);
- traits=GetPixelChannelMapTraits(image,channel);
- rescale_traits=GetPixelChannelMapTraits(rescale_image,channel);
+ channel=GetPixelChannelChannel(image,i);
+ traits=GetPixelChannelTraits(image,channel);
+ rescale_traits=GetPixelChannelTraits(rescale_image,channel);
if ((traits == UndefinedPixelTrait) ||
(rescale_traits == UndefinedPixelTrait))
continue;
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- magnify_image=ResizeImage(image,2*image->columns,2*image->rows,CubicFilter,
+ magnify_image=ResizeImage(image,2*image->columns,2*image->rows,SplineFilter,
exception);
return(magnify_image);
}
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- minify_image=ResizeImage(image,image->columns/2,image->rows/2,CubicFilter,
+ minify_image=ResizeImage(image,image->columns/2,image->rows/2,SplineFilter,
exception);
return(minify_image);
}
typedef struct _ContributionInfo
{
- MagickRealType
+ double
weight;
ssize_t
size_t
number_threads;
- number_threads=GetOpenMPMaximumThreads();
+ number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
contribution=(ContributionInfo **) AcquireQuantumMemory(number_threads,
sizeof(*contribution));
if (contribution == (ContributionInfo **) NULL)
(void) ResetMagickMemory(contribution,0,number_threads*sizeof(*contribution));
for (i=0; i < (ssize_t) number_threads; i++)
{
- contribution[i]=(ContributionInfo *) AcquireAlignedMemory(count,
- sizeof(**contribution));
+ contribution[i]=(ContributionInfo *) MagickAssumeAligned(
+ AcquireAlignedMemory(count,sizeof(**contribution)));
if (contribution[i] == (ContributionInfo *) NULL)
return(DestroyContributionThreadSet(contribution));
}
}
static MagickBooleanType HorizontalFilter(const ResizeFilter *resize_filter,
- const Image *image,Image *resize_image,const MagickRealType x_factor,
+ const Image *image,Image *resize_image,const double x_factor,
const MagickSizeType span,MagickOffsetType *offset,ExceptionInfo *exception)
{
#define ResizeImageTag "Resize/Image"
MagickBooleanType
status;
- MagickRealType
+ double
scale,
support;
/*
Support too small even for nearest neighbour: Reduce to point sampling.
*/
- support=(MagickRealType) 0.5;
+ support=(double) 0.5;
scale=1.0;
}
contributions=AcquireContributionThreadSet((size_t) (2.0*support+3.0));
#endif
for (x=0; x < (ssize_t) resize_image->columns; x++)
{
- MagickRealType
+ double
bisect,
density;
if( IfMagickFalse(status) )
continue;
- bisect=(MagickRealType) (x+0.5)/x_factor+MagickEpsilon;
+ bisect=(double) (x+0.5)/x_factor+MagickEpsilon;
start=(ssize_t) MagickMax(bisect-support+0.5,0.0);
stop=(ssize_t) MagickMin(bisect+support+0.5,(double) image->columns);
density=0.0;
{
contribution[n].pixel=start+n;
contribution[n].weight=GetResizeFilterWeight(resize_filter,scale*
- ((MagickRealType) (start+n)-bisect+0.5));
+ ((double) (start+n)-bisect+0.5));
density+=contribution[n].weight;
}
if ((density != 0.0) && (density != 1.0))
register ssize_t
i;
- if (GetPixelMask(resize_image,q) != 0)
- {
- q+=GetPixelChannels(resize_image);
- continue;
- }
for (i=0; i < (ssize_t) GetPixelChannels(resize_image); i++)
{
- MagickRealType
+ double
alpha,
gamma,
pixel;
ssize_t
k;
- channel=GetPixelChannelMapChannel(image,i);
- traits=GetPixelChannelMapTraits(image,channel);
- resize_traits=GetPixelChannelMapTraits(resize_image,channel);
+ channel=GetPixelChannelChannel(image,i);
+ traits=GetPixelChannelTraits(image,channel);
+ resize_traits=GetPixelChannelTraits(resize_image,channel);
if ((traits == UndefinedPixelTrait) ||
(resize_traits == UndefinedPixelTrait))
continue;
- if ((resize_traits & CopyPixelTrait) != 0)
+ if (((resize_traits & CopyPixelTrait) != 0) ||
+ (GetPixelMask(resize_image,q) != 0))
{
j=(ssize_t) (MagickMin(MagickMax(bisect,(double) start),(double)
stop-1.0)+0.5);
}
static MagickBooleanType VerticalFilter(const ResizeFilter *resize_filter,
- const Image *image,Image *resize_image,const MagickRealType y_factor,
+ const Image *image,Image *resize_image,const double y_factor,
const MagickSizeType span,MagickOffsetType *offset,ExceptionInfo *exception)
{
CacheView
PixelInfo
zero;
- MagickRealType
+ double
scale,
support;
/*
Support too small even for nearest neighbour: Reduce to point sampling.
*/
- support=(MagickRealType) 0.5;
+ support=(double) 0.5;
scale=1.0;
}
contributions=AcquireContributionThreadSet((size_t) (2.0*support+3.0));
#endif
for (y=0; y < (ssize_t) resize_image->rows; y++)
{
- MagickRealType
+ double
bisect,
density;
if( IfMagickFalse(status) )
continue;
- bisect=(MagickRealType) (y+0.5)/y_factor+MagickEpsilon;
+ bisect=(double) (y+0.5)/y_factor+MagickEpsilon;
start=(ssize_t) MagickMax(bisect-support+0.5,0.0);
stop=(ssize_t) MagickMin(bisect+support+0.5,(double) image->rows);
density=0.0;
{
contribution[n].pixel=start+n;
contribution[n].weight=GetResizeFilterWeight(resize_filter,scale*
- ((MagickRealType) (start+n)-bisect+0.5));
+ ((double) (start+n)-bisect+0.5));
density+=contribution[n].weight;
}
if ((density != 0.0) && (density != 1.0))
register ssize_t
i;
- if (GetPixelMask(resize_image,q) != 0)
- {
- q+=GetPixelChannels(resize_image);
- continue;
- }
for (i=0; i < (ssize_t) GetPixelChannels(resize_image); i++)
{
- MagickRealType
+ double
alpha,
gamma,
pixel;
ssize_t
k;
- channel=GetPixelChannelMapChannel(image,i);
- traits=GetPixelChannelMapTraits(image,channel);
- resize_traits=GetPixelChannelMapTraits(resize_image,channel);
+ channel=GetPixelChannelChannel(image,i);
+ traits=GetPixelChannelTraits(image,channel);
+ resize_traits=GetPixelChannelTraits(resize_image,channel);
if ((traits == UndefinedPixelTrait) ||
(resize_traits == UndefinedPixelTrait))
continue;
- if ((resize_traits & CopyPixelTrait) != 0)
+ if (((resize_traits & CopyPixelTrait) != 0) ||
+ (GetPixelMask(resize_image,q) != 0))
{
j=(ssize_t) (MagickMin(MagickMax(bisect,(double) start),(double)
stop-1.0)+0.5);
{
k=(ssize_t) ((contribution[j].pixel-contribution[0].pixel)*
image->columns+x);
- alpha=contribution[j].weight*QuantumScale*
- GetPixelAlpha(image,p+k*GetPixelChannels(image));
+ alpha=contribution[j].weight*QuantumScale*GetPixelAlpha(image,p+k*
+ GetPixelChannels(image));
pixel+=alpha*p[k*GetPixelChannels(image)+i];
gamma+=alpha;
}
MagickOffsetType
offset;
- MagickRealType
+ double
x_factor,
y_factor;
/*
Acquire resize filter.
*/
- x_factor=(MagickRealType) columns/(MagickRealType) image->columns;
- y_factor=(MagickRealType) rows/(MagickRealType) image->rows;
+ x_factor=(double) columns/(double) image->columns;
+ y_factor=(double) rows/(double) image->rows;
if ((x_factor*y_factor) > WorkLoadFactor)
filter_image=CloneImage(image,columns,image->rows,MagickTrue,exception);
else
filter_type=PointFilter;
else
if ((image->storage_class == PseudoClass) ||
- IfMagickTrue(image->matte) ||
+ image->alpha_trait == BlendPixelTrait ||
((x_factor*y_factor) > 1.0))
filter_type=MitchellFilter;
resize_filter=AcquireResizeFilter(image,filter_type,MagickFalse,exception);
ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
}
for (x=0; x < (ssize_t) sample_image->columns; x++)
- x_offset[x]=(ssize_t) (((MagickRealType) x+0.5)*image->columns/
+ x_offset[x]=(ssize_t) (((double) x+0.5)*image->columns/
sample_image->columns);
/*
Sample each row.
image_view=AcquireVirtualCacheView(image,exception);
sample_view=AcquireAuthenticCacheView(sample_image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- #pragma omp parallel for schedule(static) shared(progress,status) \
+ #pragma omp parallel for schedule(static,4) shared(progress,status) \
dynamic_number_threads(image,image->columns,image->rows,1)
#endif
for (y=0; y < (ssize_t) sample_image->rows; y++)
if( IfMagickFalse(status) )
continue;
- y_offset=(ssize_t) (((MagickRealType) y+0.5)*image->rows/
+ y_offset=(ssize_t) (((double) y+0.5)*image->rows/
sample_image->rows);
p=GetCacheViewVirtualPixels(image_view,0,y_offset,image->columns,1,
exception);
sample_traits,
traits;
- channel=GetPixelChannelMapChannel(image,i);
- traits=GetPixelChannelMapTraits(image,channel);
- sample_traits=GetPixelChannelMapTraits(sample_image,channel);
+ channel=GetPixelChannelChannel(image,i);
+ traits=GetPixelChannelTraits(image,channel);
+ sample_traits=GetPixelChannelTraits(sample_image,channel);
if ((traits == UndefinedPixelTrait) ||
(sample_traits == UndefinedPixelTrait))
continue;
next_row,
proceed;
- MagickRealType
+ double
alpha,
gamma,
pixel[CompositePixelChannel],
/*
Allocate memory.
*/
- x_vector=(MagickRealType *) AcquireQuantumMemory((size_t) image->columns,
+ x_vector=(double *) AcquireQuantumMemory((size_t) image->columns,
GetPixelChannels(image)*sizeof(*x_vector));
scanline=x_vector;
if (image->rows != scale_image->rows)
- scanline=(MagickRealType *) AcquireQuantumMemory((size_t) image->columns,
+ scanline=(double *) AcquireQuantumMemory((size_t) image->columns,
GetPixelChannels(image)*sizeof(*scanline));
- scale_scanline=(MagickRealType *) AcquireQuantumMemory((size_t)
+ scale_scanline=(double *) AcquireQuantumMemory((size_t)
scale_image->columns,MaxPixelChannels*sizeof(*scale_scanline));
- y_vector=(MagickRealType *) AcquireQuantumMemory((size_t) image->columns,
+ y_vector=(double *) AcquireQuantumMemory((size_t) image->columns,
GetPixelChannels(image)*sizeof(*y_vector));
- if ((scanline == (MagickRealType *) NULL) ||
- (scale_scanline == (MagickRealType *) NULL) ||
- (x_vector == (MagickRealType *) NULL) ||
- (y_vector == (MagickRealType *) NULL))
+ if ((scanline == (double *) NULL) ||
+ (scale_scanline == (double *) NULL) ||
+ (x_vector == (double *) NULL) ||
+ (y_vector == (double *) NULL))
{
scale_image=DestroyImage(scale_image);
ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
PixelTrait
traits;
- channel=GetPixelChannelMapChannel(image,i);
- traits=GetPixelChannelMapTraits(image,channel);
+ channel=GetPixelChannelChannel(image,i);
+ traits=GetPixelChannelTraits(image,channel);
if ((traits & BlendPixelTrait) == 0)
{
- x_vector[x*GetPixelChannels(image)+i]=(MagickRealType) p[i];
+ x_vector[x*GetPixelChannels(image)+i]=(double) p[i];
continue;
}
alpha=QuantumScale*GetPixelAlpha(image,p);
PixelTrait
traits;
- channel=GetPixelChannelMapChannel(image,i);
- traits=GetPixelChannelMapTraits(image,channel);
+ channel=GetPixelChannelChannel(image,i);
+ traits=GetPixelChannelTraits(image,channel);
if ((traits & BlendPixelTrait) == 0)
{
- x_vector[x*GetPixelChannels(image)+i]=(MagickRealType)
+ x_vector[x*GetPixelChannels(image)+i]=(double)
p[i];
continue;
}
PixelTrait
traits;
- channel=GetPixelChannelMapChannel(image,i);
- traits=GetPixelChannelMapTraits(image,channel);
+ channel=GetPixelChannelChannel(image,i);
+ traits=GetPixelChannelTraits(image,channel);
if ((traits & BlendPixelTrait) == 0)
{
- x_vector[x*GetPixelChannels(image)+i]=(MagickRealType)
- p[i];
+ x_vector[x*GetPixelChannels(image)+i]=(double) p[i];
continue;
}
alpha=QuantumScale*GetPixelAlpha(image,p);
ssize_t
offset;
- channel=GetPixelChannelMapChannel(scale_image,i);
- traits=GetPixelChannelMapTraits(image,channel);
- scale_traits=GetPixelChannelMapTraits(scale_image,channel);
+ channel=GetPixelChannelChannel(scale_image,i);
+ traits=GetPixelChannelTraits(image,channel);
+ scale_traits=GetPixelChannelTraits(scale_image,channel);
if ((traits == UndefinedPixelTrait) ||
(scale_traits == UndefinedPixelTrait))
continue;
- offset=GetPixelChannelMapOffset(image,channel);
+ offset=GetPixelChannelOffset(image,channel);
if ((traits & BlendPixelTrait) == 0)
{
SetPixelChannel(scale_image,channel,ClampToQuantum(
continue;
}
alpha=QuantumScale*scanline[x*GetPixelChannels(image)+
- GetPixelChannelMapChannel(image,AlphaPixelChannel)];
+ GetPixelChannelChannel(image,AlphaPixelChannel)];
gamma=MagickEpsilonReciprocal(alpha);
SetPixelChannel(scale_image,channel,ClampToQuantum(gamma*scanline[
x*GetPixelChannels(image)+offset]),q);
PixelTrait
traits;
- channel=GetPixelChannelMapChannel(image,i);
- traits=GetPixelChannelMapTraits(image,channel);
+ channel=GetPixelChannelChannel(image,i);
+ traits=GetPixelChannelTraits(image,channel);
if (traits == UndefinedPixelTrait)
continue;
pixel[i]+=span.x*scanline[x*GetPixelChannels(image)+i];
((ssize_t) n < (ssize_t) scale_image->columns))
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
- channel=GetPixelChannelMapChannel(image,i);
+ channel=GetPixelChannelChannel(image,i);
scale_scanline[n*MaxPixelChannels+channel]=pixel[i];
}
/*
}
for (i=0; i < (ssize_t) GetPixelChannels(scale_image); i++)
{
- channel=GetPixelChannelMapChannel(scale_image,i);
- traits=GetPixelChannelMapTraits(image,channel);
- scale_traits=GetPixelChannelMapTraits(scale_image,channel);
+ channel=GetPixelChannelChannel(scale_image,i);
+ traits=GetPixelChannelTraits(image,channel);
+ scale_traits=GetPixelChannelTraits(scale_image,channel);
if ((traits == UndefinedPixelTrait) ||
(scale_traits == UndefinedPixelTrait))
continue;
scale_scanline[x*MaxPixelChannels+channel]),q);
continue;
}
- alpha=QuantumScale*scanline[x*GetPixelChannels(image)+
- GetPixelChannelMapChannel(image,AlphaPixelChannel)];
- gamma=MagickEpsilonReciprocal(alpha);
- SetPixelChannel(scale_image,channel,ClampToQuantum(gamma*
+ SetPixelChannel(scale_image,channel,ClampToQuantum(
scale_scanline[x*MaxPixelChannels+channel]),q);
}
q+=GetPixelChannels(scale_image);
/*
Free allocated memory.
*/
- y_vector=(MagickRealType *) RelinquishMagickMemory(y_vector);
- scale_scanline=(MagickRealType *) RelinquishMagickMemory(scale_scanline);
+ y_vector=(double *) RelinquishMagickMemory(y_vector);
+ scale_scanline=(double *) RelinquishMagickMemory(scale_scanline);
if (scale_image->rows != image->rows)
- scanline=(MagickRealType *) RelinquishMagickMemory(scanline);
- x_vector=(MagickRealType *) RelinquishMagickMemory(x_vector);
+ scanline=(double *) RelinquishMagickMemory(scanline);
+ x_vector=(double *) RelinquishMagickMemory(x_vector);
scale_image->type=image->type;
return(scale_image);
}
Image
*thumbnail_image;
- MagickRealType
+ double
x_factor,
y_factor;
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- x_factor=(MagickRealType) columns/(MagickRealType) image->columns;
- y_factor=(MagickRealType) rows/(MagickRealType) image->rows;
+ x_factor=(double) columns/(double) image->columns;
+ y_factor=(double) rows/(double) image->rows;
if ((x_factor*y_factor) > 0.1)
thumbnail_image=ResizeImage(image,columns,rows,image->filter,exception);
else
if (thumbnail_image == (Image *) NULL)
return(thumbnail_image);
(void) ParseAbsoluteGeometry("0x0+0+0",&thumbnail_image->page);
- if( IfMagickFalse(thumbnail_image->matte) )
+ if( IfMagickFalse(thumbnail_image->alpha_trait) )
(void) SetImageAlphaChannel(thumbnail_image,OpaqueAlphaChannel,exception);
thumbnail_image->depth=8;
thumbnail_image->interlace=NoInterlace;