Log in

View Full Version : What would you say is a HEAVY DUTY denoiser/smoother?


Chainmax
7th April 2005, 16:37
Thanks to the awesomeness of Didée, I am now able to start working on a very messed up clip. The only problem is that I have no idea what to use for MAYOR cleanup. Here's a screenshot from the unfiltered source:

http://members.arstechnica.com/x/master_burrfoot/FUBAR.png

And here's the results of the primary filterchain:

http://members.arstechnica.com/x/master_burrfoot/Less_FUBAR.png

which is the following one:

TFM(d2v="wherever\HaloTort.d2v",mode=2,PP=7,mChroma=false,chroma=false,mi=50)
TDecimate(mode=1,chroma=false)
SimpsonsRepair()
Crop(22,4,692,460,align=true)
Cnr2("xxx",4,5,255)
Camembert(true,true)
Lanczos4Resize(640,480)
Deen()
Unfilter(-30,-30)
LimitedSharpen(ss_x=2,ss_y=2,Strength=128)

As you can see, not even Deen()+Unfilter(-30,-30)+Camembert(true,true) are enough. What is the strongest filter I can use?

Chainmax
7th April 2005, 17:06
Since the black box with the timer becomes unreadable, I'd also like to know if someone can tell me how to remove it since I have no idea about logo removal.

krieger2005
8th April 2005, 12:23
I would say, a chromashift as first step is needed (i think i read in the capture-guide of doom9 something about this)

than dehalo with "blinddehalo" would be a good start. As an alternative you can use a filter, which i made some time ago. You can get it here (http://freehost11.websamba.com/krieger2005/Blinddering.dll)
It includes two filters:
- BlindDeRingA(radius,centerweight,thresholdMin,thresholdMax,Y,U,V)
- BlindDeRingB(radius,centerweight,thresholdMax,Y,U,V)

The filters search in the neightbourhood of the actual pixel (defined through radius) and take all pixels into the acount, which differ maximum "thresholdMax" and minimum "thresholdMin". Then they take from all surrounding pixel acount and give the actual pixel the weight of "centerweight" (surrounding pixel get the weight 1).
Y,U,V are booleans, which tells which channel shound be processed.
BlindDeRingB make an averagefilter before the filterprocess.

You can use it like: BlindDeRingA(3,80,0,18,true,true,true).

For extensive dehalo you can use this script:
function CEA(clip c, int "EdgeBias", int "thinY", int "noisegate"){c
EdgeBias = default(EdgeBias,16)
noisegate=default(noisegate,5)

blurrY = blindDeRingA(5,60,1,22,true,false,false)

edge1Y=blurrY.FineEdge(EdgeBias)
xvon=25
xbis=75
xbis2=130

#Big Edge
edge1YBIG=edge1Y.Levels(xbis,1,xbis2,0,255,false).inflate
edge2=edge1YBig.expand.inflate.ExpandThinX(round(thinY/2-1))
edge5Big=YV12LUTxy(edge2,edge1YBig,
\"y 0 > x 20 > & x y 1.3 * - x ?").inflate

#Fine Edge
edge1YFine=edge1Y.YV12LUT("x "+string(xvon)+"> x "+string(xbis)+" < & x "+string(xvon)+" - 255 "+string(xbis)+" "+string(xbis)+" - / * 0 ?")
edge2=edge1YFine.expand.inflate.ExpandThinX(thinY)
edge3=YV12LUTxy(edge2,edge1YFine,"y 0 > x 0 > & x y 1.3 * - x ?")
edge3=YV12Lutxy(edge3,edge1YFine,"y 0 = x 110 < & 110 x ?")
mustBeOn =YV12LutXY(c,c.RemoveGrain(4),"x y - abs "+string(noisegate)+" > 255 0 ?").inflate
mustBeOff=c.RemoveGrain(2).FineEdge(5,Y=3,U=3,V=3).Levels(20,1,120,0,255,false)
sub=YV12LUTxy(mustBeOn,mustBeOff,"x 0 > y 0 > & y x - y ?")
edge5Fine=YV12LUTxy(edge3,sub,"x 0 > x y - x ?")


sauberF=c
\.BlindDeHalo2(strength=70)
\.TBilateral(diameter=11,chroma=true)
\.UnSharpMask(80,1,0)
# \.FFT3DFilter(bt=-1, ratio=2, sigma=3, sharpen=0.6)

sauberB=c
\.BlindDeHalo2(strength=125)
\.blindDeRingA(3,15,0,22,true,false,false)
\.UnSharpMask(40,1,0)

MaskedMerge(c,sauberF,edge5Fine,Y=3,U=3,V=3)
MaskedMerge(sauberB,edge5Big,Y=3,U=2,V=2)
}




function ExpandThinX(clip c, int thin){
t0=c

t1=t0.FineEdge(3)
\.BicubicResize(t0.width*2,t0.height*2)
\.expand.BicubicResize(t0.width,t0.height)
\.inflate
t1=Logic(t1,t0,"max")

t2=c.FineEdge(3).expand.inflate
t2=Logic(t2,t0,"max")

t3=t2.FineEdge(3).BicubicResize(t0.width*2,t0.height*2).expand.BicubicResize(t0.width,t0.height).inflate
t3=Logic(t3,t2,"max")

t4=t2.FineEdge(3).expand.inflate
t4=Logic(t4,t2,"max")

t5=t4.FineEdge(3).BicubicResize(t0.width*2,t0.height*2).expand.BicubicResize(t0.width,t0.height).inflate
t5=Logic(t5,t4,"max")

thin > 5 ? t5 : Select(thin,t0,t1,t2,t3,t4,t5)
}

Usage could be something like:
CEA(EdgeBias=12, thinY=3)



Then maybe something hqdn3d would help, because it is very powerfull of flat areas while let edges sharp, so you can maybe use it with higher settings.

TBilateral(diameter=21) or something like that could be a choise (i love this filter... but it is sooo slow)

LRemoveDustMC or manaodenoise could also help...

krieger2005

Didée
8th April 2005, 13:50
TBilateral [...]i love this filterOh yes!

but it is sooo slowOH YES!!!

***

Interesting function, will give it a try (supposely it's a little slower than BDH3, isn't it ... ;) )

However, have a closer look at the source, krieger ... - note that these are "drop-shadow" -alike halos, only present at the right side of detail. In particular, some of the halos are *bigger* (wider) than the detail that is causing them. Plus the stronger of the halos do have halos themselves again ... This is *evil* stuff :devil:
E.g. BDH3 is not at all able to do anything useful about them ... that's why there is that "SimpsonsRepair" function, which is said to come from somewhere out of never-never-land ;)


But another thing: Since you do have a plugin that does area evaluation anyways ... what about:

(Since I strongly dislike any fixed thresholding, like you do through your thresholdMin|Max. Fixed thresholding is a bad thing, most times)

- Get all pixels from pixel's neighborhood ( /w custom radius)
- calculate area's average
- upper boundary: average of (all pixels > area_average)
- lower boundary: average of (all pixels < area_average)

You get the idea.


[edit, forgot something]

@ Chainmax:

Seems the noise filtering reduces contrast pretty much again. Shall we extract that "enhance" functionality, so that it can be applied after denoising, or even within and after?

Chainmax
8th April 2005, 22:51
I am going to try TBilateral in addition to Deen then. By the way, Didée, as you can see I used SimpsonsRepair with default settings, meaning that no enhancement takes place. After seeing how SimpsonsRepair darkens things (look at the timer or the kitchen handles), I think it's probably better to use enhancement (what do you mean use it within denoising?).

krieger2005
9th April 2005, 01:39
Originally posted by Didée
Interesting function, will give it a try (supposely it's a little slower than BDH3, isn't it ... )


Yes... it is much slower... (and i mean much...), but it can remove really horrible halos. If you have some time and some ideas how to improve this script... you know ;)

However, since here are "horrible halos" (or like you said "drop shadows") i posted the script here... I have much effort with this script. Try it, Chainmax! If it remove not anough increase "thinY", but max. thinY should be 5.


Originally posted by Didée
But another thing: Since you do have a plugin that does area evaluation anyways ... what about:

1- Get all pixels from pixel's neighborhood ( /w custom radius)
2- calculate area's average
3- upper boundary: average of (all pixels > area_average)
4- lower boundary: average of (all pixels < area_average)

For 2: BlindDeRingB make an average, but only for a radius of 1 (so only 9 Pixels)
For 3 and 4: does i understand it right, that the filter should give an average in the "upper"-"lower"-Range for a pixel? If this is right, then BlindDeRingB is the right thing. The only thing is, that it have no "lower boundary". I made the expirience (with BlindDeRingA), that with high radius-values and a "lower boundary"-value>0 the filter produce halos... I will imporve this filter in the near future, so that the weights of the pixel-values wouldn't be allways "1", but decrease, if the radius is too big (maybe in gaussian way or something). If you have an better idea how to improve it, say it to me.

krieger2005
krieger2005

Chainmax
13th April 2005, 01:44
I'll try it soon, thanks :). In the meantime, if anyone wants to take a stab at it, you can download a sample here (http://www.31012.com/~azulftp/Halo_Torture_Clip.vob). By the way, here is the latest script I tried:

TFM(d2v="wherever\HaloTort.d2v",mode=2,PP=7,mChroma=false,chroma=false,mi=50)
TDecimate(mode=1,chroma=false)
SimpsonsRepair()
Crop(22,4,692,460,align=true)
Cnr2("xxx",4,5,255)
TBilateral(diameter=35,diameterC=25)
LRemoveDust(4,20)
BicubicResize(640,480,0,0.5)
LimitedSharpen(ss_x=2,ss_y=2,Strength=200)

And here is the result:

http://members.arstechnica.com/x/master_burrfoot/OMGSmooth.png

It does look better, but shouldn't the filters have removed much more given the strengths they were set at? Maybe I should apply another kind of filtering before the smoothing?


P.S: Didée, I tried using ENHmode=1 and it made the halos much more evident. I'll try ENHmode=1 and ENHmode=2 with different ENHstrength settings soon.

XviDEncoder
13th April 2005, 07:06
i had a really rare cartoon from VHS that was very dirty. I just converted it to digital and left it dirty, and only lightly compressed. for archive purposes. Then I reanimated the enitre thing in flash. Because it was more pleasent for people to watch that way. I actually did that with 5 minutes of a simpsons episode once. I exported the flash video to an uncompressed avi. converted to mpeg-2, and burned to dvd.
it looked infinitly more beautiful than any amount of filtering. very sharp, and brilliant. and yet, since i just traced every frame, it remained true looking to the original.
even syncing up the audio isn't that bad.

Chainmax
13th April 2005, 12:14
Well, in this case there's not only dirt but nasty ugly haloing too which I doubt conversion to flash can solve, but this procedure you mention sounds interesting. Could you tell me exactly how to do it?

Soulhunter
13th April 2005, 13:18
Huh, you are still working @ this turd?
No more SmartSmootherHQ?


Bye

Didée
13th April 2005, 14:19
[P.S: Didée, I tried using ENHmode=1 and it made the halos much more evident. I'll try ENHmode=1 and ENHmode=2 with different ENHstrength settings soon.
Yes, sure. For this source, ENHmode=1 is not suited at all.
Mode 2 does darkening only, therefore is working somewhat similar to a "line darkener", and is the one to use in this case.

Chainmax
14th April 2005, 19:29
Originally posted by Soulhunter
Huh, you are still working @ this turd ???

No more SmartSmootherHQ ???


Bye
Well, I stopped working on this shortly after trying the processing chain you suggested, but yeah, I haven't given up on it. Plus, SSHQ doesn't really cut it for this. I wish MrTibs would have released a new version of FixVHSOversharp :(.


Anyway, I can't help but think that I might have to use some unusual filtering on this, something like DeFreq, DeScratch or DeSpot. Problem is, I wouldn't know how to identify wether this needs them or not.

Emulgator
5th February 2011, 09:23
Since the links to BlindDeRing seem to be dead,
and I am willing to play with it,
could anyone help me out with a copy of BlindDeRing ?

Didée
5th February 2011, 11:10
Here: http://www.mediafire.com/?vltt32ttk6di9en

Emulgator
6th February 2011, 20:00
Many thanks, Didée !

EHarlen
29th May 2019, 17:00
function CEA(clip c, int "EdgeBias", int "thinY", int "noisegate"){c
EdgeBias = default(EdgeBias,16)
noisegate=default(noisegate,5)

blurrY = blindDeRingA(5,60,1,22,true,false,false)

edge1Y=blurrY.FineEdge(EdgeBias)
xvon=25
xbis=75
xbis2=130

#Big Edge
edge1YBIG=edge1Y.Levels(xbis,1,xbis2,0,255,false).inflate
edge2=edge1YBig.expand.inflate.ExpandThinX(round(thinY/2-1))
edge5Big=YV12LUTxy(edge2,edge1YBig,
\"y 0 > x 20 > & x y 1.3 * - x ?").inflate

#Fine Edge
edge1YFine=edge1Y.YV12LUT("x "+string(xvon)+"> x "+string(xbis)+" < & x "+string(xvon)+" - 255 "+string(xbis)+" "+string(xbis)+" - / * 0 ?")
edge2=edge1YFine.expand.inflate.ExpandThinX(thinY)
edge3=YV12LUTxy(edge2,edge1YFine,"y 0 > x 0 > & x y 1.3 * - x ?")
edge3=YV12Lutxy(edge3,edge1YFine,"y 0 = x 110 < & 110 x ?")
mustBeOn =YV12LutXY(c,c.RemoveGrain(4),"x y - abs "+string(noisegate)+" > 255 0 ?").inflate
mustBeOff=c.RemoveGrain(2).FineEdge(5,Y=3,U=3,V=3).Levels(20,1,120,0,255,false)
sub=YV12LUTxy(mustBeOn,mustBeOff,"x 0 > y 0 > & y x - y ?")
edge5Fine=YV12LUTxy(edge3,sub,"x 0 > x y - x ?")


sauberF=c
\.BlindDeHalo2(strength=70)
\.TBilateral(diameter=11,chroma=true)
\.UnSharpMask(80,1,0)
# \.FFT3DFilter(bt=-1, ratio=2, sigma=3, sharpen=0.6)

sauberB=c
\.BlindDeHalo2(strength=125)
\.blindDeRingA(3,15,0,22,true,false,false)
\.UnSharpMask(40,1,0)

MaskedMerge(c,sauberF,edge5Fine,Y=3,U=3,V=3)
MaskedMerge(sauberB,edge5Big,Y=3,U=2,V=2)
}




function ExpandThinX(clip c, int thin){
t0=c

t1=t0.FineEdge(3)
\.BicubicResize(t0.width*2,t0.height*2)
\.expand.BicubicResize(t0.width,t0.height)
\.inflate
t1=Logic(t1,t0,"max")

t2=c.FineEdge(3).expand.inflate
t2=Logic(t2,t0,"max")

t3=t2.FineEdge(3).BicubicResize(t0.width*2,t0.height*2).expand.BicubicResize(t0.width,t0.height).inflate
t3=Logic(t3,t2,"max")

t4=t2.FineEdge(3).expand.inflate
t4=Logic(t4,t2,"max")

t5=t4.FineEdge(3).BicubicResize(t0.width*2,t0.height*2).expand.BicubicResize(t0.width,t0.height).inflate
t5=Logic(t5,t4,"max")

thin > 5 ? t5 : Select(thin,t0,t1,t2,t3,t4,t5)
}


I'm getting FineEdge does not have a named argument "Y" error message with CEA(EdgeBias=12, thinY=3)

How can I fix it?


For FineEdge function


function CleanEdges(clip c, int "dering_luma", int "dering_floor", bool "use_old_chroma", int "sharpen_cycles", int "blur_cycles", int "thin", bool "mask", int "edgeinfluence"){c
EdgeBias = 16
dering_floor= default(dering_floor,13)
dering_luma = default(dering_luma, 78)
use_old_chroma = default(use_old_chroma,true)
mask=default(mask,false)
diff=default(edgeinfluence,22)

faktor=float(c.height)*float(c.width)/400000.0
sharpen_cycles=default(sharpen_cycles,round(faktor*4))
blur_cycles=default(blur_cycles,round(faktor*4))
thin = default(thin,round(faktor*2))

blurr = deen(rad=3, thrY=30, thrUV=40).hqdn3d(60,60,0,0)

u = c.utoy.blur(1.5).blur(1.5).blur(1.5).temporalsoften(2,255,0,3,2).xsharpen(155)
v = c.vtoy.blur(1.5).blur(1.5).blur(1.5).temporalsoften(2,255,0,3,2).xsharpen(155)
y = c.removeGrain(2).deen(thrY=33, thrUV=37, rad=3).xsharpen(35)

clean= ytouv(u, v, y)
\.hqdn3d(9,3,5,2)
\.RemoveDirt(mthreshold=70, pthreshold=2, tolerance=7)
\.removeGrain(2)
\.UnSharpMask(50,1,0)

sharpy=DeRing_getSharp(blurr,sharpen_cycles)
blurry=DeRing_getBlur(blurr,blur_cycles)

edge1a = YV12subtract( sharpy, blurry)
edge1b = yv12subtract( edge1a,
\ edge1a.unsharpMask(120,1,0),tol=1,wideRange=true )
\ .yv12lut(yexpr="x 128 - abs "+string(dering_floor)+" *")
edge1ba = blurr.FineEdge(EdgeBias)
edge1bb = edge1a.FineEdge(EdgeBias).inflate.inflate.inflate.blur(1)
\ .DeRing_ExpandToThin(thin)
\ .greyscale.Ylevels(19,1.6,dering_luma,0,255)
\ .Blur(1.5)
edge1bc = c.FineEdge(EdgeBias+2)

z=edge1bb
z=YV12LUTxy(edge1ba,z,"x "+string(diff)+" > y x 1.5 * - y ?")
z=YV12LUTxy(edge1bc,z,"x "+string(diff)+" > y x 1.1 * - y ?")
z=FitY2UV(z)

use_old_chroma ? mask ? z : maskedmerge( c, clean, z, Y=3,U=1,V=1, useMMX=true ) :
\ mask ? z : maskedmerge( c, clean, z, Y=3,U=3,V=3, useMMX=true )
}

#------------ Different Help functions -----------------------#
function DeRing_getSharp(clip c, int sharp_cycles){
s1= c.sharpen(0.6)
s2=s1.sharpen(0.6)
s3=s2.sharpen(0.6)
s4=s3.sharpen(0.6)
s5=s4.sharpen(0.6)
sharp_cycles <= 5 ? Select(sharp_cycles-1,s1,s2,s3,s4,s5)
\: DeRing_getSharp(s5,sharp_cycles-5)
return last
}

function DeRing_getBlur(clip c, int blur_cycles){
b1= c.Blur(0.6)
b2=b1.Blur(0.6)
b3=b2.Blur(0.6)
b4=b3.Blur(0.6)
b5=b4.Blur(0.6)

blur_cycles <= 5 ? Select(blur_cycles-1,b1,b2,b3,b4,b5)
\: DeRing_getBlur(b5,blur_cycles-5)
return last
}

function DeRing_ExpandToThin(clip c, int thin){
q=c.LanczosResize(m4(5/float(thin)*c.width),
\m4(5/float(thin)*c.height))
q=q.expand()
q=q.LanczosResize(c.width,c.height)
q=Logic(c,q,"max")

thin <= 5 ? q : DeRing_ExpandToThin(q,thin-5)
return last
}


function FineEdge( clip clp, int "div" )
{
logic( clp.DEdgeMask(0,255,0,255,"5 10 5 0 0 0 -5 -10 -5", setdivisor=true, divisor=div)
\ ,clp.DEdgeMask(0,255,0,255,"5 0 -5 10 0 -10 5 0 -5", setdivisor=true, divisor=div), "max", Y=3,U=1,V=1 )
}

StainlessS
29th May 2019, 17:16
Try this, is only a guess and untested. [Hacked from first d9 post here:- https://forum.doom9.org/showthread.php?p=517100#post517100 ]


Function FineEdge( clip clp, int "div",int "Y",Int "U",iint "V") {
Y=Default(Y,3) U=Default(U,1) V=Default(V,1)
logic( clp.DEdgeMask(0,255,0,255,"5 10 5 0 0 0 -5 -10 -5", setdivisor=true, divisor=div)
\ ,clp.DEdgeMask(0,255,0,255,"5 0 -5 10 0 -10 5 0 -5", setdivisor=true, divisor=div), "max", Y=Y,U=U,V=V )
}


EDIT: Made div non optional, is bugged to use optional arg without a default.
EDIT: Sorry, my mistake, div is not used within function, except passed on to other filter where other filter default would be used. So, reinstated div as optional arg.