remove a 0.5 pixel shift from triangle
lines up with cubic and lanczos now
This commit is contained in:
parent
53119250cc
commit
0767e4f4c9
@ -311,6 +311,37 @@ calculate_coefficients_catmull( double c[4], const double x )
|
||||
c[2] = cthr;
|
||||
}
|
||||
|
||||
/* Given an x in [0,1] (we can have x == 1 when building tables),
|
||||
* calculate c0 .. c(@shrink + 1), the triangle coefficients. This is called
|
||||
* from the interpolator as well as from the table builder.
|
||||
*/
|
||||
static void inline
|
||||
calculate_coefficients_triangle( double *c, const double shrink, const double x )
|
||||
{
|
||||
/* Needs to be in sync with vips_reduce_get_points().
|
||||
*/
|
||||
const int n_points = rint( 2 * shrink ) + 1;
|
||||
|
||||
int i;
|
||||
double sum;
|
||||
|
||||
sum = 0;
|
||||
for( i = 0; i < n_points; i++ ) {
|
||||
double xp = (i - (shrink - 0.5) - x) / shrink;
|
||||
|
||||
double l;
|
||||
|
||||
l = 1.0 - VIPS_FABS( xp );
|
||||
l = VIPS_MAX( 0.0, l );
|
||||
|
||||
c[i] = l;
|
||||
sum += l;
|
||||
}
|
||||
|
||||
for( i = 0; i < n_points; i++ )
|
||||
c[i] /= sum;
|
||||
}
|
||||
|
||||
/* Calculate a catmull kernel for shrinking.
|
||||
*/
|
||||
static void inline
|
||||
@ -397,37 +428,6 @@ calculate_coefficients_lanczos( double *c,
|
||||
c[i] /= sum;
|
||||
}
|
||||
|
||||
/* Given an x in [0,1] (we can have x == 1 when building tables),
|
||||
* calculate c0 .. c(@shrink + 1), the triangle coefficients. This is called
|
||||
* from the interpolator as well as from the table builder.
|
||||
*/
|
||||
static void inline
|
||||
calculate_coefficients_triangle( double *c, const double shrink, const double x )
|
||||
{
|
||||
/* Needs to be in sync with vips_reduce_get_points().
|
||||
*/
|
||||
const int n_points = rint( 2 * shrink ) + 1;
|
||||
|
||||
int i;
|
||||
double sum;
|
||||
|
||||
sum = 0;
|
||||
for( i = 0; i < n_points; i++ ) {
|
||||
double xp = (i - (shrink - 1) - x) / shrink;
|
||||
|
||||
double l;
|
||||
|
||||
l = 1.0 - VIPS_FABS( xp );
|
||||
l = VIPS_MAX( 0.0, l );
|
||||
|
||||
c[i] = l;
|
||||
sum += l;
|
||||
}
|
||||
|
||||
for( i = 0; i < n_points; i++ )
|
||||
c[i] /= sum;
|
||||
}
|
||||
|
||||
/* Our inner loop for resampling with a convolution. Operate on elements of
|
||||
* type T, gather results in an intermediate of type IT.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user