View Full Version : SMDegrain equivalent of MDegrain2


Atlantis
19th October 2023, 13:59
What would be the SMDegrain equivalent of this?

super = MSuper()

b1 = MAnalyse(super, isb = true, delta = 1, overlap=4)
b2 = MAnalyse(super, isb = true, delta = 2, overlap=4)
f1 = MAnalyse(super, isb = false, delta = 1, overlap=4)
f2 = MAnalyse(super, isb = false, delta = 2, overlap=4)

MDegrain2(super, b1,f1,b2,f2)

Atlantis
19th October 2023, 14:03
And where is the tr of SMDegrain in the MDegrain2 chain?

DTL
19th October 2023, 15:22
tr for MDegrain2 is fixed to 2 and not provided as filter param (internally fixed to 2). Also MDegrainX filters accepts MVs clips in single MVs per frame format (MAnalyse(multi=false)) and as separate clips for each time-step.

Atlantis
19th October 2023, 16:50
If tr for MDegrain2 is fixed, how SMDegrain is using it? Isn't SMDegrain just a function that uses MDegrain2?

kedautinh12
19th October 2023, 17:15
Something like this:

pre=MDegrain2(super, b1,f1,b2,f2)
SMDegrain(prefilter=pre)

Atlantis
19th October 2023, 17:26
How it knows what is b1,f1,b2,f2 ?!

kedautinh12
19th October 2023, 17:44
How it knows what is b1,f1,b2,f2 ?!

My script is example, you need add them above like post 1

Atlantis
19th October 2023, 17:55
If I have to add all the lines there is no point to use SMDegrain, I just use the original.

My question is if it is possible to write that in one line with SMDegrain.

anton_foy
21st October 2023, 11:41
Smdegrain(tr=2,overlap=4,prefilter=last,UHDhalf=false)

Atlantis
21st October 2023, 16:15
Thank you.

I don't find any UHDhalf parameter in the documentation.

anton_foy
21st October 2023, 17:58
Thank you.

I don't find any UHDhalf parameter in the documentation.

Yes it is maybe not mentioned in the docu but search in the script.

kedautinh12
22nd October 2023, 01:45
Document here
https://github.com/Dogway/Avisynth-Scripts/tree/master/SMDegrain

Atlantis
29th October 2023, 20:40
I recently discovered SMDegrain and I have to say how impressed I'm with it. For years I was using a combination of RemoveGrain and FFT3D.
Then I had to use motion compensation and doing a combination of different settings. It took many lines.

Now I'm using SMDegrain in just one line and playing with different parameters, I can achieve a simple and good result. It's easy
and better in motion movement than many other filters I have tried considering speed vs quality.

My goal has been to keep 4K HDR files under 9Mb/s and this thing does it easily. I re-tried my 2 difficult reference grainy movies and it works.
Now I'm convinced it will work for everything!

Atlantis
31st October 2023, 11:23
I have a grainy source and the manual says very grainy sources might require spatio-temporal filters (presets 4, 6 and 8).
BM3D (Block Matching 3D) > NLMeans > SAD Block Matching (MVTools) > Frequency Filters (FFT/DFT..) > Bilateral > Median > simple linear filters (Gaussian Filter, Wiener Filter...)

-1 = off (Default)
0 = light controlled gauss blur
1 = mild median/gauss blur
2 = strong median/gauss blur
3 = very strong median/gauss blur (IQMV -Variable Inter Quartile Median- filter)
4 = spatio-temporal median/gauss filter (IQMST)
5 = DFTTest (spatial)
6 = KNLmeansCL (spatio-temporal non-local means OpenCL GPU filter)*
7 = DGDenoise (spatial non-local means Cuda GPU filter)*
8 = BM3D (temporal BM3D Cuda GPU filter)*

I can't use 8, I use avisynth, I tried 4 and 6 and they give the smallest size, cleanest results. 6 is indeed better than 4. 4 gives smaller output put some warping going in some scenes.

Now I want to write the prefilter 6 by hand to better understand it but it does not give me the same results, I have gone as extreme as this.

pre=KNLMeansCL(D=1, A=6, h=32, device_type="auto")
SMDegrain(tr=2, thSAD=300, prefilter=pre)

But it does not match this
SMDegrain(tr=2, thSAD=300, prefilter=6)

Any idea what KNLmeansCL settings the prefilter 6 uses?

kedautinh12
31st October 2023, 12:14
You need use warp of knlmeanscl is ex_knlmeans but it's need more than one line to add
https://github.com/Dogway/Avisynth-Scripts/blob/24432b3980208582f7175f74107a1415b6175b68/SMDegrain/SMDegrain.avsi#L325C39-L325C39

Atlantis
31st October 2023, 15:20
Thank you so much. It also shows what all the other prefilters do. I'm going to stick with prefilter 6 in extreme cases. It's easy and good enough for me in term of denoising and quality.

My reference for hard noisy films are Saving Private Ryan and Blade Runner (1982), the 4K HDR versions I find them very difficult to encode. Maybe their transfer is bad, red colors in the sky and other stuff.

Any other movies harder than these 2?

kedautinh12
31st October 2023, 16:20
@FranceBB will help you about color trans :D

SaurusX
31st October 2023, 16:21
Any other movies harder than these 2?
Have you tried 300?

Atlantis
31st October 2023, 17:03
No but is it worse? What is this?!

https://i.imgur.com/8ckkvHr.jpeg

tormento
31st October 2023, 17:33
Sometimes noise is a bad enemy, mostly when the movie is resized or it's encoded with wrong quantization, leading to artifacts.

In the first case, downscale, denoise, upscale. In the second, there isn't too much that you can do.

anton_foy
31st October 2023, 17:44
Try CCD from Dogway's deblock pack or a higher thsadC in mdegrain or both.

Edit. and try this to:
VsCnr2("ooo",100,16,191,100,255,32,255,sceneChroma=true)

Atlantis
31st October 2023, 22:09
I'm not sure what that means. Need more details. To where I should add that?

anton_foy
31st October 2023, 22:24
I'm not sure what that means. Need more details. To where I should add that?

Just google vscnr2 avisynth and you find the plugin.

VsCnr2("ooo",100,16,191,100,255,32,255,sceneChroma=true)
Smdegrain(tr=3...rest of your code)

Or

Ccd(16) #can try up to 20 or maybe more
Smdegrain(blablabla)

Edit2: in Smdegrain you put thsadC=500 or so if your thsad=300 and see if it makes any difference.