-
-
Notifications
You must be signed in to change notification settings - Fork 245
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
Bug in cubic scaling #593
Comments
I tried with |
OK, so with It seems that the https://github.com/brendan-duncan/image/blob/main/lib/src/transform/copy_resize.dart#L162 This is not what I would expect from a linear or cubic interpolation, as shown by the Gimp example above. for any scale factor smaller than 0.5, |
Yeah, you're right, it should do a gather and interpolate over all of the pixels converging in the down sampling. |
This is a bit costly, but you could do the gather by just calling |
The usual trick for cubic down sampling is to use a guassian blur on the image and then downsample. Which, as you said, is more costly. An average would be an approximation to that, a bilinear down sample. There's no getting around it being more costly to do decent down sampling. |
Right, what I was suggesting is equivalent to a convolution of a convolution of two box functions, which is a convolution with a triangle function, which is a 2nd order approximation of a Gaussian. It should be faster than convolving with a Gaussian, but give a similar result. |
If I scale an image down using cubic scaling, the pixels appear "locally jumbled", which in an image processing algorithm typically indicates that the weights in adjacent pixels were inadvertently switched, or similar.
For example, take this original image, at 1080x1920:
Scaling this down to 270x480 using
copyResize(image, width: 270, interpolation: Interpolation.cubic)
gives the following (zoom in to see the local pixel jumbling):The same downscaling in Gimp, using cubic interpolation, gives the correct and expected result:
The text was updated successfully, but these errors were encountered: