Log in

View Full Version : Blend mode "saturation"


Pages : [1] 2

anton_foy
21st August 2021, 22:27
Hello, is there a way to apply the saturation information from the original clip and apply this onto the processed clip?

In photoshop and GIMP this option is available but not seen it here in the "overlay" function or "ex_blend". Any way to make this possible?
Thanks.

Reel.Deel
22nd August 2021, 00:25
Hello, is there a way to apply the saturation information from the original clip and apply this onto the processed clip?

In photoshop and GIMP this option is available but not seen it here in the "overlay" function or "ex_blend". Any way to make this possible?
Thanks.

I tried adding hsv/hsl modes to my yet-to-be publish-but-finished OverlayPlus script but was not successful.

There are some threads on hsv convertion:

Smooth hue adjustment using Masktools? (https://forum.doom9.org/showthread.php?t=170189)

HSV (de)composing: is it possible in AVISynth? (https://forum.doom9.org/showthread.php?t=161115)

Tweak: HSV - RGB conversion difference between programs (https://forum.doom9.org/showthread.php?t=116949)

Yuv <-> hsv (https://forum.doom9.org/showthread.php?t=162053)

HSLTint (https://github.com/magiblot/HSLTint/blob/master/HSLTint.avsi)

Most notably the first thread has scripts on creating hue/sat masks. Hopefully this thread leads to a possible solution on HSV/L blending modes :).

anton_foy
22nd August 2021, 08:16
Thanks Reel.Deel I will check into those links now. Hope to see the OverlayPlus script working soon :)
Tricky in my mind to figure out how to write this.

I found this: avisynth.nl/index.php/AviSynthGimpLayer
But sadly it is for RGB only and no HBD.

Dogway
22nd August 2021, 09:00
There was a function in MasksPack called SatMask(), it had a 'Recover' mode. I talk in past because I'm currently refactoring it from top to bottom in GradePack. If you wait a few weeks (or days) you might use it. I also have in my mind grading operators like "HUE vs SAT", "HUE vs HUE" and such but that will come later.

EDIT: Refactored (https://github.com/Dogway/Avisynth-Scripts/blob/master/GradePack.avsi#L40)and implemented 'recover' mode.

anton_foy
22nd August 2021, 12:08
There was a function in MasksPack called SatMask(), it had a 'Recover' mode. I talk in past because I'm currently refactoring it from top to bottom in GradePack. If you wait a few weeks (or days) you might use it. I also have in my mind grading operators like "HUE vs SAT", "HUE vs HUE" and such but that will come later.

Great thank you! I gladly wait for it. One of the reasons I want this is due to fft3dfilter's problem with desaturated image after denoising chroma planes. The image gets "dull" after processing compared to the original colors.

kedautinh12
22nd August 2021, 12:50
Great thank you! I gladly wait for it. One of the reasons I want this is due to fft3dfilter's problem with desaturated image after denoising chroma planes. The image gets "dull" after processing compared to the original colors.

fft3dfilter got many banding after denoising. Could you try DFTTest for result don't have banding. Or if you have strong GPU or CPU, could you try KNLMeansCL or BM3D for good result

anton_foy
22nd August 2021, 13:48
fft3dfilter got many banding after denoising. Could you try DFTTest for result don't have banding. Or if you have strong GPU or CPU, could you try KNLMeansCL or BM3D for good result

Thanks, yes DFTTest is actually very good on my material but it is pretty slow on my computer. KNLMeansCL I never got to work with MP_pipeline for some reason. BM3D is also available for Avs+ now? Thought it was for Vapoursynth only. My current graphicscard is very old and slow so even fft3dgpu is slow.

EDIT: okay I found BM3DCuda for avs+. Gotta try it out.

kedautinh12
22nd August 2021, 14:04
BM3D now sp avs+ and have 2 ver are cpu and gpu
https://github.com/WolframRhodium/VapourSynth-BM3DCUDA/issues/7#issuecomment-886173346

kedautinh12
22nd August 2021, 14:05
Try neo_fft3d and neo_dfttest for speed
https://github.com/HomeOfAviSynthPlusEvolution

anton_foy
22nd August 2021, 14:10
Try neo_fft3d and neo_dfttest for speed
https://github.com/HomeOfAviSynthPlusEvolution

Thank you, strangely enough I tried neo_fft3d but it is much slower than the normal fft3dfilter (with ncpu=4). Neo_dfttest is even slower but maybe I have to sacrifice a bit of speed to get my project going.

kedautinh12
22nd August 2021, 14:12
Use fftw3 3.3.8 for speed than old ver
https://forum.doom9.org/showthread.php?t=174470

anton_foy
22nd August 2021, 14:17
Here is my mocked up script, Im no good at scripting so bare with me this is an experiment.
My idea was to mask out the flatter areas of the image using an inverted edge mask and also use the autogain function to bring up contrast to help the mask a bit. Pretty happy with the results and it is fast but probably some downsides that I did not see yet.

vid = last.tweak(sat=2.0)
nr = fft3dfilter(sigma=7, plane=4, ncpu = 4)
dmask = vid.ColorYUV(autogain=true).sharpen(1.0).sharpen(0.6).mt_edge(mode="hprewitt",thy1=0,thy2=65280, paramscale="i16").ex_invert()
ex_merge(vid,nr,dmask, luma=true, UV=3).tweak(sat=0.6)

anton_foy
22nd August 2021, 14:17
Use fftw3 3.3.8 for speed than old ver
https://forum.doom9.org/showthread.php?t=174470

Thanks greatly appreciated!

kedautinh12
22nd August 2021, 14:33
Some test with fftw3 3.3.8
https://forum.doom9.org/showthread.php?p=1911115#post1911115

kedautinh12
22nd August 2021, 14:36
Intel c++ for chip intel
https://software.intel.com/content/www/us/en/develop/articles/intel-compilers-redistributable-libraries-by-version.html

kedautinh12
22nd August 2021, 14:50
Benchmark between fft3dfilter and neo_fft3d
https://forum.doom9.org/showthread.php?p=1911558#post1911558

anton_foy
22nd August 2021, 14:51
Some test with fftw3 3.3.8
https://forum.doom9.org/showthread.php?p=1911115#post1911115

Probably a stupid question but should I use the AVX or AVX2 version for my Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz 3.40 GHz?

kedautinh12
22nd August 2021, 14:57
Your cpu support AVX and before. Don't support AVX2

anton_foy
22nd August 2021, 15:19
Your cpu support AVX and before. Don't support AVX2

Thank you, I tested it now with the libfftw3f-3.dll 3.3.8 AVX and neo_fft3d(r7 and it gives me an error "neo_fft3d doesnt have an argument 'ncpu' so I ran it without ncpu=4) is still slower (0.0254x) than fft3dfilter (0.0489x) for me. The neo_fft3d r11 does not even run. I think I am doing something wrong here.

StainlessS
22nd August 2021, 15:40
r10, [presume this solves it]
http://avisynth.nl/index.php/Neo_FFT3D

EDIT: Yeah,

neo_fft3d (clip, float "sigma", float "beta", int "bw", int "bh", int "bt", int "ow", int "oh", float "kratio", float "sharpen", float "scutoff",
\ float "svr", float "smin", float "smax", bool "measure", bool "interlaced", int "wintype", int "pframe", int "px", int "py", bool "pshow",
\ float "pcutoff", float "pfactor", float "sigma2", float "sigma3", float "sigma4", float "degrid", float "dehalo", float "hr", float "ht",
\ int "y", int "u", int "v", int "l", int "t", int "r", int "b", int "opt", int "ncpu", bool "mt")


EDIT: Arh, you tried r11, [did not notice that], r10 is latest on wiki, so maybe worth a try [maybe r11 beta].

kedautinh12
22nd August 2021, 16:00
Thank you, I tested it now with the libfftw3f-3.dll 3.3.8 AVX and neo_fft3d(r7 and it gives me an error "neo_fft3d doesnt have an argument 'ncpu' so I ran it without ncpu=4) is still slower (0.0254x) than fft3dfilter (0.0489x) for me. The neo_fft3d r11 does not even run. I think I am doing something wrong here.

What version neo_fft3d you used???

anton_foy
22nd August 2021, 16:13
r10, [presume this solves it]
http://avisynth.nl/index.php/Neo_FFT3D

EDIT: Yeah,

neo_fft3d (clip, float "sigma", float "beta", int "bw", int "bh", int "bt", int "ow", int "oh", float "kratio", float "sharpen", float "scutoff",
\ float "svr", float "smin", float "smax", bool "measure", bool "interlaced", int "wintype", int "pframe", int "px", int "py", bool "pshow",
\ float "pcutoff", float "pfactor", float "sigma2", float "sigma3", float "sigma4", float "degrid", float "dehalo", float "hr", float "ht",
\ int "y", int "u", int "v", int "l", int "t", int "r", int "b", int "opt", int "ncpu", bool "mt")


EDIT: Arh, you tried r11, [did not notice that], r10 is latest on wiki, so maybe worth a try [maybe r11 beta].

Thank you the r10 works now with ncpu=4 although 0.0248x compared to fft3dfilter 0.0489x. BM3D_CUDA did not work at all because of my poor graphics card I guess and BM3D_CPU still not started after 14 minutes so I tried another approach with HQDN3D and I was very happy with the results.
Fast (0.048x) and kept the details and colors as I wanted while removing noise nicely. Gotta make some more tests though to see if there are too much artifacts of sorts.

Script:
vid = last.tweak(sat=2.0)
nr = hqdn3d(ls=4.0, cs=4.0, lt=7.0, ct=14.0, restart=7, y=3, u=3, v=3)
dmask = vid.ColorYUV(autogain=true).sharpen(1.0).sharpen(0.6).mt_edge(mode="hprewitt",thy1=0,thy2=65280, paramscale="i16").ex_invert()
ex_merge(vid,nr,dmask, luma=true, UV=3).tweak(sat=0.64)

anton_foy
22nd August 2021, 16:16
What version neo_fft3d you used???

In that test I used neo_fft3d r7.

kedautinh12
22nd August 2021, 16:26
Your CPU don't support AVX2 so you can't use BM3D_CPU

kedautinh12
22nd August 2021, 16:30
In that test I used neo_fft3d r7.

r7 still don't have n_cpu argument. Last ver is r11
https://github.com/HomeOfAviSynthPlusEvolution/neo_FFT3D/releases

anton_foy
22nd August 2021, 17:07
r7 still don't have n_cpu argument. Last ver is r11
https://github.com/HomeOfAviSynthPlusEvolution/neo_FFT3D/releases

Thanks yes but r11 does not run, error message says "there is no function named neo_fft3d"

kedautinh12
22nd August 2021, 17:24
I don't know what issue. Maybe you got 2 file neo-fft3d in same folder or anything else. You can check with Avisynth Info Tool or AVSMeter
https://forum.doom9.org/showthread.php?t=176079

Reel.Deel
22nd August 2021, 20:47
Wow... this thread did a complete 180 :scared:


r10 is latest on wiki, so maybe worth a try [maybe r11 beta].

I created the page just a day or two before r11, which was just a bug fix for avx-512 and now copies frame properties. Regardless, the download link just points to the release page with the latest version.

StvG
22nd August 2021, 22:09
Thanks yes but r11 does not run, error message says "there is no function named neo_fft3d"

It seems you don't have the required Microsoft Visual C++ Redistributable Runtimes. Install this pack (https://github.com/abbodi1406/vcredist/releases).

anton_foy
23rd August 2021, 07:19
It seems you don't have the required Microsoft Visual C++ Redistributable Runtimes. Install this pack (https://github.com/abbodi1406/vcredist/releases).

Thank you I will do that after im finished with work today.

anton_foy
23rd August 2021, 22:00
Thank you I will do that after im finished with work today.

Thanks that made it working with neo_fft3d r11 now with ncpu=4 but still slower (0.0231x) than fft3dfilter with ncpu=4 (0.0489x)

StvG
23rd August 2021, 23:45
Thanks that made it working with neo_fft3d r11 now with ncpu=4 but still slower (0.0231x) than fft3dfilter with ncpu=4 (0.0489x)

Testing only fft3dfilter/neo_fft3d in the script or there are other filters too?
I have ~2x better fps with neo_fft3d compared to fft3dfilter when testing with only neo_fft3d/fft3dfilter in the script. mt=true gives even bigger difference.

kedautinh12
24th August 2021, 01:19
I think his CPU is old and can bottleneck with neo_fft3d

anton_foy
24th August 2021, 09:36
Testing only fft3dfilter/neo_fft3d in the script or there are other filters too?
I have ~2x better fps with neo_fft3d compared to fft3dfilter when testing with only neo_fft3d/fft3dfilter in the script. mt=true gives even bigger difference.

As I posted earlier in this thread, this is the lines I use for denoising:


vid = last.tweak(sat=2.0)
nr = fft3dfilter(sigma=7, plane=4, ncpu = 4)
#or neo_fft3d(sigma=7, Y=3, U=3, V=3, ncpu=4)
dmask = vid.ColorYUV(autogain=true).sharpen(1.0).sharpen(0.6).mt_edge(mode="hprewitt",thy1=0,thy2=65280, paramscale="i16").ex_invert()
ex_merge(vid,nr,dmask, luma=true, UV=3).tweak(sat=0.6)
I can post the full script when I come home after work.

Can mt be combined with MP_pipeline?

I think his CPU is old and can bottleneck with neo_fft3d
Probably the case.

StvG
24th August 2021, 16:14
As I posted earlier in this thread, this is the lines I use for denoising:


vid = last.tweak(sat=2.0)
nr = fft3dfilter(sigma=7, plane=4, ncpu = 4)
#or neo_fft3d(sigma=7, Y=3, U=3, V=3, ncpu=4)
dmask = vid.ColorYUV(autogain=true).sharpen(1.0).sharpen(0.6).mt_edge(mode="hprewitt",thy1=0,thy2=65280, paramscale="i16").ex_invert()
ex_merge(vid,nr,dmask, luma=true, UV=3).tweak(sat=0.6)
I can post the full script when I come home after work.

Did you compare fps between ex_invert/ex_merge and mt_invert/mt_merge in this script? For this snippet you posted:
- with mt_invert/mt_merge I have >15% better fps than using ex_invert/ex_merge (neo_fft3d used for both ex_/mt_);
- with mt_invert/mt_merge I have ~4% better fps than using ex_invert/ex_merge (fft3dfilter used for both ex_/mt_).

anton_foy
24th August 2021, 16:50
Did you compare fps between ex_invert/ex_merge and mt_invert/mt_merge in this script? For this snippet you posted:
- with mt_invert/mt_merge I have >15% better fps than using ex_invert/ex_merge (neo_fft3d used for both ex_/mt_);
- with mt_invert/mt_merge I have ~4% better fps than using ex_invert/ex_merge (fft3dfilter used for both ex_/mt_).

Aha thanks! Very good to know, I just read in the thread about extools that ex_invert should be a little bit faster than mt_invert but then that is not the case I guess.

kedautinh12
24th August 2021, 17:10
Aha thanks! Very good to know, I just read in the thread about extools that ex_invert should be a little bit faster than mt_invert but then that is not the case I guess.

Extools only faster than Masktools2 in HBD, Dogway use benchmark in conditions 16bit. If you use only 8 bit, you still use masktool2 for the speed

StvG
24th August 2021, 17:47
Extools only faster than Masktools2 in HBD, Dogway use benchmark in conditions 16bit. If you use only 8 bit, you still use masktool2 for the speed

Adding ConvertBits(16) at the top of that snippet:
- with mt_invert/mt_merge I have ~9% better fps than using ex_invert/ex_merge (neo_fft3d used for both ex_/mt_, didn't test fft3dfilter).

anton_foy
24th August 2021, 20:47
Actually I filter in 16bit. I just did not put the whole script here yet, I can do it tonight.

EDIT
Script:

MP_Pipeline("""

### Avisynth+ 3.6.1 (r3300, 3.6, I386) ###
SetFilterMTMode("DEFAULT_MT_MODE", 2)

#Index
FFVideoSource("F:\file.mp4")

# ### prefetch: 32, 16
### ###
### platform: Win32

SetFilterMTMode("FFVideoSource", MT_SERIALIZED)
Deblock_QED(quant1=26, aOff1=1, aOff2=1, bOff1=2, bOff2=2, uv=3)

convertbits(16)

### platform: win32
### branch 2
### ###

### Denoise ###
vid = last.tweak(sat=2.0)
nr = fft3dfilter(sigma=7, plane=4, ncpu = 4)#or neo_fft3d(sigma=7, Y=3, U=3, V=3, ncpu=4)
dmask=vid.ColorYUV(autogain=true).sharpen(1.0).sharpen(0.6).mt_edge(mode="hprewitt",thy1=0,thy2=65280,paramscale="i16").ex_invert()
ex_merge(vid,nr,dmask, luma=true, UV=3).tweak(sat=0.6)

### platform: win32
### branch 2
### ###

### platform: Win32

### ###

# UNBLOW #
clip1 = last.Levels(0, 1, 65280, 0, 235*256, coring=false, dither=false)
clipR = Levels(0, 1, 65280, 0, 235*256, coring=false, dither=false).converttorgb64().extractR()
clipG = Levels(0, 1, 65280, 0, 235*256, coring=false, dither=false).converttorgb64().extractG()
clipB = Levels(0, 1, 65280, 0, 235*256, coring=false, dither=false).converttorgb64().extractB()
RBD = clipB.Overlay(clipR, mode="darken", opacity=1.0)
GRD = clipG.Overlay(RBD, mode="darken", opacity=1.0)
umask= Greyscale().Levels(197*256, 0.76, 65280, 0, 255*256, coring=false, dither=false).fastgaussblur(20)
mt_merge(clip1, GRD, umask, Y=3, U=2, V=2, chroma="copy first", w=-1, h=-1, paramscale="i16")

### ###
### platform: Win32

neo_f3kdb(range=15, Y=45, Cb=30, Cr=30, grainY=0, grainC=0, sample_mode=2, blur_first=true, dynamic_grain=false, mt=true)

### platform: Win32

### ###

""")
trim(40,60)

#Chroma Upscaling
ConverttoYUV444()
ConvertBits(bits=10, dither=1)
Prefetch(6)

kedautinh12
25th August 2021, 00:17
Avs+ last ver is 3.7.1 test 9
https://drive.google.com/uc?export=download&id=1lbiMMPsSFTKoKhUKdNl0NdcKiv0bgLKY

anton_foy
25th August 2021, 07:10
Avs+ last ver is 3.7.1 test 9
https://drive.google.com/uc?export=download&id=1lbiMMPsSFTKoKhUKdNl0NdcKiv0bgLKY

Thanks!

Dogway
25th August 2021, 10:42
Adding ConvertBits(16) at the top of that snippet:
- with mt_invert/mt_merge I have ~9% better fps than using ex_invert/ex_merge (neo_fft3d used for both ex_/mt_, didn't test fft3dfilter).

Why don't you guys read the benchmarks?

# mt_merge(luma=true,U/V=3) is 8% faster than ex_merge(luma=true, UV=3) (5% slower when Y clips/masks)
# mt_invert() is 10% slower than ex_invert()
# invert(channels="Y") is 17% slower than ex_invert()
# Overlay(mode="multiply") is 56% slower than ex_blend(mode="multiply")
# Overlay_MTools(mode="multiply") is 13% slower than ex_blend(mode="multiply")

ex_invert() is faster in HBD as is ex_blend() compared to Overlay(). And I'm not hiding ex_merge() is slower when you use YUV clips.

Excerpt from ExTools, matches your 9%:
# mt_merge() is 5% slower on Y clips / masks
# 8% faster on luma=true for YUV clips / masks
# 9% faster on luma=true for YUV clips Y masks
# 9% faster on luma=false for YUV clips Y masks


Anyway that script would run at 15fps most, the bottleneck being fft3d, I would refrain from using such filters.

anton_foy
25th August 2021, 11:40
Why don't you guys read the benchmarks?

# mt_merge(luma=true,U/V=3) is 8% faster than ex_merge(luma=true, UV=3) (5% slower when Y clips/masks)
# mt_invert() is 10% slower than ex_invert()
# invert(channels="Y") is 17% slower than ex_invert()
# Overlay(mode="multiply") is 56% slower than ex_blend(mode="multiply")
# Overlay_MTools(mode="multiply") is 13% slower than ex_blend(mode="multiply")

ex_invert() is faster in HBD as is ex_blend() compared to Overlay(). And I'm not hiding ex_merge() is slower when you use YUV clips.

Excerpt from ExTools, matches your 9%:
# mt_merge() is 5% slower on Y clips / masks
# 8% faster on luma=true for YUV clips / masks
# 9% faster on luma=true for YUV clips Y masks
# 9% faster on luma=false for YUV clips Y masks


Anyway that script would run at 15fps most, the bottleneck being fft3d, I would refrain from using such filters.

Thanks for this information! Do you have any recommendation for another filter than fft3d? I can post the original clip I use to test on.

kedautinh12
25th August 2021, 11:51
For mine
TemporalDegrain2 with postFFT=3
https://forum.doom9.org/showthread.php?t=175798

MCDegrainShape
https://forum.doom9.org/showthread.php?p=1926403#post1926403

MCTemporalDenoise
https://github.com/realfinder/AVS-Stuff/blob/Community/avs%202.5%20and%20up/MCTemporalDenoise.avsi

NotSMDegrain with prefilter=3
https://github.com/realfinder/AVS-Stuff/blob/Community/avs%202.5%20and%20up/NotSMDegrain.avsi

Next is KNLMeansCL or TemporalDegrain2 with postFFT=4 or NotSMDegrain with prefilter=4

And best BM3D or SMDegrain by Dogway with prefilter=5
https://github.com/Dogway/Avisynth-Scripts/blob/master/SMDegrain%20v.3.2.5d/SMDegrain%20v3.2.5d.avsi

Dogway
25th August 2021, 11:54
Try SMDegrain (https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/master/SMDegrain%20v.3.2.5d/SMDegrain%20v3.2.5d.avsi), but it depends on source grain. Please post your clip.

StvG
25th August 2021, 19:47
Why don't you guys read the benchmarks?

Because I'm not used to taking any benchmark result as final. The testing environment can be totally different.

anton_foy
25th August 2021, 23:12
I use this script to process/filter both color and black&white (with the bw.cube 3Dlut below) film. I need to hard denoise the chroma for using this bw.cube LUT but less denoising for color sequences. In short the footage is going to be used both as B&W and color depending on the scene in the project. The material is going to be color graded after the lut(s).

Here is the first test clip(when adding the black&white lut horrible chroma noise really shows):
https://we.tl/t-mW10q2VKJs

Here is the second(this is a better clip to see the details):
https://we.tl/t-pZhXoLr1CD

Black&white 3DLUT:
https://we.tl/t-w8CK74g1bY

Dogway
26th August 2021, 10:37
Maybe it would be better to design a curve for luma only that mimics the LUT? As I see chroma is heavily damaged, so I checked if someone had made a MC TemporalSoften and modified/optimized it a bit:

# TSMC (Temporal Soften Motion Compensated) by althor1138 (18-03-2021)
#
# TSMC mod by Dogway (26-08-2021)
# -Optimization for UHD clips
# -Higher defaults
# -Tweaked settings (mt, levels, truemotion, chroma)

function TSMC(clip input, int "tradius", int "mthresh", int "lumathresh", int "blocksize",clip "auxclip", bool "pref", int "Y", int "UV")
{

pref = Default(pref, true)
Y = Default(Y, 3)
UV = Default(UV, 2)

t=Defined(tradius)
tradius=t ? tradius : 6
# temporal radius-number of frames analyzed before/after current frame.

m=Defined(mthresh)
mthresh=m ? mthresh : 180
# motion threshold-higher numbers denoise areas with higher motion.
#Anything above this number does not get denoised.

l=Defined(lumathresh)
lumathresh=l ? lumathresh : 255
# luma threshold- Denoise pixels that match in surrounding frames.
#255 is the maximum and default. 0-255 are valid numbers.
#Also adjusts chroma threshold.

b=Defined(blocksize)
blocksize=b ? blocksize : 16
#larger numbers = faster processing times

chroma = UV == 3
aux=Defined(auxclip)

w = width(input)
h = height(input)
isUHD = (w > 2599 || h > 1499)
nw = round(w/2.0)
nh = round(h/2.0)
inputA = input
inputA = aux ? auxclip : isUHD ? inputA.ConvertBits(8,dither=-1).BilinearResize(nw+nw%2, nh+nh%2) : inputA

super = MSuper(input, pel=1, hpad = 0, vpad = 0, chroma=true, mt=true, levels=1)
superfilt = MSuper(inputA,pel=1, hpad = 0, vpad = 0, chroma=true, mt=true) # bug can't disable chroma otherwise luma isn't processed

vmulti = Manalyse(superfilt,multi=true,delta=tradius,temporal=true,truemotion=true,blksize=blocksize,overlap=blocksize/2, mt=true, chroma=true)
vmulti2 = Mrecalculate(superfilt,vmulti,thsad=mthresh,truemotion=true,tr=tradius,blksize=blocksize/2,overlap=blocksize/4, mt=true, chroma=true)
vmulti2 = isUHD ? vmulti2.MScaleVect() : vmulti2
mocomp = Mcompensate(input,super,vmulti2,thsad=mthresh,tr=tradius,center=true,mt=true) # recursion=50 is bugged
dnmc = mocomp.temporalsoften(tradius,lumathresh,lumathresh,15,2)
dec = selectevery(dnmc,tradius * 2 + 1,tradius)
Y != 3 ? input.mergechroma(dec) : dec }


And I call like this:


mergechroma(TSMC(6,280,blocksize=32))

# Optional dfttest to blur spatially after TSMC
# dfttest(sstring="0.0:2.0 0.2:6.0 1.0:12.0",tbsize=1,dither=1,threads=1)


By the way, this function works great for heavy grain films like 300, 21 grams, etc.

anton_foy
26th August 2021, 10:54
Maybe it would be better to design a curve for luma only that mimics the LUT? As I see chroma is heavily damaged, so I checked if someone had made a MC TemporalSoften and modified/optimized it a bit:

# TSMC (Temporal Soften Motion Compensated) by althor1138 (18-03-2021)
#
# TSMC mod by Dogway (26-08-2021)
# -Optimization for UHD clips
# -Higher defaults
# -Tweaked settings (mt, levels, truemotion, chroma)

function TSMC(clip input, int "tradius", int "mthresh", int "lumathresh", int "blocksize",clip "auxclip", bool "pref", int "Y", int "UV")
{

pref = Default(pref, true)
Y = Default(Y, 3)
UV = Default(UV, 2)

t=Defined(tradius)
tradius=t ? tradius : 6
# temporal radius-number of frames analyzed before/after current frame.

m=Defined(mthresh)
mthresh=m ? mthresh : 180
# motion threshold-higher numbers denoise areas with higher motion.
#Anything above this number does not get denoised.

l=Defined(lumathresh)
lumathresh=l ? lumathresh : 255
# luma threshold- Denoise pixels that match in surrounding frames.
#255 is the maximum and default. 0-255 are valid numbers.
#Also adjusts chroma threshold.

b=Defined(blocksize)
blocksize=b ? blocksize : 16
#larger numbers = faster processing times

chroma = UV == 3
aux=Defined(auxclip)

w = width(input)
h = height(input)
isUHD = (w > 2599 || h > 1499)
nw = round(w/2.0)
nh = round(h/2.0)
inputA = input
inputA = aux ? auxclip : isUHD ? inputA.ConvertBits(8,dither=-1).BilinearResize(nw+nw%2, nh+nh%2) : inputA

super = MSuper(input, pel=1, hpad = 0, vpad = 0, chroma=true, mt=true, levels=1)
superfilt = MSuper(inputA,pel=1, hpad = 0, vpad = 0, chroma=true, mt=true) # bug can't disable chroma otherwise luma isn't processed

vmulti = Manalyse(superfilt,multi=true,delta=tradius,temporal=true,truemotion=true,blksize=blocksize,overlap=blocksize/2, mt=true, chroma=true)
vmulti2 = Mrecalculate(superfilt,vmulti,thsad=mthresh,truemotion=true,tr=tradius,blksize=blocksize/2,overlap=blocksize/4, mt=true, chroma=true)
vmulti2 = isUHD ? vmulti2.MScaleVect() : vmulti2
mocomp = Mcompensate(input,super,vmulti2,thsad=mthresh,tr=tradius,center=true,mt=true) # recursion=50 is bugged
dnmc = mocomp.temporalsoften(tradius,lumathresh,lumathresh,15,2)
dec = selectevery(dnmc,tradius * 2 + 1,tradius)
Y != 3 ? input.mergechroma(dec) : dec }


And I call like this:


mergechroma(TSMC(6,280,blocksize=32))

# Optional dfttest to blur spatially after TSMC
# dfttest(sstring="0.0:2.0 0.2:6.0 1.0:12.0",tbsize=1,dither=1,threads=1)


By the way, this function works great for heavy grain films like 300, 21 grams, etc.

Wonderful many thanks Dogway! I will try it out in the evening. The Lut is emulating orthochromatic black&white in such a way the color channels are very distorted in brightness for certain hues. If I would use a "ordinary" black&white conversion I loose the specific look that I want to achieve. Yes the chroma is very damaged but if the chroma can be filtered so that "blockiness" and "chunks" are not jumping around like crazy Im happy.

kedautinh12
26th August 2021, 10:55
Try SMDegrain (https://raw.githubusercontent.com/Dogway/Avisynth-Scripts/master/SMDegrain%20v.3.2.5d/SMDegrain%20v3.2.5d.avsi), but it depends on source grain. Please post your clip.

Can you tell more details about "what sources grain use what plugins/scripts"? Thanks