mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-06 06:03:14 +03:00
fix bicubic stretch interpolation
This commit is contained in:
parent
9634e437ef
commit
c2d688c4b6
|
@ -64,16 +64,14 @@ static struct filter BILINEAR = { bilinear_filter, 1.0 };
|
||||||
|
|
||||||
static inline float bicubic_filter(float x)
|
static inline float bicubic_filter(float x)
|
||||||
{
|
{
|
||||||
/* FIXME: double-check this algorithm */
|
/* http://en.wikipedia.org/wiki/Bicubic_interpolation#Bicubic_convolution_algorithm */
|
||||||
/* FIXME: for best results, "a" should be -0.5 to -1.0, but we'll
|
#define a -1.0
|
||||||
set it to zero for now, to match the 1.1 magnifying filter */
|
|
||||||
#define a 0.0
|
|
||||||
if (x < 0.0)
|
if (x < 0.0)
|
||||||
x = -x;
|
x = -x;
|
||||||
if (x < 1.0)
|
if (x < 1.0)
|
||||||
return (((a + 2.0) * x) - (a + 3.0)) * x*x + 1;
|
return ((a + 2.0) * x - (a + 3.0)) * x*x + 1;
|
||||||
if (x < 2.0)
|
if (x < 2.0)
|
||||||
return (((a * x) - 5*a) * x + 8) * x - 4*a;
|
return (((x - 5) * x + 8) * x - 4) * a;
|
||||||
return 0.0;
|
return 0.0;
|
||||||
#undef a
|
#undef a
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user