-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add support for Magic Kernel Sharp resizing modes #8811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
A notable discrepancy: The correct behavior would be to convert images to a linear color space before resizing. If the situation has changed at all since #1604 was filed it may be worth revisiting, but in either case it's out of scope for this. As you can see, it matches the reference implementation without gamma handling by default, and when applied in linear sRGB space it matches the reference with gamma handling, both within reasonable quantization error. Just for reference, this is the amount of difference this produces on a test image: |
I have updated this to include Magic Kernel Sharp 2013 (at the suggestion of the creator -- it should have the same effects in combatting moire/blockiness while being slightly faster than Lanczos 3) as well as the 2021 implementation. I have also added these kernels to documentation at appropriate points and added them to tests. The additions to concepts.rst may need revision. I have also not added the |
Co-authored-by: Andrew Murray <[email protected]>
Added additional tests
Original formula is by John Costella, link includes paper with explanation of why it works better than Lanczos and demonstrations of its performance: https://johncostella.com/magic/
This is a simple implementation of the Magic Kernel Sharp 2021 resize filter. It should produce higher quality results for resampling, either upsampling or downsampling, than Lanczos.
This PR is incomplete, I still need to test it against the reference implementation of MKS, write tests for it, update documentation samples, and run linting. The outputs that I have gotten from preliminary testing overall look as expected and look better than Lanczos in the expected ways (reduced moiré patterning on downsampling, reduced blockiness on upscaling), so it should be in a state where it is suitable for experimentation if wanted.