KotatsuApp / Kotatsu

Manga reader for Android
https://kotatsu.app
GNU General Public License v3.0
3.51k stars 162 forks source link

[Feature Req] Add image sharpen and custom color filters #962

Open Ero-gamer opened 1 month ago

Ero-gamer commented 1 month ago

Describe your suggested feature

Hi! If possible add image sharpen and custom color filters (like the one Tachiyomi uses with overlays..etc) since image contrast filter use cases are limited and few.

Acknowledgements

galpt commented 1 month ago

I believe image sharpening is heavier compared to simple overlays, it will definitely consume the battery real quick. You're basically telling your phone to edit every manga image to look sharper.

It'll be easier to implement the sharpening from the img optimization proxy feature. The compute can be offloaded to the proxy and Kotatsu only need to display images. But I haven't seen proxies that can apply color overlays, only compression & sharpening, so overlays might still need to be done by Kotatsu.

galpt commented 1 month ago

I believe sharpening and coloring can be implemented 100% from the 0ms.dev proxy. @Ero-gamer could you give a link or two about what you're expecting from this?

Sharpening is straight to the point, but color filters - I might need to see what color filters you're referring to and how they look. Since I'm one of the devs who maintain the 0ms.dev img proxy, I can give sharpening a try. I'll let you know here if it's a success.

galpt commented 1 month ago

@Ero-gamer So this is a quick example after implementing sharpening to the proxy. Before: https://cdn.myanimelist.net/images/anime/1932/142249l.jpg After: https://x.0ms.dev/q70/https://cdn.myanimelist.net/images/anime/1932/142249l.jpg?sharp=true

Sharpening will only be used if ?sharp=true is added at the end of the URL. By default proxy will just forward images as-is.

Well, I'd say manga images are already optimized, so adding sharpening effect will make them look worse. You can experiment with more images you could find on the Internet and decide if img sharpening is worth adding to Kotatsu.

Ero-gamer commented 1 month ago

Here is an example of manhwa image with and without filter:

Original: Screenshot_2024-07-10-00-35-35-42

Overlay: Screenshot_2024-07-10-00-36-10-87

As you can see, original image is overbright which mess up colors, I have read tons of webtoons/manhwa and most of them suffer from overbright colors, some of them are affected slightly and the rest affected greatly. This feature is available on original Tachiyomi and Mihon as overlay color filter.

Screenshot_2024-07-10-00-36-26-69

Ero-gamer commented 1 month ago

@Ero-gamer So this is a quick example after implementing sharpening to the proxy. Before: https://cdn.myanimelist.net/images/anime/1932/142249l.jpg After: https://x.0ms.dev/q70/https://cdn.myanimelist.net/images/anime/1932/142249l.jpg?sharp=true

Sharpening will only be used if ?sharp=true is added at the end of the URL. By default proxy will just forward images as-is.

Well, I'd say manga images are already optimized, so adding sharpening effect will make them look worse. You can experiment with more images you could find on the Internet and decide if img sharpening is worth adding to Kotatsu.

I compared both images and they look identical, no sharpen filter. Sharpen filter is great on certain blurry and low res images especially if it's a high quality sharpen filter algorithm like lanczos3 or lanczos4 scaling/subsampling.

galpt commented 1 month ago

That overlay feature's indeed can be useful for some manga if the devs implement it.

@Ero-gamer So this is a quick example after implementing sharpening to the proxy. Before: https://cdn.myanimelist.net/images/anime/1932/142249l.jpg After: https://x.0ms.dev/q70/https://cdn.myanimelist.net/images/anime/1932/142249l.jpg?sharp=true Sharpening will only be used if ?sharp=true is added at the end of the URL. By default proxy will just forward images as-is. Well, I'd say manga images are already optimized, so adding sharpening effect will make them look worse. You can experiment with more images you could find on the Internet and decide if img sharpening is worth adding to Kotatsu.

I compared both images and they look identical, no sharpen filter. Sharpen filter is great on certain blurry and low res images especially if it's a high quality sharpen filter like lanczos3 or lanczos4 sharpen filter.

About the sharpening, it's hard because people's screens and eyes are different, so person A might see it as something better while person B might not notice a difference or even see it as worse than the original image.

This is another example, should be noticable, at least on my screen. The sharpening effect shouldn't be that much because like I mentioned, it'll make the image looks even stranger because sharpening is playing with brightness & contrast of the images.

Original: https://cdn.myanimelist.net/images/anime/1567/138687l.jpg After sharpening: https://x.0ms.dev/q70/https://cdn.myanimelist.net/images/anime/1567/138687l.jpg?sharp=true

Upscaling

There's another term called "upscaling" where you'll need a GPU to make every image looks clearer and better than the original, but that'll cost so much just for reading manga, and nobody wants to spend so much money just to read manga everyday.

It'll be expensive to do upscaling via proxy, so this should be done on people's phones with their own mobile GPUs.

The original before upscaling: 138687l

The image after upscaled: 138687l

HironoKenta commented 1 month ago

@Ero-gamer IDK, maybe I'm wrong, but lanczos isn't a sharp filter but a scaler like bicubic, spline, jinc.

Maybe it can be implemented as an optional sharpen scaler in place of the default one?

Ero-gamer commented 1 month ago

@Ero-gamer IDK, maybe I'm wrong, but lanczos isn't a sharp filter but a scaler like bicubic, spline, jinc.

Maybe it can be implemented as an optional sharpen scaler in place of the default one?

You are correct, it's image scaling algorithm with sharp filter, it can be implemented as image scaling and subsampling algorithm.

HironoKenta commented 1 month ago

@Ero-gamer but if it don't change image resolution it usually just do nothing. A simple sharpen filter can be implemented as a 0,-1,0,-1,5,-1,0,-1,0 or -1,-2,-1,-2,13,-2,-1,-2,-1 convolution matrix.