Mercurial > cgi-bin > hgweb.cgi > SimpleResizer
view 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 |
line wrap: on
line source
package com.bartsent.simpleresizer.lib import kotlin.math.PI import kotlin.math.abs import kotlin.math.sin object LanczosKernel: ScalingKernel { override val size = 3.0 private fun sinc(x: Double): Double { if (x == 0.0) return 1.0 val pix = PI * x return sin(pix) / pix } override fun weight(x: Double): Double = if (abs(x) < size) sinc(x) * sinc(x/size) else 0.0 }