Why was the Lanczos filter removed?

Skip to first unread message

Stefan O.

Mar 27, 2024, 9:09:34 AMMar 27
to skia-discuss
If I downscale an image using lanczos filter in Affinity Photo it has great quality compared to the linear filter.

There was once a Lanczos filter option in SKIA:
Why was it removed? Will it ever come back?

I find downscaled images using SKIA not looking very good.

The mitchell & catmull_rom filters are no replacement.
They look very blocky, because they don't seem to support midmaps.
(Maybe that's an skiko issue, not sure about that.)

I had those blocks on linear to until I figured out that I need to specify a MipmapMode.

Using skiko, a Kotlin SKIA wrapper, my code looks like this:

val bitmap = Bitmap()
bitmap.allocN32Pixels(thumbnailSize.width, thumbnailSize.height)
this.scalePixels(bitmap.peekPixels()!!, FilterMipmap(FilterMode.LINEAR, MipmapMode.LINEAR), false)
val downscaledImage = Image.makeFromBitmap(bitmap)

How are the plans for the Lanczos filter?

Greg Daniel

Mar 27, 2024, 10:07:52 AMMar 27
to skia-d...@googlegroups.com
I can't really answer the Lanczos question, but as to your question about mipmaps they should give you good quality on downsampling. You can look at this example fiddle here, https://fiddle.skia.org/c/75079f18906f12241fe9a4760bd11254. So my guess is if you are not getting the expected quality than there may be a bug in your wrapper of Skia, i.e. skiko. Though if you are able to reproduce the issue using raw Skia (or ideally in fiddle.skia.org) we'd be very interested in investigating it more.

You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/22e027a1-3796-4d53-b07d-9446890d8696n%40googlegroups.com.

Stefan O.

Mar 27, 2024, 1:08:39 PMMar 27
to skia-discuss

Yes, for LINEAR and NEAREST they work.
But I can’t specify them on cubic sampling (Mitchell and Catmull Rom), so the output looks blocky.
I can do the multiple resizes by 50% myself, but that’s slower due do the overhead.

Stefan O.

Mar 27, 2024, 1:15:34 PMMar 27
to skia-discuss

Okay, I opened up an issue.

I did not find another issue asking for Lanczos, so I might be the first one who cares. 😅

John Stiles

Mar 27, 2024, 3:05:15 PMMar 27
to skia-d...@googlegroups.com
I believe the references to Lanczos you are finding originate from here:

This is Chrome image code that is layered on top of Skia, not part of Skia proper.
It doesn't surprise me that SkiaSharp absorbed that code as well since it's certainly useful.
You might be able to convince Skiko to adopt it as well, but I don't think we have any plans to migrate it from Chrome into Skia at this time.

Stefan O.

Mar 27, 2024, 4:31:14 PMMar 27
to skia-discuss
Thank you! That actually explains a lot to me! :)
Reply all
Reply to author
0 new messages