Mercurial > cgi-bin > hgweb.cgi > SimpleResizer
comparison app/src/main/java/com/bartsent/simpleresizer/lib/LanczosKernel.kt @ 6:e8059b166de1
Lanczos works, but is painfully slow.
author | David Barts <n5jrn@me.com> |
---|---|
date | Tue, 16 Feb 2021 17:29:52 -0800 |
parents | |
children | 6ae738b8a814 |
comparison
equal
deleted
inserted
replaced
5:247e03baf77c | 6:e8059b166de1 |
---|---|
1 package com.bartsent.simpleresizer.lib | |
2 | |
3 import kotlin.math.PI | |
4 import kotlin.math.abs | |
5 import kotlin.math.sin | |
6 | |
7 object LanczosKernel: ScalingKernel { | |
8 override val size = 3.0 | |
9 | |
10 private fun sinc(x: Double): Double { | |
11 if (x == 0.0) | |
12 return 1.0 | |
13 val pix = PI * x | |
14 return sin(pix) / pix | |
15 } | |
16 | |
17 override fun weight(x: Double): Double = | |
18 if (abs(x) < size) sinc(x) * sinc(x/size) else 0.0 | |
19 } |