Move splineKernel function nearer to Lanczos definitions.

This commit is contained in:
jst 2013-07-08 20:40:36 +02:00
parent c1b8c4986e
commit 9e5ed35b85
1 changed files with 12 additions and 12 deletions

View File

@ -198,7 +198,19 @@ func Bilinear(img image.Image, factor [2]float32) Filter {
})
}
// Bicubic interpolation (with cubic hermite spline)
func Bicubic(img image.Image, factor [2]float32) Filter {
return createFilter(img, factor, 4, splineKernel(0, 0.5))
}
// Mitchell-Netravali interpolation
func MitchellNetravali(img image.Image, factor [2]float32) Filter {
return createFilter(img, factor, 4, splineKernel(1.0/3.0, 1.0/3.0))
}
func splineKernel(B, C float32) func(float32) float32 {
const lanczosTableSize = 300
factorA := 2.0 - 1.5*B - C
factorB := -3.0 + 2.0*B + C
factorC := 1.0 - 1.0/3.0*B
@ -220,16 +232,6 @@ func splineKernel(B, C float32) func(float32) float32 {
}
}
// Bicubic interpolation (with cubic hermite spline)
func Bicubic(img image.Image, factor [2]float32) Filter {
return createFilter(img, factor, 4, splineKernel(0, 0.5))
}
// Mitchell-Netravali interpolation
func MitchellNetravali(img image.Image, factor [2]float32) Filter {
return createFilter(img, factor, 4, splineKernel(1.0/3.0, 1.0/3.0))
}
func lanczosKernel(a uint) func(float32) float32 {
return func(x float32) (y float32) {
if x > -float32(a) && x < float32(a) {
@ -242,8 +244,6 @@ func lanczosKernel(a uint) func(float32) float32 {
}
}
const lanczosTableSize = 300
// Lanczos interpolation (a=2)
func Lanczos2(img image.Image, factor [2]float32) Filter {
return createFilter(img, factor, 4,