Log in

View Full Version : Dogway's Filters Packs


Pages : 1 2 3 [4] 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62

Arx1meD
1st August 2021, 15:10
I also want to post a list of all the median filters I could find. They happen to be much more than I thought, so I'm not including them all, although people can help out if interested to make a good library, despite some of them protected under a paywall or not possible with Expr expressions (recursions, etc)
From all of them the ones I'm interested most are: IDBA, TSND, RAA, ADKI, and AUTMF.

Convolution algorithms:
# RAA - Removal of salt and pepper an Adaptive Approach


There is a ModPlus plugin and it includes a SaltPepper filter. It can be found here (also source code) - ModPlus (http://avisynth.nl/index.php/ModPlus).
I don’t know how useful it will be for you.

kedautinh12
1st August 2021, 15:30
ManyPlus have ModPlus with new updated
http://www.avisynth.nl/users/vcmohan/manyPlus/manyPlus.html

Dogway
2nd August 2021, 11:24
Finished the port of Adaptive Sharpen (https://github.com/Dogway/Avisynth-Scripts/blob/master/EX%20mods/Adaptive_Sharpen.avsi) (phew!)

It's very slow though, I thought that processing in 8-bit would make it somewhat production ready speed, but no, it's slower. Maybe when/if we get LUT calculations in Expr though.
There are already some optimization tricks to make it faster so the next step would only be to port the optimized HLSL from igv (https://gist.github.com/igv/8a77e4eb8276753b54bb94c1c50c317e).
For the time being use it in 8 or 32-bit. Haven't tested in other depths.
Eventually I want to create a sharpeners pack with FineSharp, SeeSaw, etc and try to find a good candidate for Contrasharp replacement in SMDegrain.


I checked the SaltPepper filter and depending on mode it matches "undot" or "median". There's also the feedback argument but I can check it out later with the feedback plugin from wonkey_monkey.

kedautinh12
2nd August 2021, 11:35
Real.Finder was added feedback to stab3
https://github.com/realfinder/AVS-Stuff/blob/c6b4a92589842c622c03c7235bcb1d9261e9ba3b/avs%202.5%20and%20up/StabilizationToolsPack.avsi#L423

Dogway
4th August 2021, 12:11
Updated Adaptive Sharpen to fix the last bugs and last optimizations. It runs now at 11.40fps on my system with Prefetch(8). I will now try to port CAS, SeeSaw and other sharpeners for a Sharpeners Pack.
If any it made me appreciate more LSFmod and its quality, specially when paired with supersampling.

Also updated SMDegrain with latest changes, that is, the contrasharpening function was fixed to either use spatial or temporal limiting. Also some values for HD were tuned. Should be faster now.
Besides that BM3D prefiltering has been added. Resizing down kernel was changed to bilinear for UHD, and a threads var was fixed when empty.

kedautinh12
4th August 2021, 12:16
Thanks, but CAS have avisynth filter, why you still want port it??

Dogway
4th August 2021, 12:23
Yes, that's true, forgot about it. If it's too complex I pass otherwise I may add it to the library.

kedautinh12
4th August 2021, 13:06
Seesaw have avisynth script
https://github.com/realfinder/AVS-Stuff/blob/Community/avs%202.5%20and%20up/seesaw.avsi

Dogway
4th August 2021, 22:54
I'll update my online tool at some point as it now inserts automatic pixel references (when it can) and also has a variable-ised output option.

wonkey_monkey: Is the variable reference output option included in the tool? It's not showing in any of my browsers, it could come very handy for these long sorting networks.

Julek
5th August 2021, 04:00
I wonder if it would be possible to do something like OpenCV Adaptive Thresholding with Expr(), it would be useful for mask

tormento
5th August 2021, 11:21
contrasharpening function was fixed to either use spatial or temporal limiting.
Which are the best case scenario to choose from spatial or temporal?
Besides that BM3D prefiltering has been added.
Great, I will try it ASAP.

Dogway
5th August 2021, 12:32
Julek: I had a look into Otsu's method a month ago but wondered whether it would be useful at all. Well it uses histogram bins so that's not something I can do in Expr but I just implemented a cheap dynamic thresholding to ex_binarize() will upload soon. If Adaptive Thresholding doesn't use histogram bins it can be possible, I will have a look.

tormento: Currently in SMDegrain contrasharpening is stuck to spatial limiting. Spatial limiting is like the defacto method, I like it over temporal for anime to keep faithful lineart. Temporal could be useful for situations like poor interframe correlation like noisy sources, shaky or very action oriented films. One option would be to switch from one to another automatically depending on sequence content (via motion vectors).

tormento
5th August 2021, 12:56
tormento
Thanks.

I tried the prefilter=5 and it gives me the error:

Script error: There is no function named 'MatchColorFormat'.
(D:/Programmi/Media/AviSynth+/plugins64/SMDegrain-3.2.3d~Dogway.avsi, line 657)
(D:/Programmi/Media/AviSynth+/plugins64/SMDegrain-3.2.3d~Dogway.avsi, line 159)

Would you please explain me better what the trymany option does? I have tried to understand thru MVTools manual but it keeps being of obscure meaning to me.

Dogway
5th August 2021, 13:08
You need Utils-r41 for MatchColorFormat(). I haven't worked on format conversions lately because Transforms Pack is on halt so for the time being I use internal or other scripts.

trymany I don't know it's a remnant from real.finder's mod. There are still a few things I have to look up.

zorr
5th August 2021, 13:22
Trymany is obscure to me as well but my tests indicate (https://forum.doom9.org/showthread.php?p=1945684#post1945684) that trymany=false gives better results. At least on one test case.

Julek
5th August 2021, 14:09
Julek: I had a look into Otsu's method a month ago but wondered whether it would be useful at all. Well it uses histogram bins so that's not something I can do in Expr but I just implemented a cheap dynamic thresholding to ex_binarize() will upload soon. If Adaptive Thresholding doesn't use histogram bins it can be possible, I will have a look.

I think Adaptive is more useful than Otsu's, actually I already use Adaptive in Vapoursynth via numpy, but I believe that a direct implementation via Exp (or std.Convolution in VS) would help the speed.

tormento
5th August 2021, 14:54
You need Utils-r41 for MatchColorFormat().
I guess for floating point format used by BM3D or what else?

Edit: tried and can't run both in StaxRip and in VirtualDub2. StaxRip plainly hangs, Virtualdub2 spits the following:

https://i1.lensdump.com/i/ZM0iTQ.png

My script:

SetMemoryMax()
SetFilterMTMode("DEFAULT_MT_MODE", 2)
LoadPlugin("D:\Eseguibili\Media\DGDecNV\DGDecodeNV.dll")
DGSource("F:\In\1_33 Grosso guaio a Chinatown\grosso.dgi",ct=132,cb=132,cl=0,cr=0)
ConvertBits(16)
SMDegrain (tr=4, thSAD=400, trymany=false, refinemotion=true, contrasharp=false, PreFilter=5, truemotion=true, plane=4, chroma=true)
Prefetch(6)

AVSMeter64 output:

AVSMeter 3.0.8.0 (x64), (c) Groucho2004, 2012-2021
AviSynth+ 3.7.1 (r3431, master, x86_64) (3.7.1.0)

Exception 0xC000001D [STATUS_ILLEGAL_INSTRUCTION]
Module: C:\WINDOWS\System32\KERNELBASE.dll
Address: 0x00007FFB8450467C

No problems whatsoever with prefilter=4.

DJATOM
5th August 2021, 19:39
Illegal instruction mostly means that your CPU lacks certain instruction (AVX2 on sandy/ivy bridge?) support.

tormento
5th August 2021, 20:25
Illegal instruction mostly means that your CPU lacks certain instruction (AVX2 on sandy/ivy bridge?) support.
Yep, I confirm it's a BM3D test2 issue. With test1 I have no problems at all with a simple test script.

Dogway
5th August 2021, 21:03
Sorry I took the day off. Did you include both dll in the plugin folder, both are needed I think?

About MatchColorFormat() it just converts the clip back to input format since BM3D needs YUV444 (for chroma processing). Ideally I would use a personal function from Transforms Pack, but currently it's in WIP state.

wonkey_monkey
5th August 2021, 21:31
wonkey_monkey: Is the variable reference output option included in the tool? It's not showing in any of my browsers, it could come very handy for these long sorting networks.

Now updated. It only inserts pixel references for 3x3 or 5x5 networks, with or without the central pixel, so any network with 8, 9, 24, or 25 inputs.

Dogway
5th August 2021, 21:59
Thanks a lot, super time saver, I was wasting more than half an hour each time. I needed it to update "medianST" so a 3x3x3, that means 27 inputs, but you can also clip to closest neighbour (26 inputs) and save in this case about 9 lines of min/max.

Something was a bit wrong though (picking output 12 and 13 for 26 inputs 13 layers):
K M dup1 dup1 min K^ max M^
swap1 M P min M^
K N max N^
M N dup1 dup1 min M^ max N^

M N
There's nothing to swap, I replaced with:
K M dup1 dup1 min K^ max M^
M P min M^
K N max N^
M N dup1 dup1 max swap2 min

x swap2 clip

kedautinh12
5th August 2021, 23:32
Yep, I confirm it's a BM3D test2 issue. With test1 I have no problems at all with a simple test script.

Cause BM3D_VAggregate() move from BM3DCUDA to BM3DCPU in test2
https://github.com/Dogway/Avisynth-Scripts/blob/1c3ef4f642d71ce9f957192e2a9e9d32e9874a3c/SMDegrain%20v.3.2.3d/SMDegrain%20v3.2.3d.avsi#L653

wonkey_monkey
6th August 2021, 00:18
Something was a bit wrong though (picking output 12 and 13 for 26 inputs 13 layers)

I think I've fixed it.

tormento
6th August 2021, 10:24
Sorry I took the day off. Did you include both dll in the plugin folder, both are needed I think?
Yep, it was an AVX2 issue.

Please notice that utils-r41 and ZS_shared have duplicate functions in common. I hope it won't give secondary issues.

kedautinh12
6th August 2021, 10:57
Just delete function duplicate from utils-r41 or ZS_shared

tormento
6th August 2021, 13:36
Sorry I took the day off.
Tested and working with test3 of BM3D.

Now I just have to understand which is better at prefiltering between BM3D and KNLMeansCL, as speeds are comparable when encoding.

Would it be difficult to introduce a function in SMDegrain to show only the differences (as pixels) between the original clip and the resulting one?

Dogway
6th August 2021, 14:38
As I could observe BM3D is better at motion estimation and probably also at denoising.

There's a function in ExTools that can be used for comparisons:

ex_makediff(a, aug=true, UV=128)

kedautinh12
6th August 2021, 15:24
Yes, BM3D in my opinion is best denoiser

poisondeathray
7th August 2021, 04:39
Thanks for the toys Dogway,

Can you check GrainFactory3mod - it appears to do nothing for me, even when using high values for g1str, g2str, g3str and tried different pixel formats. GrainFactory3 ok

colorbars(pixel_type="YV12")
GrainFactory3mod
#GrainFactory3

Dogway
7th August 2021, 09:43
poisondeathray: I will have a look. Actually I had plans to replace GrainFactory3mod completely as it shouldn't be that slow. I want to make use of the Addgrain corr args to avoid resizing clip 3 times.

Julek: Do you have an input and output sample? I got some code but I'm not sure what I should target. Also there are adaptive mean/median/gaussian, which one do you need?

gispos
7th August 2021, 18:13
Then please also check ex_contrast, parameter "sat" does not work for me.
Thank you.

Dogway
7th August 2021, 18:26
poisondeathray: I just checked and it's fine here, using your colorbars call and the GrainFactory3mod call from OP. The call is actually "GrainFactory3mod" not "GrainFactory3" (fixed in OP). Might you be missing a dependency?

gispos: I tested and yes, ex_contrast() defaults to UV=1 for YUV sources. I fixed it by enabling UV=3 if sat is defined, will upload for next update.
UV = Default(UV, Defined(sat) || rgb ? 3 : 1)

In any case the saturation of ex_contrast() isn't meant as a full fledged saturation function, that's the task of ex_vibrance() but I admit it's a bit abandoned lately. Among other things I also need to make it color space aware. ex_contrast() saturation is a simple lerp, more to keep along luma contrast.

poisondeathray
7th August 2021, 18:45
poisondeathray: I just checked and it's fine here, using your colorbars call and the GrainFactory3mod call from OP. The call is actually "GrainFactory3mod" not "GrainFactory3" (fixed in OP). Might you be missing a dependency?


Yes, GrainFactory3mod . I mentioned GrainFactory3 because that separate older (non ex) function works

If I copy/paste the function into the script and rename it something like GrainFactory3mod2 , it still returns original clip, so it's not autoloading some other function with the same name

Yes all dependencies are met on the list, with same or newer versions

gispos
7th August 2021, 19:29
gispos: I tested and yes, ex_contrast() defaults to UV=1 for YUV sources. I fixed it by enabling UV=3 if sat is defined, will upload for next update.

With UV=3 it works, I hadn't even looked at UV.

Dogway
7th August 2021, 21:09
poisondeathray: Maybe you have a function (name) duplication? Another thing to care about avs+ version. Also are you using MIX mod? Both should work though but I always use MIX mods myself mostly. In any case download again from the repo (just updated) and check for dependencies.

ExTools updated to v4.6.
-ex_blur() whole refactor. Now it uses true gaussian coefficients and float radius. For matching removegrain(12), blur(1) use ex_boxblur(mode="weighted")
-ex_smartblur() bugfix that prevented the function from working
-ex_binarize() dynamic mode
-ex_median() optimize "medianST" mode

EX/MIX mods
-Rebased to latest ExTools
-Reverted removegrain(19) to removegrain(20)

I also tried to port removegrainHD smartmedian modes but failed to it, spent whole day yesterday. Might add my attempts if anyone is interested to give it a stab.

poisondeathray
7th August 2021, 21:38
poisondeathray: Maybe you have a function (name) duplication? Another thing to care about avs+ version. Also are you using MIX mod? Both should work though but I always use MIX mods myself mostly. In any case download again from the repo (just updated) and check for dependencies.


AVS+ 3.7.1 r3431

Yes I just re-downloaded and check prerequisites. Not sure what's going on

Neither GrainFactory3mod EX or MIX mods work for me. I renamed the functions to call them separately. I even removed autoloading GrainFactory3mod.avsi versions and manually copy/pasted function into script . I double check that function is missing - ie. error message when GrainFactory3Mod is called

eg. rename function

function GrainFactory3mod_ex(clip...

function GrainFactory3mod_mx(clip...

They return the original clip for me

The original GrainFactory3mod from 2020.04.06 (I think real_finder) works ok

Dogway
7th August 2021, 22:01
I don't know, there's nothing special on my mod. In these situations I would work my way up within the function to check up where it starts to fail. Output process clip in different stages to see what's failing. Usually it tends to be a dumb oversight. Use simple script, empty the plugin folder, etc.

If you can please try replacing the last line:
use_ALMask ? mt_merge(result... }
With just
result }

poisondeathray
7th August 2021, 22:15
I don't know, there's nothing special on my mod. In these situations I would work my way up within the function to check up where it starts to fail. Output process clip in different stages to see what's failing. Usually it tends to be a dumb oversight. Use simple script, empty the plugin folder, etc.

If you can please try replacing the last line:
use_ALMask ? mt_merge(result... }
With just
result }

Same thing; :(

It's ok - Don't worry about it, the original mod still works ok for me

Julek
8th August 2021, 16:11
Julek: Do you have an input and output sample? I got some code but I'm not sure what I should target. Also there are adaptive mean/median/gaussian, which one do you need?

Here is an example of mean and gaussian with blockSize=15 and C=3, both applied to luma after a prefilter.
I usually use the mean option more.
Link (https://drive.google.com/drive/folders/18wjz_kEQLvnfmdzoNsXhOFCeR2vLXdn7)

Dogway
10th August 2021, 21:23
ExTools updated to v4.7.
-Guidelines for common operations with ex_xxpand(): Opening, closing, smooth, outline, inline, gradient, top hat, black hat.
-ex_hitormiss(). New function for advanced binary mask operations. Modes: Thin, thicken, prune, pruneS, boundary, convexhull, convexhull45, corner, cornerS, skeleton, SKIZ, end and junction. I may add more in the future.

EX/MIX mods
-Minor cosmetic stealth updates

Dogway
10th August 2021, 21:52
@Julek: I tried to port adaptive threshold, there are many flavours though but couldn't make anyone work, unless my integral image is wrong I think the problem is in the second part, the thresholding.

It involves two passes, since the integral overflows range_max I'm testing in 32-bits first.
# mean of the local sum
str = "x[-2,-2] A^ x[-1,-2] B^ x[0,-2] C^ x[1,-2] D^ x[2,-2] E^
x[-2,-1] F^ x[-1,-1] G^ x[0,-1] H^ x[1,-1] I^ x[2,-1] J^
x[-2,0] K^ x[-1,0] L^ x[0,0] M^ x[1,0] N^ x[2,0] O^
x[-2,1] P^ x[-1,1] Q^ x[0,1] R^ x[1,1] S^ x[2,1] T^
x[-2,2] U^ x[-1,2] V^ x[0,2] X^ x[1,2] Y^ x[2,2] Z^

A B + WA^ WA C + WB^ WB D + WC^ WC E + WD^
A F + WE^ F G WA + + WF^ F G H WB + + + WG^ I WG WC + + WB - WH^ J WH WD + + WC - WI^
K WE + WJ^ K L WF + + WK^ K L M WG + + + WL^ N WL WH + + WG - WM^ O WM WI + + WH - WN^
P WJ + WO^ P Q WK + + WP^ P Q R WL + + + WQ^ S WQ WM + + WL - WR^ T WR WN + + WM - WS^
U WO + WT^ U V WP + + WU^ U V X WQ + + + WV^ Y WV WR + + WQ - WX^ Z WX WS + + WR - WY^

A WA WB WC WD WE WF WG WH WI WJ WK WL WM WN WO WP WQ WR WS WT WU WV WX WY + + + + + + + + + + + + + + + + + + + + + + + + 25 /"

For the second part I'm not sure whether I should pick the box "vertices", or their range, and if the bottom-right corner should be [x,y] or [x+2,y+2]. In any case I tested all possible combinations (5x5 only, not 15x15 yet) but didn't yield any meaningful results.

Some attempts for thresholding:
str = "x y[2,-2] y[-2,2] + y[-2,-2] - y[2,2] - 25 / 1 0.14 - * <= 0 range_max ? "
str = "x y[2,2] y[-2,-2] + y[-2,2] - y[2,-2] - 25 / 0.8 * <= 0 range_max ? " # this seems legit
str = "x y[0,0] y[-2,-2] + y[-2,0] - y[0,-2] - 9 / 1 0.04 - * <= 0 range_max ? "
str = "x[0,0] y[0,0] y[-2,2] + y[-2,0] - y[0,2] - 9 / 1 0.91 - * <= range_max 0 ? "
str = "y[0,0] y[-2,2] + y[-2,0] - y[0,2] - 9 / 0.003 <= range_max 0 ? " # this seems legit
str = "x y[0,0] y[-1,0] y[-1,-1] y[0,-1] y[-2,-2] + + + + y[-2,0] - y[-2,-1] - y[0,-2] - y[-1,-2] - 9 / 1 0.958 - * <= range_max 0 ? "
str = "x[0,0] y[0,0] y[-1,0] y[-1,-1] y[0,-1] y[-2,-2] y[-2,0] y[-2,-1] y[0,-2] y[-1,-2] y[-2,-2] + + + + + + + + + y[-2,0] - y[-2,-1] - y[0,-2] - y[-1,-2] - 9 / 1 0.9939 - * <= range_max 0 ? "
str = "x y y 25 / A@ - B@ 1 B - / 1 - 0.445 * 1 + A * <= 0 range_max ? " # y should be local sum (without mean)
str = "x x y 25 / A@ - dup * sqrt 128 / 1 - 0.34 * 1 + A * <= 0 range_max ? " # Sauvola (y is local mean -no integral-)
str = "x x y 25 / A@ - dup * sqrt 0.5 / 1 - 0.25 * -10 A * exp 2 * 1 + + A * <= 0 range_max ? " # Phansalkar (y is local mean -no integral-)
I might need to research a bit more.



By the way, for Otsu's I found a way to create histogram bins, well a poor man's version of it, simply threshold image for each bin, subtract the previous thres and average each bin get the amount of values.
ScriptClip("""
thr1=ex_binarize(25.5,true)
bin1=thr1.AverageLuma()
thr2=ex_logic(thr1, ex_binarize(51,true), "andn")
bin2=thr2.AverageLuma()
... """)

Dogway
12th August 2021, 12:50
ExTools updated to v4.8.
-ex_binarize() added "otsu" mode.
-ex_median() fixed "adaptive" (for good). Optimized "median5", "medianST", "medianT" and "medianT5"
-ex_repair() optimized "median5"
-ex_bs() upgraded to convert from any bitdepth to any bitdepth, including self bitdepth with different bit scale.
-Updated benchmarks

EX/MIX mods
-Rebase to latest ExTools

SMDegrain updated to v3.2.4d.
-Revert to removegrain(20)
-Fix ex_BM3D() issue when input is 32-bit
-Revert workaround for empty 'threads' issue
-Swapped mt_merge with ex_merge, thus totally removing masktools2 dependency

GradePack updated to v2.6.
-Update ex_bs()
-Optimize ex_blend() "interpolation" mode
-ex_contrast() enable chroma if sat is defined.

Dogway
19th August 2021, 23:24
@Tormento: Couldn't refrain myself so I cobbled this up in a moment. Defaults are not tuned, check against STPresso() to see how it compares, this runs about 100fps, STPresso 3.3fps.

# Spatio-Temporal Thresholded Weighted Median

function STTWM(clip a, int "sthres", int "tthres", int "athres", int "slimit", int "tlimit", int "UV", bool "fulls") {

rgb = isRGB(a)
isy = isy(a)
bi = BitsPerComponent(a)

ths = Default(sthres, 24) # 0 - 100%
tht = Default(tthres, 49) # 0 - 100%
tha = Default(athres, 1) # 0 - 100%
sl = Default(slimit, 5) # 0 - 255
tl = Default(tlimit, 5) # 0 - 255
UV = Default(UV, rgb ? 3 : 1)
fs = Default(fulls, rgb)

ts = ths/100.
tt = tht/100.
ta = (100-tha)/100.
rt = 1 - (ts + tt) * ta

Assert(ths+tht<101, "Spatial and Temporal thresholds cannot sum more than 100%.")
Assert(IsVersionOrGreater(3,7,1), "Update AviSynth+ version to 3.7.1+")

str = Format( \
"x[-1,1] x[1,1] dup1 dup1 min K^ max P^
x[-1,-1] x[1,-1] dup1 dup1 min L^ max O^
x[0,1] dup D^ N^
x[-1,0] dup C^ M^
x[0,-1] dup I^ J^
x[1,0] dup G^ H^
x[0,0] dup dup dup A^ F^
B^ E^
N P dup1 dup1 min N^ max P^
F O dup1 dup1 min F^ max O^
J M dup1 dup1 min J^ max M^
I L dup1 dup1 min I^ max L^
B K dup1 dup1 min B^ max K^
E H dup1 dup1 min E^ max H^
D G dup1 dup1 min D^ max G^
A C dup1 dup1 min A^ max C^
H P dup1 dup1 min H^ max P^
M O dup1 dup1 min M^ max O^
E N dup1 dup1 min E^ max N^
C L dup1 dup1 min C^ max L^
G K dup1 dup1 min G^ max K^
F J dup1 dup1 min F^ max J^
A I dup1 dup1 min A^ max I^
B D dup1 dup1 min B^ max D^
O P min O^
L N dup1 dup1 min L^ max N^
H M dup1 dup1 min H^ max M^
J K dup1 dup1 min J^ max K^
D I dup1 dup1 min D^ max I^
F G dup1 dup1 min F^ max G^
C E dup1 dup1 min C^ max E^
A B max B^
M O min M^
K N min K^
H L dup1 dup1 min H^ max L^
G J dup1 dup1 min G^ max J^
E I dup1 dup1 min E^ max I^
C F max F^
B D max D^
K M min K^
E L dup1 dup1 min E^ max L^
H J dup1 dup1 min H^ max J^
G I dup1 dup1 min G^ max I^
D F max F^
K L min K^
I J min I^
G H max H^
E F max F^
I K min I^
F H max H^
H I dup1 dup1 max swap2 min

x swap2 clip S@

dup dup dup
a dup
z dup
y b dup1 dup1 min swap2 max
swap4 swap1 swap8 dup1 dup1 min swap2 max
swap4 swap1 swap6 dup1 dup1 min swap2 max
swap9 swap1 swap3 dup1 dup1 min swap2 max
swap7 swap1 swap5 dup1 dup1 min swap2 max
swap2 swap1 swap4 dup1 dup1 min swap2 max
swap3 swap1 swap6 dup1 dup1 min swap2 max
swap2 swap1 swap7 dup1 dup1 min swap2 max
swap4 swap1 swap8 dup1 dup1 min swap2 max
swap9 swap1 swap3 min
swap8 swap1 swap5 dup1 dup1 min swap2 max
swap2 swap1 swap4 max
swap2 swap1 swap7 dup1 dup1 min swap2 max
swap7 swap1 swap4 dup1 dup1 min swap2 max
swap2 swap1 swap5 dup1 dup1 min swap2 max
swap6 swap1 swap3 dup1 dup1 min swap2 max
swap2 swap1 swap7 min
swap3 swap1 swap4 dup1 dup1 min swap2 max
swap4 swap1 swap5 dup1 dup1 min swap2 max
swap2 swap1 swap6 max
swap3 swap1 swap2 min
swap3 dup1 dup1 min swap2 max
swap2 swap1 swap4 max
swap2 min
swap2 max

x swap2 clip T@
x - abs {tl} > x T ? {tt} *
S x - abs {sl} > x S ? {ts} * + {ta} * x {rt} * + ")

b = a.selectevery(1,-1)
f = a.selectevery(1,+1)
b2 = a.selectevery(1,-2)
f2 = a.selectevery(1,+2)

isy ? Expr(a, b2, b, f, f2, str, optSingleMode = false ) : \
UV == 1 ? Expr(a, b2, b, f, f2, str, "", optSingleMode = false ) : \
Expr(a, b2, b, f, f2, str, ex_UVexpr(str, UV, bi, rgb, fs), optSingleMode = false, scale_inputs="none")

}

tormento
20th August 2021, 17:26
Couldn't refrain myself so I cobbled this up in a moment.
I suffer OCD too :D
Defaults are not tuned, check against STPresso() to see how it compares, this runs about 100fps, STPresso 3.3fps.
I just want to replicate

Spresso(10,30).STpresso(10,30,4,22,8,49,1,mc=true)

just a bit faster :o

Dogway
23rd August 2021, 10:35
I'm trying to port mt_hysteresis() (slow and seems a little buggy on each F5) to ExTools. I'm still not sure this can be ported even by reading the source code (https://github.com/pinterf/masktools/blob/16bit/masktools/filters/mask/hysteresis/hysteresis.cpp).

I managed to get a very similar output with this, which basically is just a 8-connected hit structuring element. The other blocks in red still don't add or help at all.
function ex_hysteresis(clip a, clip b, int "UV", bool "fulls") {

rgb = isRGB(a)
isy = isy(a)
bi = BitsPerComponent(a)

UV = Default(UV, rgb ? 3 : 1)
fs = Default(fulls, rgb)

str = "x[-1,-1] A^ x[0,-1] B^ x[1,-1] C^
x[-1,0] D^ x[0,0] E^ x[1,0] F^
x[-1,1] G^ x[0,1] H^ x[1,1] I^
y[-1,-1] J^ y[0,-1] K^ y[1,-1] L^
y[-1,0] M^ y[0,0] N^ y[1,0] O^
y[-1,1] P^ y[0,1] Q^ y[1,1] R^

J A min
K B min max
L C min max
M D min max
N E min max
O F min max
P G min max
Q H min max
R I min max X^

J
K max
L max
M max
O max
P max
Q max
R max Z^

J N min
K N min max
L N min max
M N min max
O N min max
P N min max
Q N min max
R N min max Y^

Y 0 != range_max 0 ? "

isy ? Expr(a, b, str, optSingleMode=false) : \
UV == 1 ? Expr(a, b, str, "", optSingleMode=false) : \
Expr(a, b, str, ex_UVexpr(str, UV, bi, rgb, fs), optSingleMode=false) }

Reading the VS docs (http://www.vapoursynth.com/doc/plugins/misc.html) says:
"If we treat the planes of the clips as representing 8-neighbourhood undirected 2D grid graphs, for each of the connected components in clipb, the whole component is copied to the output plane if and only if one of its pixels is also marked in the corresponding plane from clipa."

The X^ block tries to compare every corresponding pixel from clipb to clipa, so if it's a hit, then the Y^ 'connected' block can be evaluated and passed to output clip. I also tested by simply comparing E to Y.

guest
23rd August 2021, 14:01
Hi Dogway,

I just wanted to say that I have been using SMDegrain & ExTools (early builds) successfully in RipBot 264, but with the lasted builds I get an error when running AVSMeter saying there is an issue with Line 446 in SMDegrain.

Are there any other dependancies that need to be used with the later builds ???

I can work around by using older builds of SMDegrain.

Regards

Dogway
23rd August 2021, 22:52
Maybe if you are doing contrasharpening with values you need my mod of LSFmod, or if you are using BM3D prefiltering you might need Utils-r41.
I noticed that in latest LSFmod I changed 'defaults' arg to 'preset', try changing that in line 337 until I update SMDegrain.

guest
24th August 2021, 02:17
Maybe if you are doing contrasharpening with values you need my mod of LSFmod, or if you are using BM3D prefiltering you might need Utils-r41.
I noticed that in latest LSFmod I changed 'defaults' arg to 'preset', try changing that in line 337 until I update SMDegrain.

Thanks for the info, and yes, one of the scripts that throws up the line 446 error IS a contrasharp=30 entry...

Also, I checked the version of LSFmod I was using, and it's was a little old @ v2.187, the latest that I could find was v2.191...doesn't that sound right ??

I just had a look at Line 337 in v2.191, it's blank :eek:

Don't know anything about BM3D....is there a forum or something around ??

I'll do some updates, and let you know :)

OK, back already, and with the very quick response from "videoh" & "kedautinh12", I have some stuff to study :) thanks guys :)

So I now have LSFMod v2.9mx, so I will see what that does.

videoh
24th August 2021, 02:29
Don't know anything about BM3D....is there a forum or something around ?? https://forum.doom9.org/showthread.php?t=183066&highlight=BM3D

Read the whole thread. test3 supports AVS+.