silvia-odwyer / photon

⚡ Rust/WebAssembly image processing library
https://silvia-odwyer.github.io/photon
Apache License 2.0
2.72k stars 154 forks source link

Paeth-Rotate and Shear #178

Closed volbot closed 5 months ago

volbot commented 6 months ago

TL;DR: I'm currently working to refine transform::rotate using Paeth's shearing algorithm, so necessarily I'm also adding transform::shear.

Problem: transform::rotate is naively implemented, as explained in the documentation for the method. As mentioned in #170, it adds a thick layer of compression to everything it touches. Solution: As suggested in the aforementioned documentation, I'm reworking it to use Alan Paeth's algorithm, which renders an arbitrary rotation using three calculated shears.

General Notes: I've already got the Paeth rotation working, but there's a handful of issues remaining: 1) It's not as performant as it could be, and I think it's slower than Photon's current implementation, but it's currently difficult to accurately test, because 2) I implemented the whole thing as a wrapper in a separate, personal repository. I'm making a volume knob app, and it's all over there, so I'm going to have to re-implement it into Photon and set up the WASM bindings and such. 3) It leaves holes in the image. The function, as I've implemented it, doesn't appear to be onto. I think the problem is with the shear function, which is admittedly over-simplified, and shouldn't really be embedded into the rotate function anyway, so I'm going to abstract that out into a separate function, which had might as well become transform::shear.

I figured I should create an issue before I get into the woods of interpolation function, just to make sure I'm not missing anything critical about Photon that previous contributors would pick up on. I'm new to the code base, so let me know if I'm mistakenly reinventing any wheels or anything of that nature.

silvia-odwyer commented 5 months ago

@volbot Hi there! It would be excellent to have this added to the library. Thanks very much for implementing this in your pull request, I'm going to merge it now ✅