-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add experimental withoutGaussianBlur
API
#211
Conversation
Applying a Gaussian blur for large reductions of transparent images can cause dark ‘fringing’ around bright parts of the image. See: #3
I wonder if using floating point arithmetic will help here.
(I notice the existing code sets a non-existent |
eba84af
to
6f2715b
Compare
Thanks for the tip, @lovell, but I just tried that and the black fringing got even worse (compared visually). Luckily, I can work around the reduction fringes by disabling the Gaussian blur, but to my dismay, I realized that even upscaling transparent images with straight VIPS CLI causes dark fringes when using non- It’s after 3am here, so I will catch some sleep and come back to this tomorrow with a fresh mind 😄 Happy to discuss best long-term solution to this. For now, we’ll use |
@gasi There’s actually good reasons why they are applying the gaussian blur before downsampling; you can filter the high-frequency noise and therefore avoid moiré patterns. Does this mean that they were doing that blur before your were converting to pre-multiplied alpha? If we convert to pre-multiplied as early as possible (before the blur), it just might fix things, possibly in both upsampling and downsampling cases. The issue is that you can’t interpolate two semi-transparent colors non-pre-multiplied colors. You’ll get the wrong result. For example: So anything that does interpolation of colors, including gaussian blur or resampling, needs to be done in pre-multiplied space. Being a scientific image processing library, not a general purpose one, |
@gasi Thanks for testing the use of floats to remove rounding/truncate errors as a possible source. @julianwa Yes, the blur is to reduce aliasing on diagonal edges, a similar method to *magick's Lanczos filter. In case you missed it, the related improvement to libvips is being discussed over at https://github.com/jcupitt/libvips/issues/291 |
Applying a Gaussian blur for large reductions of transparent images can cause dark ‘fringing’ around bright parts of the image.
This API helps us work around the issue, but I’d love to hear more about the cause of this issue and if there is a way to apply the Gaussian blur safely. We originally assumed this was caused by a missing alpha channel premultiplication before the affine transform but this turned out not to be the case.
See gasi#3 for details.
/cc @julianwa