Skip to content
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

How to improve imresize for downsizing #28

Closed
Evizero opened this issue May 5, 2017 · 5 comments
Closed

How to improve imresize for downsizing #28

Evizero opened this issue May 5, 2017 · 5 comments

Comments

@Evizero
Copy link
Member

Evizero commented May 5, 2017

Right now imresize performs something that is pretty similar to simple pixel sub-sampling. Naturally the quality of the result isn't particularly breathtaking.

I open this issue to brainstorm on what would be a good way to improve the quality for downsizing and image to an arbitrary specified size.

The straight forward way of doing it would be in two steps: 1.) Filter image, 2.) sub-sample. However, this would add an additional temporary array that I suspect could probably be avoided.

@timholy
Copy link
Member

timholy commented May 7, 2017

This page points out that one can effectively use the same splines that we use for interpolation, but stretch them to cover the "grid" of the reduced-size image. Not entirely trivial to implement, but not insanely difficult either. I suspect the main question is whether we want to support multiple splines or just pick one. I suspect if we started with linear (triangular splines) we'd be pretty happy.

Interestingly, that page suggests handling one dimension at a time, rather than computing the result directly. It's the same strategy that restrict is using.

@Evizero
Copy link
Member Author

Evizero commented May 13, 2017

Thanks for the pointers. I think this is currently a little beyond me in terms of skill and time, but a good thing to keep in mind.

@babaq
Copy link

babaq commented Oct 13, 2020

I am also curious about interpolations for upsampling/downsampling of images, the MATLAB and Pillow both support several methods, and some of them, for example , the Lanczos kernel seems easy to implement in the image filtering framework, is it possible to just add the kernel, and then, we can use filtering and imresize to achieve anti-aliasing resizing?

@johnnychen94
Copy link
Member

I am also curious about interpolations for upsampling/downsampling of images, the MATLAB and Pillow both support several methods, and some of them, for example , the Lanczos kernel seems easy to implement in the image filtering framework, is it possible to just add the kernel, and then, we can use filtering and imresize to achieve anti-aliasing resizing?

This is now available (provided by #115) since v0.8.11:

using Interpolations

imresize(img, sz; method=Lanczos(2))
imresize(img, sz; method=Lanczos4OpenCV())

@johnnychen94
Copy link
Member

I'm closing this in favor of #120 as I didn't observe any particular bad alias result.

But feel free to reopen it if this is still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants