Log in

View Full Version : Nasty noise that seems easily removable but isn't


msundman
29th November 2006, 14:53
I'm having a really hard time removing some nasty noise from this clip: http://www.abo.fi/~masundma/clip.mpg
It's from a DVD, but seems heavily amplified. There is very little movement, the noisy area is static (although there are a few shadows moving over it), it may be heavily blurred, and it can easily be masked, e.g. so:
v=v.Undot.Blur(1.55)
a1=v.ColorKeyMask($393D38, 29).ShowAlpha("YV12")
a2=v.ColorKeyMask($4C5653, 22).ShowAlpha("YV12")
a=Overlay(a1, a2, mode="Darken")
a=a.Blur(1.55).Blur(1.55).Blur(1.55)
a=a.Expand.Expand.Invert
Given all this it should be very easy to get pretty much perfect results. Yet I can not. I've tried a lot of denoisers (spatial, temporal, combinations) with a lot of settings. Almost all of them mostly makes the grain larger and the flicker slower. This just makes the noise even worse to look at, as the noise turns into some kind of plasma.
Does anyone have any idea what I could do?

This snapshot shows what it looks like, and also what it should look like. The problem is that all those dark dots are moving. If they weren't moving it would be close to perfect (well, a little de-contrast wouldn't hurt, but that's easy to fix).
http://www.abo.fi/~masundma/clip.png

Pookie
30th November 2006, 01:15
Could that be "Salt", as VCMohan refers to in his "SaltandPepper" plugin?

http://www.avisynth.org/vcmohan/DeSaltPepper/DeSaltPepper.html

And you're doing a separateFields() before processing, right ?

msundman
30th November 2006, 08:48
Could that be "Salt", as VCMohan refers to in his "SaltandPepper" plugin?
I don't know, but I've tried the DeSaltPepper filter with many different configuration permutations but it doesn't help.

And you're doing a separateFields() before processing, right ?
No. Should I? I mean, if we ignore the small amounts of motion there is in the scene and only concentrate on the flat, static areas we can just ignore the fact that it's interlaced, right?

Didée
30th November 2006, 14:07
Noise removed (http://rapidshare.com/files/5438073/clip_msundman_calm.rar.html). ;)

Worth noting: the stats of not-filtered vs. full-denoised encoding, with exactly same Xvid settings:

http://img153.imageshack.us/img153/5927/directencodestatsgl9.png (http://imageshack.us) http://img294.imageshack.us/img294/7658/denoisedstatsoy3.png (http://imageshack.us)

1733 / 6067 = 0.285

71.5% gain in compressibility.:) Other bids?

msundman
30th November 2006, 14:16
Noise removed
Dude, you rock! How'd you do that?!?

Didée
30th November 2006, 14:40
Oh, it's that funny machine that some of my alien mates left here on their last visit. No idea how it works, but when pressing 'n turning the knobs, funny things happen ... ;)

msundman
30th November 2006, 14:46
Seriously, if you did that with avisynth then would you mind posting the script, please?

Piper
30th November 2006, 23:04
Oh, it's that funny machine that some of my alien mates left here on their last visit. No idea how it works, but when pressing 'n turning the knobs, funny things happen ... ;)

LOL!!!

Sorry, I've nothing to contribute here, but that's one of the funniest lines I've read in these parts in quite a while. :D

Now about about showing the poor lad your script Didée! :p

Blue_MiSfit
30th November 2006, 23:24
LOL!!!! Didee I love you man!

Nice boost - I'm interested to see the script too.

~MiSfit

Pookie
30th November 2006, 23:46
Lemme guess, Didée - there's a yv12lutxy call in there :D

DarkZell666
1st December 2006, 17:28
I'm sure there's nothing extraordinary ;)

I just got a similar result using vdubmod and 2 filters:
* gunnar thalin's general convolution 3D v1.1
* vdub's internal temporal smoother

(i needed to deinterlace though because one of the filter's stopped filtering otherwise :p)

krieger2005
1st December 2006, 21:19
Oh, it's that funny machine that some of my alien mates left here on their last visit. No idea how it works, but when pressing 'n turning the knobs, funny things happen ... ;)

I'am wondering if that machine can make something similar like MCBob, but faster and whithout artifacts :D .

However. Didée used a temporal filter, i think in combination with MVTools. DeGrainMedian could be here that right one. You can see this, if you look at the first frame, which still is very noisy.

I think also, there are enough good temporal-softer-scripts out there. Maybe this is the reason, why Didée don't answer. Maybe this is a soft-spoken ":search:". However. You can try it, i does it not, with:

X=MVAnalyse-Backward
Y=MVAnalyse-Forward
interleave(X,last,Y)
DeGrainMedian(8,8)
SelectEvery(3,1)

Didée
1st December 2006, 21:49
@ DarkZell:
Post a sample, or at least the exact settings. Vdub's temporal smoother might be able to achieve very strong denoising on the static green parts, but that will necessarily destroy the moving hands, and harm the cards, too.

---

Did some hypermailing (wormhole technique), and the little blue people send me the following script, it should mimic the processing done by the funny machine.

They also noted that it runs moderately fast on their exaflop quantum computers ...

LoadPlugin("DGDecode.dll")
LoadPlugin("FluxSmooth.dll")
LoadPlugin("MedianBlur.dll")
LoadPlugin("mt_masktools.dll")
LoadPlugin("MVTools.dll")
LoadPlugin("RemoveGrain.dll")
LoadPlugin("Repair.dll")
LoadPlugin("TTempSmooth.dll")

Mpeg2Source("clip.d2v")

Bob(0,0.5)

bobbed = last
base = last.minblur(2).FluxSmoothT(9)

bw4_vec = base.MVAnalyse(isb=true, truemotion=false,delta=4,lambda=512,pel=2,sharp=2,blksize=16,overlap=16/2,pnew=32,idx=1)
bw3_vec = base.MVAnalyse(isb=true, truemotion=false,delta=3,lambda=512,pel=2,sharp=2,blksize=16,overlap=16/2,pnew=32,idx=1)
bw2_vec = base.MVAnalyse(isb=true, truemotion=false,delta=2,lambda=512,pel=2,sharp=2,blksize=16,overlap=16/2,pnew=32,idx=1)
bw1_vec = base.MVAnalyse(isb=true, truemotion=false,delta=1,lambda=512,pel=2,sharp=2,blksize=16,overlap=16/2,pnew=32,idx=1)
fw1_vec = base.MVAnalyse(isb=false, truemotion=false,delta=1,lambda=512,pel=2,sharp=2,blksize=16,overlap=16/2,pnew=32,idx=1)
fw2_vec = base.MVAnalyse(isb=false, truemotion=false,delta=2,lambda=512,pel=2,sharp=2,blksize=16,overlap=16/2,pnew=32,idx=1)
fw3_vec = base.MVAnalyse(isb=false, truemotion=false,delta=3,lambda=512,pel=2,sharp=2,blksize=16,overlap=16/2,pnew=32,idx=1)
fw4_vec = base.MVAnalyse(isb=false, truemotion=false,delta=4,lambda=512,pel=2,sharp=2,blksize=16,overlap=16/2,pnew=32,idx=1)

bw4_comp = bobbed.MVCompensate(bw4_vec,idx=2)
bw3_comp = bobbed.MVCompensate(bw3_vec,idx=2)
bw2_comp = bobbed.MVCompensate(bw2_vec,idx=2)
bw1_comp = bobbed.MVCompensate(bw1_vec,idx=2)
fw1_comp = bobbed.MVCompensate(fw1_vec,idx=2)
fw2_comp = bobbed.MVCompensate(fw2_vec,idx=2)
fw3_comp = bobbed.MVCompensate(fw3_vec,idx=2)
fw4_comp = bobbed.MVCompensate(fw4_vec,idx=2)

Interleave(bw4_comp,bw3_comp,bw2_comp,bw1_comp,bobbed,fw1_comp,fw2_comp,fw3_comp,fw4_comp)
MedianBlurT(0,0,0,4)
SelectEvery(9,4)

base2 = last
bobbed2 = last

bw4_vec2 = base2.MVAnalyse(isb=true, truemotion=false,delta=4,lambda=256,pel=2,sharp=2,blksize=8,overlap=8/2,pnew=32,idx=3)
bw3_vec2 = base2.MVAnalyse(isb=true, truemotion=false,delta=3,lambda=256,pel=2,sharp=2,blksize=8,overlap=8/2,pnew=32,idx=3)
bw2_vec2 = base2.MVAnalyse(isb=true, truemotion=false,delta=2,lambda=256,pel=2,sharp=2,blksize=8,overlap=8/2,pnew=32,idx=3)
bw1_vec2 = base2.MVAnalyse(isb=true, truemotion=false,delta=1,lambda=256,pel=2,sharp=2,blksize=8,overlap=8/2,pnew=32,idx=3)
fw1_vec2 = base2.MVAnalyse(isb=false, truemotion=false,delta=1,lambda=256,pel=2,sharp=2,blksize=8,overlap=8/2,pnew=32,idx=3)
fw2_vec2 = base2.MVAnalyse(isb=false, truemotion=false,delta=2,lambda=256,pel=2,sharp=2,blksize=8,overlap=8/2,pnew=32,idx=3)
fw3_vec2 = base2.MVAnalyse(isb=false, truemotion=false,delta=3,lambda=256,pel=2,sharp=2,blksize=8,overlap=8/2,pnew=32,idx=3)
fw4_vec2 = base2.MVAnalyse(isb=false, truemotion=false,delta=4,lambda=256,pel=2,sharp=2,blksize=8,overlap=8/2,pnew=32,idx=3)

bw4_comp2 = bobbed2.MVCompensate(bw4_vec2,idx=3)
bw3_comp2 = bobbed2.MVCompensate(bw3_vec2,idx=3)
bw2_comp2 = bobbed2.MVCompensate(bw2_vec2,idx=3)
bw1_comp2 = bobbed2.MVCompensate(bw1_vec2,idx=3)
fw1_comp2 = bobbed2.MVCompensate(fw1_vec2,idx=3)
fw2_comp2 = bobbed2.MVCompensate(fw2_vec2,idx=3)
fw3_comp2 = bobbed2.MVCompensate(fw3_vec2,idx=3)
fw4_comp2 = bobbed2.MVCompensate(fw4_vec2,idx=3)

Interleave(bw4_comp2,bw3_comp2,bw2_comp2,bw1_comp2,bobbed2,fw1_comp2,fw2_comp2,fw3_comp2,fw4_comp2)
ttempsmooth(4,8,8,2,2,strength=5,pfclip=last.RemoveGrain(11))
SelectEvery(9,4)

maxx = bobbed.mt_logic(bw1_comp,"max")
\ .mt_logic(fw1_comp,"max")
minn = bobbed.mt_logic(bw1_comp,"min")
\ .mt_logic(fw1_comp,"min")
#.mt_logic(bw2_comp,"max").mt_logic(bw3_comp,"max")
#.mt_logic(fw2_comp,"max").mt_logic(fw3_comp,"max")
#.mt_logic(bw2_comp,"min").mt_logic(bw3_comp,"min")
#.mt_logic(fw2_comp,"min").mt_logic(fw3_comp,"min")

ssharp = mt_lutxy(last,last.RemoveGrain(11), \
"x x y - abs 12 / 1 4 / ^ 12 * x y - 2 ^ x y - 2 ^ 2.3 + / * x y - x y - abs 0.0001 + / * 1 x y - abs 16 / 1 4 / ^ + / +",U=2,V=2)

ssharp.mt_Clamp(maxx,minn,0,0,U=2,V=2)

SeparateFields().SelectEvery(4,0,3).Weave() # before or after,

interleave( selectevery(5,0).FluxSmoothT(7),selectevery(5,1).FluxSmoothT(7),
\ selectevery(5,2).FluxSmoothT(7),selectevery(5,3).FluxSmoothT(7),
\ selectevery(5,4).FluxSmoothT(7) )

# SeparateFields().SelectEvery(4,0,3).Weave() # that's a question

return(last)

#=================================

# Nifty Gauss/Median combination
function MinBlur(clip clp, int r, int "uv")
{
uv = default(uv,3)
uv2 = (uv==2) ? 1 : uv
rg4 = (uv==3) ? 4 : -1
rg11 = (uv==3) ? 11 : -1
rg20 = (uv==3) ? 20 : -1
medf = (uv==3) ? 1 : -200

RG11D = (r==1) ? mt_MakeDiff(clp,clp.RemoveGrain(11,rg11),U=uv2,V=uv2)
\ : (r==2) ? mt_MakeDiff(clp,clp.RemoveGrain(11,rg11).RemoveGrain(11,rg11),U=uv2,V=uv2)
\ : mt_MakeDiff(clp,clp.RemoveGrain(11,rg11).RemoveGrain(20,rg20).RemoveGrain(20,rg20),U=uv2,V=uv2)
RG4D = (r==1) ? mt_MakeDiff(clp,clp.RemoveGrain(4,rg4),U=uv2,V=uv2)
\ : (r==2) ? mt_MakeDiff(clp,clp.medianblur(2,2*medf,2*medf),U=uv2,V=uv2)
\ : mt_MakeDiff(clp,clp.medianblur(3,3*medf,3*medf),U=uv2,V=uv2)
DD = mt_lutxy(RG11D,RG4D,"x 128 - y 128 - * 0 < 128 x 128 - abs y 128 - abs < x y ? ?",U=uv2,V=uv2)
(r==0) ? clp : clp.mt_MakeDiff(DD,U=uv,V=uv)
return(last)
}

... what probably means it's not well suited for our current PCs :D

Boulder
1st December 2006, 22:44
Are you sure you are don't work for Intel or AMD and try to get people buy their fastest chips?

I dare not even try that script on my PC :p

Didée
1st December 2006, 23:03
Are you sure you are don't work for Intel or AMD and try to get people buy their fastest chips?
Pretty sure. If I would, I weren't still sitting on a rusty XP1800+, resp. a smallbreasted Celeron 2.6 ...

Really, for the above I didn't look at performance at all. Just hacked/copy-pasta'd together what I thought that should do the job, checked some frames in the middle, saw that it almost did except for some small leftover quicksand, hence added the select/fluxsmooth part at the end ("this has to be rock stable"), let it run, went to bed, and after waking up the next morning I had a look at what it had done. :)

But you never know,

Anyway, I am wondering if there is anything else I can do to bring this poor Mac to its knees.
there might be some that need such scripts. :D

Blue_MiSfit
3rd December 2006, 12:06
16 mvanalyse, 16 mvcompensate... Wow.

I... I'm not ready!

:D

Adub
13th December 2006, 04:16
Didee, what is your encoding rig like? I mean, that you could build a script like this and not even shudder?