Dogway / Avisynth-Scripts

AviSynth+ 3.7.3+ Filters
GNU General Public License v3.0
85 stars 11 forks source link

Port vapoursynth detailmask lvsfunc. #72

Closed Kuronoe-Ookami closed 1 year ago

Kuronoe-Ookami commented 1 year ago

Hello. Could you consider looking into whether there is a possibility to port detailmask from vapoursynth to avisynth? It's a great mask for black backgrounds and very small things, but apparently it's abandoned, it's pretty hard to find about.

there are two versions of it, normal and neo_: https://lvsfunc.encode.moe/en/v0.3.10/index.html?highlight=mask.detail_mask#lvsfunc.mask.detail_mask

Here is the mask.py that contains them, I believe they are not on the wiki anymore. mask.txt

Thank you for keeping avisynth alive.

Dogway commented 1 year ago

Do you have an example image and the mask it produces? Reading the description this might be similar to FlatMask + LumaMask.

You can combine both with ex_logic(). I guess this is for anime?

Kuronoe-Ookami commented 1 year ago

You're right, they are similar if I put them together. Here is the result in the default configuration for both. dropbox

The detailmask lines tend to be more solid, which is good for shadows, maybe the binarize will help with that, I need to test with more time. Thank you for responding quickly earlier.

Dogway commented 1 year ago

Yes, VP seems a bit too strong, probably more like a flat mask rather than an edge mask per-se. You can play with FlatMask's 'scale' and 'lo' args to make it stronger.

EDIT: Actually just tested and it doesn't seem to be a Ridge Filter, a simple edge mask does the job. Check something like this.

ex_edge("frei-chen",hi=25)
ex_expand(mode="disk")
ex_deflate()
ex_smooth(2,mode="SG")
Kuronoe-Ookami commented 1 year ago

Yes, it looks very similar to the example you showed me. I always prefer FlatMask and DebandingMask in avisynth, I really like the result. On Vapoursynth I use the DetailMask a lot, retinex usually takes longer to encode. I always have problems with debanding and denoise, they end up disappearing with some detail, so these masks help a lot. Especially in scenes similar to the second image, on the wall and door, it's really hard to keep those lines.

Thanks for helping and for the helpful tips, I'll try to test more variations.

Dogway commented 1 year ago

There's another option to increase edge detection, using convolution with ex_unsharp(). In this case I use it for LumaMask() so more edges are picked as dark. Then you mix it with ex_edge() with overlay blend mode to improve its edge masking, or simply with 'linearadd' to add dark masking.

LM=lumamask(ex_unsharp(2,Fc=width()/4),30,70,invert=true)
ex_edge("frei-chen",lo=4,hi=25)

ex_expand(mode="disk")
ex_deflate()
ex_smooth(2,mode="SG")

ex_blend(LM,mode="overlay")
Kuronoe-Ookami commented 1 year ago

Hi, This second example is very good in these bad scenes, it works better than the simple masks. As there are few scenes like this, I think I can use the first mask for the most part and map these bad scenes to this second example and see how it turns out.

I want to test these variations with a more destructive denoise, maybe waifu2x, I'm using KnlmeansCL and it's very good for what I need. Well, I tried asd-g's waifu2x, but I can't get this RGB32-Planar to work on it, I need to find out what it is to see how the result comes out.

Thank you for all your help and for your time teaching me. 👍

Dogway commented 1 year ago

Closing for now. If you have any issues open back or create a new issue.