-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Description
I thought "Bicubic" which is used in raster graphic editors like Photoshop, GIMP and so on used "Bicubic interpolation", but, I hear that they really use Lanczos filter or Mitchell-Netravali filter (This so confused me!:confused:).
I want to downsize images so need Lanczos filter and plan to implement it. Lanczos filter takes a positive integer value as the size of the kernel. I have three suggestions about implementation.
Implementation
A. Let ADT have the kernel size
Define such that:
data Lanczos = Lanczos Natural
This way is simple but needs to allocate memory by dynamic way, so it maybe causes slow.
B. Let the name of ADT have kernel size
data Lanczos3 = Lanczos3
This way is simple too, but not cool. To take into account that it can use several kernel sizes only, this selection may be good. And it require implementation each data type, so not need dynamic memory allocation.
C. Use type level number
Black magic:
data Lanczos (n :: Nat) = Lanczos
instance Interpolation (Lanczos 3) where
...
The way of implementation is same as B, but looks cooler. It requires type annotation to use:
writeImage "sample.jpg" $ resize (Lanczos :: Lanczos 3) Edge (300, 400) img
D. Implement only Lanczos-3
It's a possibly.