View Full Version : Dogway's Filters Packs
kedautinh12
14th October 2021, 02:03
I downloaded easy with github account
guest
14th October 2021, 02:11
I downloaded easy with github account
Yes, once I signed in, made all the difference :)
tormento
14th October 2021, 09:39
Great! share the clip
Warning! NSFW!
It's the shower scene (https://send.cm/d/5JUr) in Carrie.
It's a plain script
SetMemoryMax()
SetFilterMTMode("DEFAULT_MT_MODE", 2)
LoadPlugin("D:\Eseguibili\Media\DGDecNV\DGDecodeNV.dll")
DGSource("F:\In\carrie.dgi",ct=20,cb=20,cl=0,cr=0)
ConvertBits(16)
SMDegrain (tr=x, thSAD=x00, refinemotion=true, contrasharp=false, PreFilter=4, plane=4, chroma=true) [,lfr=true]
fmtc_bitdepth (bits=8,dmode=8)
Prefetch(6)
where x varies from 4 to 9, accordingly.
Any hint is welcome.
Dogway
14th October 2021, 09:54
Thanks, I didn't get block of any sorts, simply recovered low frequency grain.
You have two options, run my double temporalsoften call (double MDegrain also works), or lower the frequency restoration with LFR=8 for example.
https://i.imgur.com/ibjwVaP.png https://i.imgur.com/vHKSqlY.png
EDIT: this is a good compromise between quality and speed
smdegrain(tr=1,mode="temporalsoften",blksize=32,thSAD=900,LFR=2,contrasharp=false,refinemotion=true)
smdegrain(tr=1,mode="MDegrain",blksize=32,thSAD=300,LFR=false,contrasharp=true,refinemotion=true)
tormento
14th October 2021, 10:55
lower the frequency restoration with LFR=8
Does the number modify the frequency domain or the restoration intensity?
Dogway
14th October 2021, 11:10
The number indicates the cutoff frequency of the lowpass (it isn't parametrized but I would like to do it in the future). The higher the lower frequency is restored, the lower more high (along low) frequencies are restored. It's a low pass so that means that recovered frequencies span from 0 to cutoff frequency.
tormento
14th October 2021, 13:56
The number indicates the cutoff frequency of the lowpass
Do you have any idea of some meaningful numbers/cutoffs to use?
Dogway
14th October 2021, 21:49
Depends on source grain, the greater the grain the more low freq noise you will get. Or you can use two passes as above and get away with a lower LFR (higher cutoff).
Also I forgot about your query on ex_makediff(), can't you just do:
a=last
b=SMDegrain(tr=5, thSAD=500)
c=SMDegrain(tr=7, thSAD=700)
d=SMDegrain(tr=9, thSAD=900)
b=ex_makediff(a,b,aug=true)
c=ex_makediff(a,c,aug=true)
d=ex_makediff(a,d,aug=true)
StackHorizontal(b,c,d)
Julek
14th October 2021, 22:11
I remember you mentioned about reinstalling VS, so I wanted to let you know that Akarin's Expr now has sortN, which is very useful.
https://github.com/AkarinVS/vapoursynth-plugin/wiki/Expr#using-sortn-to-implement-rank-order-filters
Dogway
14th October 2021, 22:41
Wow that's great, too bad pinterf dismissed the sort operator. I'm still trying to figure out how to compose a 48 inputs ranking filter, I know I can use two parallel 24 inputs, then use a Batcher's odd-even sorter to merge both ranked lists, I still don't know how to set up this odd-even sorting network for 48 inputs, I need to run some tests probably in a few days. Will be the last thing to add to ExTools.
I haven't installed VS because my main urge is to finish the current scripts and its issues. Had to rebase all the scripts for the new ex_blur() gaussian to binomial fit. Then also created a MatchClip() function to remove MatchColorFormat() and its Utils-r41 dependency. Also created a few rounding functions to remove m4(), m4_sh, m(), etc and also Zs_RF_Shared.avsi dependency.
My main problem with VS is python, despite I use it for blender and a few random scripts I prefer the more direct approach of AVS+. Programming is reduced to a minimum and you only care about the algo. Python is a bit harder to read, also because the object oriented approach, a bit too verbose IMO. I will install it when I get TransformsPack to a stable release, want to play with the AI filters.
tormento
15th October 2021, 09:21
I haven't installed VS
Don't give in to the dark side. :p
Dogway
15th October 2021, 19:12
No I won't. I look forward to Julia, much faster and probably easier to read (I hate the "X if true else false" of python).
Just updated SimilarityMetrics, vsSSIM had a few issues. Also finished BSSIM.
Also updated ResizersPack, main utility is nmod(), it converts any value to a set mod size, also has an option for minimum value (ie. nmod(n, 4, 16) ). You can also use bankers' rounding. New function PadBorders() pads the clip with borders in set 'mode', as in 'Dilate', 'Mirror' or a color '$000000'. And also updated MatteCrop() to work faster, the function still needs some work.
This weekend I will have a look at MatchClip() and update all the EX/MIX mods according.
Julek
15th October 2021, 20:49
I have a question about your ex_ContraSharpening, why do you use the result of "ssDD range_half -" or "ssD range_half -" to add to the denoised, and the original chooses between ssDD and ssD to then add to the denoised?
ex_CS: https://github.com/Dogway/Avisynth-Scripts/blob/master/MIX%20mods/SharpenersPack.avsi#L566
CS: https://github.com/realfinder/AVS-Stuff/blob/15ec37a05e090c9438fc855b7d2df572436ccb75/avs%202.5%20and%20up/Zs_RF_Shared.avsi#L603-L606
vs-CS: https://github.com/HomeOfVapourSynthEvolution/havsfunc/blob/master/havsfunc.py#L5691-L5693
Dogway
15th October 2021, 21:06
The original version uses mt_adddiff() which does "ssDD range_half -" or "ssD range_half -" in itself, so their output needs to be range_half centered.
I do everything in a single step so no need to add (or keep) the centered values. This is faster.
Julek
15th October 2021, 21:12
But wouldn't mt_adddiff be like denoised + ssD (the whole ssD or ssDD)?
#EDIT: I guess I really didn't know how mt_adddiff works, I'll do some tests later.
Dogway
15th October 2021, 21:24
You want to add the pure difference. Centering the difference is to circumvent the unsigned nature of AviSynth+ int bitdepths.
mt_addiff() is actually "y range_half - x +".
tormento
16th October 2021, 11:53
No I won't.
Can I make a request?
Something similar to RGBAdapt but more consistent and MT friendly, plus it still needs stacked to do HBD.
I have tried AutoAdjust too but it's just too slow to be useful on HD or 4K.
You made so many useful scripts that the only two things I can see missing is a motion stabilizer (a really working one, even for micromovements of film on the spool) and levels/gamma/RGB optimizer.
Those two can help a lot with old movies, directly ported to BD and even 4K with no restoration at all.
Dogway
16th October 2021, 19:01
Did you try RGBAdapt or Gammac? The core principle is easy, the hard part is to work on scene bounds and temporally soften the effect to avoid chroma flicker. This has been done in plugins, I don't know of an easy way to do it at script level.
I usually apply a hue correction but at clip level so I avoid all those issues. Normally at two points, white level and grey level. Import the curve from Photoshop apply to RGB, convert to YUV and mergechroma with that.
tormento
16th October 2021, 23:11
Did you try RGBAdapt or Gammac?
Yes and yes. RGBAdapt is a script and I hope it could be improved, as it presents many limitations.
I usually apply a hue correction but at clip level so I avoid all those issues. Normally at two points, white level and grey level. Import the curve from Photoshop apply to RGB, convert to YUV and mergechroma with that.
Sorry, as I told, I am a noob with color spaces and conversion. Any available tutorial to the detailed steps? :)
Boulder
17th October 2021, 14:17
I've been getting Access Violation errors with SPresso. Extools.avsi line 3670, smdegrain.avsi line 622 and spresso.avsi line 38 are mentioned in the dialog box.
This is the script I can use to reproduce it, it usually starts occurring if I have to refresh the script often in VDub2 while tuning the settings. Closing the application and reopening it seems to help.
DGSource("columbo_s03e01.dgi")
TFM(slow=2).TDecimate(nt=1)
SPresso(bias=20, rgmodec=4, limit=0.65)
SelectEvery(400, 1)
Dogway
17th October 2021, 14:51
Interesting, looks like an avisynth bug. It's in the "smart" algo of ex_median(). Investigating. Read here (https://forum.doom9.org/showthread.php?p=1955161#post1955161).
EDIT: @tormento, look here (https://emalm.com/?v=l_irt)for a simple color correction method, You can do 2 points, 3, 4, etc. Do over things you know should be neutral (opening, credits...). Then export as a .cube file.
Dogway
18th October 2021, 16:14
@Boulder: Did it work before, in previous versions of test AviSynth+ ? Since what version does it happen? Looks like an obscure memory bug.
Boulder
18th October 2021, 18:34
@Boulder: Did it work before, in previous versions of test AviSynth+ ? Since what version does it happen? Looks like an obscure memory bug.
I've only started testing SPresso recently, so all tests have been done with test14. I actually forgot that there's more recent ones too, I guess I could try testing with the latest one once my current encode finishes.
Boulder
18th October 2021, 19:02
Looks like test20 works without issues, I tried refreshing and jumping around the video a lot but it didn't trigger anything. I'm good with that :)
Dogway
18th October 2021, 19:40
Ok, I was in test 20 and got the issue initially (although not today), so the bug traces back to at least test 14.
EDIT: Updated most EX/MIX mods, mainly maintenance rebasing to latest ExTools and ResizersPack.
Boulder
19th October 2021, 05:03
Ok, I was in test 20 and got the issue initially (although not today), so the bug traces back to at least test 14.
EDIT: Updated most EX/MIX mods, mainly maintenance rebasing to latest ExTools and ResizersPack.
I got it now with test20 as well, if it's a memory bug, no wonder it is quite random.
Dogway
19th October 2021, 11:35
I will update it with a workaround until it is fixed (if it gets fixed at all) since it is so critical (used in minblur) so for the time being you can edit the "smart" algo with an explicit var:
Where it says "E^ D^ H^" replace it with "E^ D^ H^ A^ A" and the bug shouldn't appear more.
tormento
19th October 2021, 23:14
@tormento
I was playing with lfr and contrasharpening.
The details recovered with lfr are terrific when compared to contrasharpening. How are them different and has contrasharpening any reason to exist anymore?
Dogway
20th October 2021, 00:04
The lowpass recovery has an issue, it recovers everything under the cutoff (not exactly but more or less), so it's as if you didn't denoise low frequencies at all, this can be problematic for very grainy sources. That's why that's another reason to run two consecutive calls, the later cleaning up the remnant low frequency noise.
Another thing is that for LFR I'm comparing the behaviour of filtering twice (the original and the lowpassed). Maybe this is not necessary at all and can do as I did with MDegrain, simply compare the lowpassed original versus the lowpassed denoised. This would greatly improve performance.
Also there might be better filters for lowpassing, bessel, butterworth, etc. There's room for improvement.
ex_contrasharpening() doesn't recover anything, it's just acutance. I like to think in terms of LFR for low freq, and contra for high freq, so they are not mutually exclusive.
tormento
20th October 2021, 00:39
Another thing is that for LFR I'm comparing the behaviour of filtering twice (the original and the lowpassed).
Any example to understand the behaviour is welcome. Please keep us informed!
LFR for low freq, and contra for high freq
So, wouldn't be possible to set a integer parameter for contra and call it something like hfr?
MysteryX
21st October 2021, 16:46
At first I get confused or turned-off when I see too many dependencies like Dogway where you need the whole bundle just to use a function.
Then I'm thinking. What you're developing is a framework kind of like jQuery or TypeScript; that allow us to write modern full-featured JavaScript on the same-old JavaScript. That gets useful when it's well-documented and standardized. It gets a pain when you need the whole framework for a few functions, and another framework for other features, and the libraries conflict with each other.
It would particularly be useful if it would provide more unified syntax/features between Avisynth and VapourSynth. Like I see you use CombinePlanes (ShufflePlanes) extensively in Avisynth.
Dogway
21st October 2021, 19:17
The dependency amount is something relative as I try to reduce dependencies to the max, for example yesterday I was debating whether to use nmod() in SMDegrain or not, and decided not to, because it requires ResizersPack and SMDegrain is a widely used filter, even when I think ResizersPack should be in everyone's toolbox.
For example, nmod() tries to standardize the mod functions everyone includes in their scripts, m4(), m8(), m4_sh(), modx(). The at-least-16 (x<16?16:...) that many include is wrong because the mod(n) can output a value below 16. PadBorders() tries to replace Padding(), Addborders(), PadMirror(), sh_Padding(), _Padding(), BorderMirror(), _MirrorBorders(), etc.
I'm constantly trying to reduce dependencies so I included ex_vinverse() in QTGMC, ex_retinex, ex_minblur, ex_luma_rebuild in SMDegrain, and so on, following the concept of Packs. ex_median() replaces a handful of plugins as well. I try to shift the dependencies from plugins or individual scripts to Packs, and then to 'mode' arguments. Some people have been doing this already like manyPlus, plugins_JPSDR, Utils-r4x, jdl_xxx, Zs_RF_Shared, RT_Stats, avsresize, fmtconv.
Boulder
22nd October 2021, 10:50
Avisynth's test21 build probably broke some similarity metrics. I just ran ex_makediff and I can see the difference with aug=true, but the metric values for PlaneSSIM, PlaneGMSD and FrameMDSI are 1.0, 0.0 and 0.0 respectively. I'm not entirely sure but I think I did check those also with test20 earlier and didn't notice anything.
pinterf
22nd October 2021, 13:34
Avisynth's test21 build probably broke some similarity metrics. I just ran ex_makediff and I can see the difference with aug=true, but the metric values for PlaneSSIM, PlaneGMSD and FrameMDSI are 1.0, 0.0 and 0.0 respectively. I'm not entirely sure but I think I did check those also with test20 earlier and didn't notice anything.
Try please with test22, there was a glitch with some property handling script functions.
Dogway
22nd October 2021, 15:09
@Boulder: I'm updating SimilarityMetrics and ex_makediff() today, big refactor for the later. Give me some minutes.
Dogway
22nd October 2021, 19:15
Updated ExTools and SimilarityMetrics.
Added mode arg to ex_blur, it accepts "binomial", "gaussian" and now "butterworth", this one is a mix between mean and gaussian controlled by a bias arg included as 'n', still need to default it to 6dB/oct slope.
ex_median() now allows 'thres' for all modes.
Now ex_makediff(aug=true) shows more metrics, check below (Requires Butteraugli plugin, and TransformsPack), and added a 'show' argument to decide to what clip add the metric frameprops. I didn't include VMAF because it doesn't write frameprops, I want to add other modes like 4-SSIM, MS-SSIM, DEitp, VQM, MOVIE, BRISQUE, etc.
https://i.imgur.com/xB2LVIs.png
I've been parametrizing the blur in SMDegrain to allow frequency inputs for the LFR argument. I think it's correct now but want to do a few more checks.
tormento
22nd October 2021, 19:40
I've been parametrizing the blur in SMDegrain to allow frequency inputs for the LFR argument. I think it's correct now but want to do a few more checks.
I find lfr really great. How does it work now?
Dogway
23rd October 2021, 02:56
I haven't updated it yet but since the frequency sample rate depends on the resolution, instead of an absolute frequency cutoff it's now relative to the resolution.
For example by setting LFR=300, you are setting the cutoff to 300Hz from the frequency sample rate, for a 1080p clip setting the value to 1920 means no lowpass/blur. Defaults account for input sample rate. It's designed so at the cutoff the attenuation is 3dB. There's another filter I designed today the "butterworth" which typically shows a better lowpass shape, default being a bandpass + lowpass with a 6dB/oct decay/slope. I still have to find how to design this decay and see if it works as good for images as it does for audio.
There's also the "brickwall" filter, it's called the "ideal filter" but it doesn't seem to work fine over images, it should correspond to a "mean" blur kernel. Haven't had the time to test each.
Boulder
23rd October 2021, 09:24
I've now updated a number of packs, and SPresso gives me a new error message. "Expr: Not enough elements on stack to perform operation", points to extools.avsi, line 3801.
tormento
23rd October 2021, 13:20
EDIT: ignore following... Windows 11 latest insider decided to f*ck up the Nvidia Driver. Reinstalled the latest DCH and now it is working.
I haven't updated it
Latest everything.
Script Error
KNLMeansCL: fatal error!
(clCreateContext: OCL_UTILS_UNKNOWN_ERROR)
(D:/Programmi/Media/AviSynth+/plugins64/SMDegrain-3.3.4d~Dogway.avsi, line 892)
(D:/Programmi/Media/AviSynth+/plugins64/SMDegrain-3.3.4d~Dogway.avsi, line 915)
(D:/Programmi/Media/AviSynth+/plugins64/SMDegrain-3.3.4d~Dogway.avsi, line 197)
tormento
23rd October 2021, 13:44
Another one arose:
SetMemoryMax()
SetFilterMTMode("DEFAULT_MT_MODE", 2)
LoadPlugin("D:\Eseguibili\Media\DGDecNV\DGDecodeNV.dll")
DGSource("F:\In\2_24 007 21 - Casino Royale\21casino.dgi",ct=144,cb=144,cl=0,cr=0)
CompTest24(1)
ConvertBits(16)
SMDegrain (tr=4, thSAD=400, refinemotion=true, contrasharp=false, PreFilter=4, plane=4, chroma=true, lfr=1)
fmtc_bitdepth (bits=8,dmode=8)
Script Error
Script error: There is no function named 'nmod'.
(D:/Programmi/Media/AviSynth+/plugins64/ExTools-6.2_22~Dogway.avsi, line 1330)
(D:/Programmi/Media/AviSynth+/plugins64/SMDegrain-3.3.4d~Dogway.avsi, line 378)
(D:/Programmi/Media/AviSynth+/plugins64/SMDegrain-3.3.4d~Dogway.avsi, line 380)
(D:/Programmi/Media/AviSynth+/plugins64/SMDegrain-3.3.4d~Dogway.avsi, line 380)
(D:/Programmi/Media/AviSynth+/plugins64/SMDegrain-3.3.4d~Dogway.avsi, line 385)
(D:/Programmi/Media/AviSynth+/plugins64/SMDegrain-3.3.4d~Dogway.avsi, line 560)
It works on Ex_tools 6.1.
Dogway
23rd October 2021, 18:20
Yes, nmod() is in ResizersPack, it replaces sh_m4() from Zs_RF_Shared. You can copy/paste it anywhere else.
I've now updated a number of packs, and SPresso gives me a new error message. "Expr: Not enough elements on stack to perform operation", points to extools.avsi, line 3801.
Shit sorry, a stupid typo. Updated.
Boulder
23rd October 2021, 18:52
Shit sorry, a stupid typo. Updated.
Thanks, it works now :)
One more I found out, CASm with a 1080p source cropped by 210 pixels off left and 272 pixels off right, I get an error "CombinePlanes: source and target plane dimensions are different".
Dogway
23rd October 2021, 19:13
Fixed now in ExTools, keep'em coming!! : D
tormento
23rd October 2021, 19:48
it replaces sh_m4() from Zs_RF_Shared
So I can get rid of ZS?
Dogway
23rd October 2021, 20:03
It's still required for sh_GetUserGlobalIMTint() but I will try to remove that dependency in SMDegrain for the next version.
EDIT: Does anybody have a build of KPassFilterCL? I need it to double check some frequency related functions. I have GCC but I can't build avs plugins with this compiler.
Visual examples for lowpass filters:
Mean (brickwall)
https://i.imgur.com/ST86ZY1l.png
Butterworth (with n: 50, 10 and 2)
https://i.imgur.com/g8HaoZHl.png
https://i.imgur.com/XShiPu1l.png
https://i.imgur.com/iMATKqfl.png
Gaussian
https://i.imgur.com/wP1CjE1l.png
Butterworth 'n' setting animated from 300 to 0:
https://i.imgur.com/huq9JF5.gif
poisondeathray
23rd October 2021, 21:21
EDIT: Does anybody have a build of KPassFilterCL? I need it to double check some frequency related functions. I have GCC but I can't build avs plugins with this compiler.
There is a link mirror on the top right corner of this page to v0.1.0
http://avisynth.nl/index.php/KPassFilterCL
tormento
24th October 2021, 11:01
I have GCC but I can't build avs plugins with this compiler.
You can easily get MSVC or Intel really easily. :D
Dogway
24th October 2021, 12:09
I don't have space in C: and 4Gb (at the very least) for building once every half a year...
I tested the plugin but didn't work for me... It would really be great to have vcmohan F1QLimit in avisynth to preview frequency domain in 1D.
By the way I built a sharpener ex_sharp() that by chance matched unsharp(), but I added a twist by also adding 20% of the sharpness from a lower frequency cutoff as reinforcement. It's frequency based so the varY option of unsharp() is now Fc and you can use 1920 for pixel accuracy, 1920*2 for subpixel accuracy and 1920*0.5, or simply 960 to sharpen low frequency. I also finished designing the butterworth slope, first order is actually the 6dB/oct slope, very gaussian like.
Dogway
5th November 2021, 09:17
Just updated SMDegrain with a battery of changes. You can read the log in the commit description (https://github.com/Dogway/Avisynth-Scripts/commit/3ea0e66d1d0f43f2e05d1dab0a1b9094248b8f4e).
To expand, I repurposed the LFR argument so now it describes frequency. The higher the more higher frequencies you restore, notice the frequency is bound to clip width (typically) resolution so 300 is not the same for a 1080p clip than for a 2160p one. By default it's to set to 300Hz for 1080p, 600Hz for 1080p and so on.
I reworked the LFR code in non-MDegrain modes to use the one in MDegrain which is sensibly faster.
I included a new setting called DCTFlicker, this is a problem I described some weeks ago which is low frequency noise so I wanted to do something with it. It happened I stumbled over this (https://forum.doom9.org/showthread.php?p=1073349#post1073349) Didée's post to tackle this very same issue. For that I had to port FluxSmoothT to Expr() which was a pending task in order to expand temporal radius and include a soft threshold. FluxSmoothT is nice because it's the minimum change of a temporal average and a temporal median, along with the soft threshold it makes for a good low frequency calmer. It's not perfect, but there's no perfect solution either (reference (https://forum.doom9.org/showthread.php?p=1471841#post1471841)). That's why a multistep solution although slower might be desired. Check below with the great sample clip from tormento.
raw
http://i.imgur.com/Gr8x0a3m.png (https://i.imgur.com/Gr8x0a3.png)
DNR..........................................................................DNR+LFR
http://i.imgur.com/LPOlEfkm.png (https://i.imgur.com/LPOlEfk.png)............http://i.imgur.com/GEsqelEm.png (https://i.imgur.com/GEsqelE.png)
DNR+LFR+DCTR........................................................DNR+LFR+DCTR (tailored: multi-step)
http://i.imgur.com/t65diLpm.png (https://i.imgur.com/t65diLp.png)............http://i.imgur.com/kY4rARZm.png (https://i.imgur.com/kY4rARZ.png)
Call for the multi-step solution
pre=smdegrain(tr=1,mode="temporalsoften",blksize=32,thSAD=900,LFR=400,prefilter=5,DCTFlicker=true,contrasharp=false,refinemotion=true)
smdegrain(tr=2,mode="MDegrain",blksize=32,prefilter=pre,thSAD=400,LFR=false,contrasharp=true,refinemotion=true)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.