Log in

View Full Version : A hybrid(or not) 300 heavy dancing grains denoiser


Ponder
6th June 2011, 01:13
The original intend was to incorporate the script inside Speedy HDRAGC v4 for heavy dancing
grains. So there is some dependency.

Needed plugins:
SimpleResize from trbarry
HDRAGC from Paviko
RemoveGrain from Kassandro
MaskTools v2 from Kurosu, Manao, mg262
TTempSmoothF from tritical
FluxSmooth from SansGrip
mod. sh0dan

LoadPlugin("F:\AviSynth 2.5\PLUGINS\SimpleResize.dll")
LoadPlugin("f:\AviSynth 2.5\PLUGINS1\TTempSmooth.dll")
#aviSource("b:\3.avi") #300 Original.avi
#DirectShowSource("b:\3.mkv", fps=23.976)
#MPEG2Source("b:\z.d2v",idct=6,cpu=0)
#simpleResize(1280,528) # better since you dont want sharpen heavy grains if downside
source=last
my_wid0=1280
#my_wid0=1024
ratio=my_wid0/4 #Mod8h may get pixels overlap, get bright green edge, mod4 preferred
mod4h=4*ROUND((HEIGHT*ratio)/width)
my_HEIGHT=mod4h
my_wid = (width > my_wid0) ? my_wid0 : width

#TTempSmoothF(1,strength=8,scthresh=15,pfclip=source.blur(1).FluxSmoothT(7).blur(1))
#HDRAGC(Corrector=0.7,Reducer=1.5,protect=1,MODE=1,PASSES=2,max_sat=1.35)

#yLevels(0, 1.9, 255, 60,273) #to see
#return last #Uncomment these above 4 lines to test pure HDRAGC and TTempSmoothF,lot more
#artifacts on flat wall on 300 Original.avi . Following script, lot less artifacts.

# Separate source into 2 parts. Pure gradient, and 100% details

a = source.simpleResize(my_wid/2,my_HEIGHT/2).blur(1).FluxSmoothT(7).blur(1)
a_up=a.simpleResize(my_wid,my_HEIGHT)
a=a.HDRAGC(Corrector=0.7,Reducer=1.5,protect=1,MODE=1,PASSES=2,max_sat=1.35)
b=a.simpleResize(my_wid,my_HEIGHT)
bri2=mt_makediff(b,a_up)
source2=source.TTempSmoothF(1,strength=7,scthresh=15,pfclip=a_up)#radius=2 is overkill,20-33% slower
mt_adddiff(bri2,source2)
RemoveGrain(1)
RemoveGrain(1)
yLevels(0, 1.8, 255, 60,273) #to see under virtualdub
return last

Didee and Zep's version look very good. Above script, version 1 was used on the dark grainy scene
to get:

My test on the "Original avi", very calm and lot of details. 14MB crf20 at
http://www.mediafire.com/?1s7e6bv5a5o2zde

HDRAGC has good effect on dark scene being a excellent gradient plugin, but
on the very bright wheat fields scene. HDRAGC preferred not be to used, to retain more contrast.

So use this instead for very bright scene. Version 1a.

a = source.simpleResize(my_wid/2,my_HEIGHT/2).blur(1).FluxSmoothT(8)
#a = source.simpleResize(my_wid/2,my_HEIGHT/2).blur(1).FluxSmoothT(7).blur(1) #or
a_up=a.simpleResize(my_wid,my_HEIGHT)
TTempSmoothF(1,strength=1,scthresh=15,pfclip=a_up)#strength=1 is best here, not 2+,quite sensitive
RemoveGrain(1)
#yLevels(0, 1.8, 255, 60,273) #to see under virtualdub
return last

It is a fairly new script aim to be fast and quite good, so improvement and new parts can be
added hence very flexible. some settings are chosen carefully, so any change without careful
inspection will impact quality.

Ponder heavy degrain test on 300's wheat field scene at crf21.9 using Version 1a on very bright scene.
http://www.mediafire.com/?pmvwdb2amltla9q

Ponder
7th June 2011, 00:34
Replacing blur(1) with medianblur(1),slightly more details are retained. Replacing medianblur(1)
with removegrain(mode=17+), even more fine details are retained. such as very fine textures on Gerald's
cape.

so this line should be used on bright scene.
a = source.simpleResize(my_wid/2,my_HEIGHT/2).removegrain(18).FluxSmoothT(7).removegrain(18)

Didée
7th June 2011, 13:25
Why does it look so woeful when things are in motion.

If you don't filter at all, then detail retention is even better, and all that damage to moving parts would be avoided.

I mean, c'mon ... you don't seriously want to tackle '300' with ttempsmooth?

Ponder
8th June 2011, 02:30
@Didée, the grain master

Zep posted 4 clips I think, from moderate dancing grains to mega dancing grains. On the "orginal avi"
where the boy kneel and rise. This simple 2 lines show lot of artifacts on wall.

TTempSmoothF(1,strength=8,scthresh=15,pfclip=source.blur(1).FluxSmoothT(7).blur(1))
HDRAGC(Corrector=0.7,Reducer=1.5,protect=1,MODE=1,PASSES=2,max_sat=1.35)

The same 2 lines on the same scene on the mkv "orginal". show quite less artifacts on wall.
just different between xvid and 264 format already show some noticable difference on decode,
so testing these clips can be misleading and tricky.

When my script version 1 worked on the "orginal avi", I tried the next clip, wheat field scene
which I had to modify, took out HDRAGC etc to get better result. Replacing blur(), with
different parts, saw more details, same speed hence replace them again. I specificly mention to
use on "bright scene" implying it may not work well on dark scene. It was a good suggestion since
it was what observed. Since those 4 clips have very different in amount of dancing grains. A script
work on one may not work fully on the others. Don't we have many dozens degrain variants!.

I don't how far TTempSmoothF can carry to, or how far other plugins can go either. Since it worked
well on the Orginal.avi and wheat field scene, and I have some repair ideas I will use. It may
complement each other. My thought was if one get a very good prefilter clip... better outcome
is ahead. If any plugins is clearly better but not 2-4 fps, I would not mind use them. :-)

Clearly, the first 2 versions do not handle that well on part of the "mega wall & sand grains". And
since blur(1).FluxSmoothT(7).blur(1) work better on "Orginal.avi" , I modified it with some
repair trick to test Zep's version of mega wall grains.

The repair version works better on the "mega wall grains" clip except at part of the sand fighting
sections where the boy, soldier, and mother, look fine but the mega dancing grains on "sands" sometime
look sticky if one freeze frame. Mega dancing grains on panning "sands" in "close up" view is sure
tough to handle. However, dancing grains on sand storm look fine being random particles behaving
like noise. The sticky sand problem can be solved if no resize used. But resize is very useful,
since it took out most of the dancing on flat areas.

RemoveGrain(1) is not even safe here on "mega wall dancing grains", it took out big chunk of details.
on some bricks. Big surprise. The clip is a little devilish.

The repair version 1b gets back the ultra fine edges during resize. So it enhances edges and fine
lines. It has more details than removegrain(mode=18) Replacing blur(). So now blur() can be used
again for mega grains clip. version 1b work on dark or bright scene.

Difficult mega wall & sand dancing grains scene with some sticky sand, freeze frame to see at
http://www.mediafire.com/?f1a9glf9h6v7mm3

Ponder
8th June 2011, 11:37
On scene where the boy rolling on the sands, There are already many artifacts in Zep's unfilter
avc clip. Not even an average of 9877 kbps can save it. So unmask the dancing effects expose some
of these.

My first 2 versions had RemoveGrain(1) in them. If testing them on "mega wall & sand dancing grains"
clip, big chunk of details disappear on many places right in front of your eyes. Plain tricky. This is the first time I see RemoveGrain(1) fail!. It works great on all other sources.