mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 21:24:31 +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)
|
||||
{
|
||||
/* FIXME: double-check this algorithm */
|
||||
/* FIXME: for best results, "a" should be -0.5 to -1.0, but we'll
|
||||
set it to zero for now, to match the 1.1 magnifying filter */
|
||||
#define a 0.0
|
||||
/* http://en.wikipedia.org/wiki/Bicubic_interpolation#Bicubic_convolution_algorithm */
|
||||
#define a -1.0
|
||||
if (x < 0.0)
|
||||
x = -x;
|
||||
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)
|
||||
return (((a * x) - 5*a) * x + 8) * x - 4*a;
|
||||
return (((x - 5) * x + 8) * x - 4) * a;
|
||||
return 0.0;
|
||||
#undef a
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user