Log in

View Full Version : xClean 3-Pass Denoiser


MysteryX
16th May 2022, 05:29
xClean 3-Pass Denoiser is now ready for Avisynth! (finally)

[Download here] (https://github.com/mysteryx93/xClean/blob/main/xClean.avsi)

xClean runs MVTools -> BM3D -> KNLMeans in that order, passing the output of each pass as the ref of the next denoiser.

The objective is to remove noise while preserving as much details as possible. Removing noise is easy -- just blur out everything.
The hard work is in preserving the details in a way that feels natural.

Designed for raw camera footage to remove noise in dark areas while preserving the fine details. It works for most types of content.

Performance-wise, BM3D pass is the heaviest and helps recover fine details, but this script runs 1 pass of BM3D whereas stand-alone BM3D runs twice.

Here's a denoiser comparison video showing it in action. (https://www.youtube.com/watch?v=Z0OrPP0VOUI)

In that video, the last clip of 720p webcam has the most obvious effect. The water and cliff video, you may not see much difference -- and that's the whole point, you're not losing details when it's not needed.

This port to Avisynth had been pending for a long while. I did it quickly and now it runs, but I haven't done much testing so there can be bugs and things to tweak.

For chroma upscaling in the Avisynth version, I've unlocked it to support all kernels supported by DogWay's ConvertFormat.

Test it and report any problems you see!

kedautinh12
16th May 2022, 17:12
duplicate function
"x_GetMatrixStr" : "C:\Program Files (x86)\AviSynth+\plugins64+\xClean.avsi"
"x_GetMatrixStr" : "C:\Program Files (x86)\AviSynth+\plugins64+\xClean.avsi"

Mounir
16th May 2022, 19:30
something's wrong in the avsi man i got and kind of <!DOCTYPE html>, no actual code that i can see.
edit: ok i have copy/pasted the code from the page but i get an error (line 220 in the avsi), in bold in the code below

cplace = Select(x_GetChromaLoc(clp), "left", "center", "top_left", "left", "left", "left")

if (isy)
{
chroma = "none"
conv = False

Selur
16th May 2022, 19:38
@Mounir: you need to open the RAW view,.. https://raw.githubusercontent.com/mysteryx93/xClean/main/xClean.avsi

Mounir
16th May 2022, 20:05
@Mounir: you need to open the RAW view,.. https://raw.githubusercontent.com/mysteryx93/xClean/main/xClean.avsi

I did, still error on line 220

ChaosKing
16th May 2022, 21:10
duplicate function
"x_GetMatrixStr" : "C:\Program Files (x86)\AviSynth+\plugins64+\xClean.avsi"
"x_GetMatrixStr" : "C:\Program Files (x86)\AviSynth+\plugins64+\xClean.avsi"

Does Avisynth+ support function overloading?

function x_GetMatrixStr(clip c, bool "fullrange")
{
fulls = propNumElements(c, "_ColorRange") > 0 ? \
propGetInt (c, "_ColorRange") == 0 : isRGB(c)
matrix = x_GetMatrix(c)
full = Default(fullrange, fulls)
return matrix == 6 ? full ? "PC.601" : "Rec601" : full ? "PC.709" : "Rec709"
}

function x_GetMatrixStr(clip c)
{
fulls = x_GetColorRange(c) == 0
matrix = x_GetMatrix(c)

}

MysteryX
17th May 2022, 00:01
That's DogWay's rewrite of the function colliding with mine, merged it quick last night. I was also having an issue with chroma="nnedi3" but it works with chroma="bicubic" or "reconstructor"

kedautinh12
17th May 2022, 00:31
You can try to use deep_resize. I think it's faster than nnedi3_resize16

MysteryX
17th May 2022, 03:14
I'm using DogWay's ConvertFormat. nnedi3_resize16 was complaining that it doesn't support 16-bit.

kedautinh12
17th May 2022, 05:15
Deep_resize belong to Dogway too
https://github.com/Dogway/Avisynth-Scripts/blob/3b3ee5a325aa0f886e2a5fdba24fd33607be3bfb/ResizersPack.avsi#L30

MysteryX
17th May 2022, 20:46
The nnedi3 problem is fixed. Update TransformsPack.avsi to the latest version.

tormento
2nd January 2025, 13:57
I tried to use xClean for the first time and got error.

Tried to debug with the author but he is not using Windows anymore and is not interested in further development.

First try

LoadPlugin("D:\Eseguibili\Media\DGDecNV\DGDecodeNV.dll")
DGSource("M:\In\1989_07 Kiki - Consegne a domicilio ~774p Lucky Red\kiki.dgi",ct=24,cb=24,cl=0,cr=0)
xClean(chroma="none", sharp=0, rn=0, deband=false, depth=0, strength=0, m1=.6, m2=2, m3=2, rgmode=0, thsad=400, d=2, a=2, h=1.4, sigma=9.0, block_step=4, bm_range=16, ps_range=8, radius=0, conv=true)

Error:

fmtc_matrix: greyscale format not supported as input.
(D:/Programmi/Media/AviSynth+/plugins64/xClean-beta10~mysteryx93.avsi, line 560)
(D:/Programmi/Media/AviSynth+/plugins64/xClean-beta10~mysteryx93.avsi, line 561)
(D:/Programmi/Media/AviSynth+/plugins64/xClean-beta10~mysteryx93.avsi, line 233)
(M:\In\1989_07 Kiki - Consegne a domicilio ~774p Lucky Red\kiki_774p_xclean.avs, line 3)

Second try

LoadPlugin("D:\Eseguibili\Media\DGDecNV\DGDecodeNV.dll")
DGSource("M:\In\1989_07 Kiki - Consegne a domicilio ~774p Lucky Red\kiki.dgi",ct=24,cb=24,cl=0,cr=0)
xClean(chroma="nnedi3", sharp=0, rn=0, deband=false, depth=0, strength=0, m1=.6, m2=2, m3=2, rgmode=0, thsad=400, d=2, a=2, h=1.4, sigma=9.0, block_step=4, bm_range=16, ps_range=8, radius=0, conv=true)

Error:

Script error: NNEDI3RESIZE does not have a named argument "src_width"
(D:/Programmi/Media/AviSynth+/plugins64/TransformsPackMain-2.2.1~Dogway.avsi, line 969)
(D:/Programmi/Media/AviSynth+/plugins64/TransformsPackMain-2.2.1~Dogway.avsi, line 971)
(D:/Programmi/Media/AviSynth+/plugins64/TransformsPackMain-2.2.1~Dogway.avsi, line 972)
(D:/Programmi/Media/AviSynth+/plugins64/TransformsPackMain-2.2.1~Dogway.avsi, line 973)
(D:/Programmi/Media/AviSynth+/plugins64/TransformsPackMain-2.2.1~Dogway.avsi, line 973)
(D:/Programmi/Media/AviSynth+/plugins64/TransformsPackMain-2.2.1~Dogway.avsi, line 1323)
(D:/Programmi/Media/AviSynth+/plugins64/xClean-beta10~mysteryx93.avsi, line 232)
(M:\In\1989_07 Kiki - Consegne a domicilio ~774p Lucky Red\kiki_774p_xclean.avs, line 3)

Dogway seems disappeared too.

Anyone willing to help me?

P.S: It would be nice, once having it functioning back, replace nnedi3 with its OpenCL version.

Emulgator
2nd January 2025, 16:47
The second xClean commandline runs here.
I am guessing at a version mismatch.
BTW, that setting is killing all details in a cartoon I have laying around, and shifting chroma.

StvG
2nd January 2025, 17:40
@tormento,

The first error fmtc_matrix: greyscale format not supported as input. - change line #233 (xClean.avsi) from cconv = conv && (clp.IsYUV() || clp.IsYUVA()) ? x_ConvertMatrix(cconv, "RGB", fulls) : cconv to cconv = conv && (clp.IsYUV() || clp.IsYUVA()) ? x_ConvertMatrix(IsY(cconv) ? ConvertToYUV444(cconv) : cconv, "RGB", fulls) : cconv

The second error Script error: NNEDI3RESIZE does not have a named argument "src_width" - replace lines #968, #969, #970 (TransformsPack - Main.avsi) with the following:

}
else if (kernel_c == "nnedi3") {
Cb = Eval("Cb." + resampler_c + ")")
Cr = Eval("Cr." + resampler_c + ")")
} else {
Cb = Eval("Cb." + resampler_c + cplaceC1)
Cr = Eval("Cr." + resampler_c + cplaceC1)
}


As for "replace nnedi3 with its OpenCL version." - it uses the OpenCL version by default.

Emulgator
3rd January 2025, 13:12
Plus in case of chroma="none" because of fmtconv only accepting subsampling css "444","422","420","411" xClean needs another fix from line 564ff
(might be a hack only, but ist runs here) :
[*
function x_ClipSampling(clip c)
{
return c.IsY() ? "GRAY" : c.IsRGB() ? "RGB" : \
c.Is444() ? "444" : c.Is422() ? "422" : c.Is420() ? "420" : "UNKNOWN"
}
*]
#[*
function x_ClipSampling(clip c)
{
return c.IsY() ? "444" : c.IsRGB() ? "444" : \
c.Is444() ? "444" : c.Is422() ? "422" : c.Is420() ? "420" : "444"
}
#*]

tormento
3rd January 2025, 19:06
BTW, that setting is killing all details in a cartoon I have laying around, and shifting chroma.
Any help with parameters is welcome. It's the first time that I use it. I usually encode 1080p anime (or native resolution, whem I can find it).
The first error
Plus in case of chroma="none"
Thank you! Now it seems to work. I had to download neo_TMedian_r2 too.