nodeca / pica

Resize image in browser with high quality and high speed

Home Page:http://nodeca.github.io/pica/demo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add mks2021 as a filter option

octopushugger opened this issue · comments

http://johncostella.com/magic/

Now that an updated version is available would be nice to see in pica.

I don't keep in head details about math equations, and it takes notable time to dive into topic. Did not found equations for mks2021, as been provided for mks2013.

If you are familiar with topic, may be you can do PR with new filter? When equation is known, adding it is trivial: https://github.com/nodeca/pica/blob/master/lib/mm_resize/resize_filter_info.js#L53-L62

The math is way beyond my current level.

@j-p-c If you have some free time wanna help add it?

The 2021 version is a big improvement imo. Fixes the oversharpening and slightly decreases aliasing and ringing. I was also surprised to see that a6v7 has almost no visual difference from 2021.

For regular social-media type uses it's a case of diminishing returns. MKS 2013 does a fine job for Facebook and Instagram. MKS 2021 is more correct in not over-sharpening, and the extra generations (e.g. a6v7) are even better in their properties. Those would be more desirable for precision cases, like medical imaging (2D or 3D), and I used a6v7 for the audio resampling. The differences between 2021 and a6v7 can be seen with some of the more demanding test cases in the paper, but in practice it may not be discernible for most images.

The way that @puzrin has structured the code, we'd need to add it in as a single filter, rather than multiple kernels. Already for 2013 this makes the pica implementation slightly less efficient than it could be. For 2021 it would become significantly more so because of the widened support.

Feel free to expand out the kernels and put up a PR, but I'm not sure it should replace 2013 as the default, which works well for most cases and is still close to its maximum efficiency. I think that if this was really needed, it would be better to restructure the code to handle multiple kernels, so that the two Sharp kernels in MKS 2021 would add less overhead.

I think, it's not too difficult to change existing filter format from "single object" to "array of objects". But i don't like to make changes "just for fun" (have other projects to spend time with more valuable result).

So, if mks2013 is "good enough", let's close this issue to remove it from "pending jobs". And leave PR to volunteers, who have time for that.

@j-p-c thank you for consulting. Feel free to ask me anything, if help with my repos required.

I had another request for an explicit formula for MKS 2021 as single resizing kernel, from an author of another resizing library, so I bit the bullet and computed it (and carefully verified it).

The explicit MKS 2021 formula is now on my page (and I added a new graph of it).

@octopushugger: As @puzrin suggests, feel free to implement it and put up a PR.