View Full Version : New Sharpening Function from Didée -'SeeSaw'
Pages :
1
2
3
4
5
[
6]
7
8
9
10
11
12
13
oligophant
15th October 2006, 05:39
now it works ^_^ thanks boulder =]
koolcracker
3rd November 2006, 02:55
Is there an internal resize function in SeeSaw like there is in LimitedSharpenFaster? Also, I am looking for any speed improvement tips, because at the rate its at, its going to take almost 18 hours to do a two and a half hour movie.
Video=MPEG2source("C:\DVD Rips\BatmanBegins.d2v", cpu=4, info=3).ColorMatrix(hints=true)
Audio=WavSource("C:\DVD Rips\BatmanBegins T01 3_2ch 448Kbps 48KHz.wav")
Audiodub(Video, Audio)
a = last
b=a.FluxSmoothST()
SeeSaw(a,b, NRlimit=6, NRlimit2=7, Sstr=1.5, Slimit=5, Spower=5, Sdamplo=6, Szp=16)
BicubicResize(640, 480)
Pookie
3rd November 2006, 11:17
If you resize before the SeeSaw lines, it will run faster. Try placing the Bicubicresize line above the a=last line. Also, I think that movie is Aspect Ratio: 2.35:1 which means it can be cropped to 640x272 to remove the black bars (could be wrong, I don't have the movie).
You ought to IVTC and Decimate since you have a Mpeg2 FILM source (unless you already set Dgindex to ForceFilm). Doing so will enhance your target file just as much as running it through SeeSaw.
Do you really have macroblocks? If you don't, remove the CPU=4 section from the Mpeg2Source line - your system will transcode faster and the resulting file will probably look more detailed.
NRlimit=6, NRlimit2=7 - I've noticed the higher these numbers are, the slower the processing. See if you can cut it back to 3 and 4.
Didée
3rd November 2006, 22:27
NRlimit=6, NRlimit2=7 - I've noticed the higher these numbers are, the slower the processing. See if you can cut it back to 3 and 4.
Are you sure about that? There's no reason why it should make any noticeable difference. The processing done is always the same, no matter what the NRlimits are. (Except for NRlimit=0, which will bypass a LutXY that's working on all 3 planes.) Everything runs through the same lookup ... there's a slight chance that with smaller limits, LutXY can bail out earlier from some loops, hence doing internal copying work faster. But speed differences from this should be marginal.
Pookie
3rd November 2006, 23:18
I was hoping you'd see that, Didée. I'll do a test. Of course, I could be wrong (and have been - many, many, many times) :D
EDIT: Yes Indeed, I was wrong. Did some more tests of the NR settings. Some other variable must have been affecting my encoding speeds. For this test, the following settings were used:
SeeSaw(a,b, NRlimit=X, NRlimit2=Y, Sstr=1.5, Spower=5, Sdamplo=2, Szp=16,soothet=-49)
NRlimit=2, NRlimit2=3
ffmpeg.exe -i "NR23.avs" -threads 1 -benchmark -vcodec mpeg2video -r 23.976 -dc 10 -g 15 -bufsize 480 -minrate 6000 -b 6000 -maxrate 6000 -aspect 16:9 -s 720x400 -an -mbd 2 -qmin 2 -async 1 -y "test1.vob"
bench: utime=1655.370s
NRlimit=3, NRlimit3=4
ffmpeg.exe -i "NR34.avs" -threads 1 -benchmark -vcodec mpeg2video -r 23.976 -dc 10 -g 15 -bufsize 480 -minrate 6000 -b 6000 -maxrate 6000 -aspect 16:9 -s 720x400 -an -mbd 2 -qmin 2 -async 1 -y "test1.vob"
bench: utime=1636.564s
NRlimit=5, NRlimit2=6
ffmpeg.exe -i "NR56.avs" -threads 1 -benchmark -vcodec mpeg2video -r 23.976 -dc 10 -g 15 -bufsize 480 -minrate 6000 -b 6000 -maxrate 6000 -aspect 16:9 -s 720x400 -an -mbd 2 -qmin 2 -async 1 -y "test1.vob"
bench: utime=1637.204s
NRlimit=7, NRlimit2=8
ffmpeg.exe -i "NR78.avs" -threads 1 -benchmark -vcodec mpeg2video -r 23.976 -dc 10 -g 15 -bufsize 480 -minrate 6000 -b 6000 -maxrate 6000 -aspect 16:9 -s 720x400 -an -mbd 2 -qmin 2 -async 1 -y "test1.vob"
bench: utime=1636.032s
NRlimit=8, NRlimit2=9
ffmpeg.exe -i "NR89.avs" -threads 1 -benchmark -vcodec mpeg2video -r 23.976 -dc 10 -g 15 -bufsize 480 -minrate 6000 -b 6000 -maxrate 6000 -aspect 16:9 -s 720x400 -an -mbd 2 -qmin 2 -async 1 -y "test1.vob"
bench: utime=1635.021s
NRlimit=9, NRlimit2=9
ffmpeg.exe -i "NR99.avs" -threads 1 -benchmark -vcodec mpeg2video -r 23.976 -dc 10 -g 15 -bufsize 480 -minrate 6000 -b 6000 -maxrate 6000 -aspect 16:9 -s 720x400 -an -mbd 2 -qmin 2 -async 1 -y "test1.vob"
bench: utime=1635.221s
fjhdavid
6th November 2006, 12:34
dear Didee and all,
I read your posts and I know that I asked for a different question, but if you have several minutes, could you answer my simple question:
I used LSF with the Soothe function (maybe seesaw one day when I will understand more about it).
I watch only Film movies and my filters are in the following order:
1- denoise 3D HQ
2- Lanczos resize 1280, 720
3- LSF (smode=3) and soothe
I would like to add a "deblocking filter". Two questions:
- Which deblocking filter do you prefer? (I was thinking of ffdshow postprocessing filter)
- In which position do I have to put the deblocking filter in the sequence regarding to the others filters in order to get the best picture?
thanks
Francois
Didée
6th November 2006, 13:00
As I replied to the PM you sent in parallel:
Smoothing/denoising might (or will) turn the "sharp" borders of the blocking artefacts into "not-sharp" borders. Most deblockers need those "sharp" block borders to reckognize where blocking occurs.
Moreover, resizing will relocate the blocking borders so that they're no more aligned with the 8x8 grid. This alignment is something on which most deblockers rely on, too.
Thus, you should use deblocking before smoothing or denoising, and before resizing.
What I actually mostly use for deblocking is Deblock_QED ... but I'm biased in that respect. ;)
Holomatrix
7th November 2006, 00:14
As soon as I put the removegrain files in my Avisynth 2.5 plugin folder I can't get any scripts to run. What did I miss? All I'm doing is calling the seesaw avs and has the removegrain files, do I need something else?
Pookie
7th November 2006, 02:36
Don't put them ALL in, just the one that best suits your hardware platform. Try keeping *SSE2.dll and remove the others which don't for starters. (Unless your PC is Pre-P4). Also, you might need mscvcr71.dll in your \windows\system32 folder.
Holomatrix
7th November 2006, 04:49
I'm running an AMD so I copied, DenoiseSharpen.dll, RemoveGrain.cpp, RemoveGrain.dll, RemoveGrain.htm, Repair.dll and RSharpen.dll into my plugin directory. Anything else? where do I find the mscvcr file?
Pookie
7th November 2006, 05:39
http://www.cpuid.org/cpuz.php
Use the utility above to determine if your system supports SSE or SSE2 . If it does, use those plugins instead.
http://www.dll-files.com/dllindex/dll-files.shtml?msvcr71
Holomatrix
7th November 2006, 06:36
I tried just;
0=BicubicResize(^TargetWidth,^TargetHeight,^b_value,^c_value)
1=Import(!SeeSaw.avs)
2=SeeSaw(NRlimit=4, NRlimit2=5, Sstr=1.5, Slimit=5, Spower=7, Sdamplo=6, Szp=16))
3=AddBorders(^BorderLeft,^BorderTop,^BorderRight,^BorderBottom)
^b_value=0.0
^c_value=0.6
!SeeSaw.avs=C:\Program Files\DVD2SVCD\Avisynth2.5 Plugins\SeeSaw\SeeSaw.avs
Without any plugins but still getting a script error in DVD2SVCD :(
Pookie
7th November 2006, 09:32
You Still Need RemoveGrain.
superuser
7th November 2006, 18:59
One thing, what was is difference between LimitedSharpen and LimitedSharpenFaster. This might be already answered in this thread, but there are two many posts to dig through.
thnxs in advance.
Edit:" Also are there newer revision of LimitedSharpen Script than posted in starting of the thread, if so where to get it from. Currently most of the pages on avisynth r down, so other link or script itself will be helpful.
thnxs.
Boulder
7th November 2006, 19:19
LimitedSharpen is LimitedSharpen..
..LimitedSharpenFaster is.....
a faster LimitedSharpen :p
Pookie
8th November 2006, 04:36
Holomatrix - I was looking at the DVD2SVCD faq - there's an option to edit the AVS file before encoding. Rather than confuse yourself with "^!" notation, just try a plain ol' modification of an AviSynth script. Voila !
Pookie
17th November 2006, 01:48
For very fast transcodes with SeeSaw, the recently compiled Vinverse function seems to work nicely as a dumb denoiser/smoother.
http://bengal.missouri.edu/~kes25c/vinverse.zip
Thanks to Didée and Tritical
a=last
b=a.vinverse()
SeeSaw(a,b, NRlimit=4, NRlimit2=5, Sstr=1.5, Spower=7, Szp=2, bias=90)
Reference to original post: http://forum.doom9.org/showthread.php?p=841641&highlight=vinverse#post841641
fjhdavid
21st November 2006, 18:13
I thought vinverse was "against residual combing" and not a denoiser filter like HQDN3D
am I wrong?
Pookie
21st November 2006, 19:04
It's a denoiser as much as Blur() is. Just a fast method to calm down a picture during transcoding or playback and using SeeSaw to keep it all from turning into mush.... The b variable in SeeSaw can consist of many kinds of filters/functions, including Addgrain, Limitedsharpen, etc - stuff that seems counterintuitive, but it all depends on the source. If Vinverse doesn't please the eyes, FluxsmoothT is great (but slower).
Some people use LimitedSharpen or SeeSaw for realtime playback on their PCs, in which case an accurate and "smart" denoiser like fft3dfilter is going to consume too many cpu cycles for smooth viewing.
fjhdavid
21st November 2006, 22:38
HQDN3D is not one of the best denoiser available (for realtime viewing) and perfectly suited for seeaw?
Pookie
21st November 2006, 23:19
Could be. Haven't tested the performance. That filter originally comes from the FFdshow code, doesn't it? In that case, perhaps it makes more sense to invoke it from FFdshow directly rather than call it via an Avisynth script.
Egh
22nd November 2006, 23:06
HQDN3D is not one of the best denoiser available (for realtime viewing) and perfectly suited for seeaw?
Who knows :P
You see, some people do have different tastes and work with different sauces using different standards.
Some praise convolution3d + deen + hqdn3d, some (like me :shy: ), rejected removegrain(mode=2) with FluxSmoothT(3) on the grounds of far too much quality degradation for one particular encode.
Basic hqdn3d in my experience destroys far too much even for dvds with values higher than (2).
fjhdavid
23rd November 2006, 17:18
egh, what you said for the values higher than 2 for hqdn3d is true only for the luminance and the chroma (even if the resolution of chroma is half the luma), BUT the last two arguments named "TIME" need to be at least 4 and are very efficient. In fact the filter is looking during 4 seconds to pixels change and remove those which change to much.
so a very efficient way is to call the function this way
hqdn3d (0,0,4,4)
Egh
23rd November 2006, 20:23
In fact the filter is looking during 4 seconds to pixels change and remove those which change to much.
so a very efficient way is to call the function this way
hqdn3d (0,0,4,4)
Sure that's 4 *seconds* aka roughly 100 frames? :) Not just 4 frames? :)
foxyshadis
23rd November 2006, 20:28
Actually, hqdn3d is a 3x3x3 filter (very similar to degrainmedian), it only compares against the next and previous frames. Not coincidentally, its effects are also similar to degrainmedian, although it doesn't always clip as hard. The oddly-named "time" parameter merely determines how strong the next/previous temporal smoothing is - it corresponds to luma strength, and all three parameters are combined to determine chroma smoothing strength.
fjhdavid
24th November 2006, 01:40
and my question remains :
what is actually the best denoisers for realtime viewing (with a intel core duo for example)?
JarrettH
30th November 2006, 03:47
anyone compare output of SeeSaw to FluxSmooth?:cool:
Blue_MiSfit
3rd December 2006, 12:40
Hey everyone,
So I'm LOVING SeeSaw's sharpening, it seems to enhance detail significantly while maintaining a calmer clip overall! I've been trying to get the best out of my copy of The Andromeda Strain, and here's what I'm working with right now:
DGDecode_mpeg2source("F:\Movies Work\Andromeda Strain\Andromeda.d2v",info=3)
ColorMatrix(hints=true)
crop( 8, 62, -8, -66)
a=last
b=last
c=last
b=b.DeGrainMedian(limitY=3, limitUV=7, mode=1)
b=b.DeGrainMedian(limitY=3, limitUV=7, mode=1)
d=SeeSaw(a,b,bias=40).histogram().subtitle("seesaw")
c=c.histogram().subtitle("source")
stackvertical(c,d)
The bits for stacking, and histograms and so forth are just for my tweaking - they won't go into the actual encode. Here are some screenshots:
http://home.comcast.net/~blue_misfit/andromeda1.png
http://home.comcast.net/~blue_misfit/andromeda3.png
I'm really pleased. I haven't encoded anything yet, so we'll see how x264 likes it. What do you guys think? It still seems a little noisy to me, but much sharper.
I seem to get better compressibility for this source using fft3dgpu(sigma=3) as my denoiser. With degrainmedian+seesaw I was getting almost 1/2 the compressibility of the source
I still have one issue with seesaw though, no matter how much I denoise, I seem to have little sparkling artifacts left in the end, they mostly appear in large flat areas, like walls etc. Any idea how to remove them? Here's a sample - this time seesaw (denoised before by fft3dgpu) is on the top. It was point resized up to 1024x1024.
http://home.comcast.net/~blue_misfit/sparkle.png
~MiSfit
fjhdavid
3rd December 2006, 15:16
Good job!
I am on the same way, and I still hesitate between a "strong degrainmedian (Y=5, mode=0) and two succesive more modest degrainmedian like yours.
(in fact sparkling seems to be noise which remains and goes through seesaw...)
what histogram stand for? and colormatrix (hints=true)?
Pookie
3rd December 2006, 20:05
Try reducefluctuations(limit=2) from the ReduceFlicker plugin by kassandro. Might help on the flat parts. 264 transcodes can make problems in the flat areas more obvious. Test it out before you do another 2 day encode :)
Blue_MiSfit
3rd December 2006, 22:32
histogram() gives you those neat little vector scopes on the right side of the images. If you are comparing a denoised and a noisy clip, the histograms can show you how calm the clip is overall. It's just another way to look at the video.
Thanks for the idea Pookie. I gave it a try, and the little sparklies are still there... Maybe I just need different settings.
For example, in another scene (helicopter taking off, camera pointed at sky) where the sky is an even blue, with RGB values at roughly 94/100/121 with some variation , and the little dots are 103/111/129 with some variation. So overall, things just get about 10 levels hotter overall. Not sure how this correlates to a YUV colorspace, but maybe the info will help :)
I tried just a simple removegrain(mode=1), since these evil pixels have no temporal stability and seem to be very small, only 1 or 2 adjacent pixels. It had no effect.
~MiSfit
Blue_MiSfit
12th December 2006, 04:44
Still having strange artifacts with SeeSaw - I seem to get them with every source, and cannot kill them no matter what settings I use - even with sootheT and sootheS at 100, I still get these strange artifacts.
Anyone have some suggestions?
Didée
12th December 2006, 12:29
It really seems there's something wrong, since all those speckles are brighter than they should be, never darker.
Are you using the modded-for-MaskToolsV2 version of SeeSaw (and if so, can you post or upload it somewhere? AS Wiki is still down, and I can't find that mod on my HDs or here in the forum...), or the "old" one for MTools v.1.5.8 ?
The effect looks like if not all conditions from some Lutxy expression would be processed. But other causes are possible, too.
I glanced through the old (my) version-for-MaskToolsV158, but can't see anything wrong there.
Boulder
12th December 2006, 12:52
I've seen the speckle effect as well, and that has kept me from using SeeSaw. I actually thought that I hadn't tweaked the parameters properly (I used the defaults) and never had the time to really start investigating the issue. From what I remember, I had the problem with rather noisy sources but it is apparent even with less noisy ones.
I'll post some screenshots a bit later along with the seesaw.avs I'm using.
Blue_MiSfit: do you happen to have soothe.avsi in your plugins folder? IIRC SeeSaw also has a function named Soothe included but the functionality is not the same..
Boulder
12th December 2006, 14:20
Here are some screenshots from a rather clean source (Nanny McPhee R2):
http://www.saunalahti.fi/sainki/mcphee_original.png
http://www.saunalahti.fi/sainki/mcphee_seesaw.png
http://www.saunalahti.fi/sainki/mcphee_seesaw_dgm.png
The scripts are rather simple ones:
MPEG2Source()
a=last
b=DegrainMedian()
SeeSaw(a,b) # or SeeSaw() in mcphee_seesaw.png
The speckles appear in the kids face. They are not extremely obvious as the source is quite clean. If the source is noisy (let's say a quite good quality VHS source), they are more visible - and I wouldn't want to kill all the details by extreme denoising before SeeSaw'ing. In that case it wouldn't make much sense using SeeSaw since there's not much detail to enhance.
Yes, chances are that I just don't know how to tweak the parms:)
Here's the seesaw.avs:
function SeeSaw( clip clp, clip "denoised",
\ int "NRlimit",int "NRlimit2",
\ float "Sstr", int "Slimit", float "Spower", float "Sdamp", float "Szp",
\ float "bias", int "Smode", int "sootheT", int "sootheS", float "ssx", float "ssy")
{
ssx = default( ssx, 1.0 ) # supersampling factor x / SeeSaw doesn't require supersampling urgently.
ssy = default( ssy, ssx ) # supersampling factor y / if at all, small values ~1.25 seem to be enough.
NRlimit = default( NRlimit, 2 ) # absolute limit for pixel change by denoising
NRlimit2 = default( NRlimit2, NRlimit+1) # limit for intermediate denoising
Sstr = default( Sstr, 1.5 ) # Sharpening strength (don't touch this too much)
Slimit = default( Slimit, NRlimit+2 ) # positive: absolute limit for pixel change by sharpening
# negative: pixel's sharpening difference is reduced to diff=pow(diff,1/abs(limit))
Spower = default( Spower, 4 ) # exponent for modified sharpener
Szp = default( Szp, 16+2 ) # zero point - below: overdrive sharpening - above: reduced sharpening
Sdamp = default( Sdamp, Spower+1 ) # reduces overdrive sharpening for very small changes
bias = default( bias, 49 ) # bias towards detail ( >= 50 ) , or towards calm result ( < 50 )
Smode = default( Smode, ssx<1.35 ? 11 : ssx<1.51 ? 20 : 19 )
sootheT = default( sootheT, 49 ) # 0=minimum, 100=maximum soothing of sharpener's temporal instableness.
# (-100 .. -1 : will chain 2 instances of temporal soothing.)
sootheS = default( sootheS, 0 ) # 0=minimum, 100=maximum smoothing of sharpener's spatial effect.
Szp = Szp / pow(Sstr, 1.0/4.0) / pow( (ssx+ssy)/2.0, 1.0/2.0 )
Sdamp = Sdamp / pow(Sstr, 1.0/4.0) / pow( (ssx+ssy)/2.0, 1.0/2.0 )
ox=clp.width
oy=clp.height
xss = m4(ox*ssx)
yss = m4(oy*ssy)
NRL = string( NRlimit )
NRL2 = string( NRlimit2 )
NRLL = string( int(round( NRlimit2 * 100.0/bias - 1.0 )) )
SLIM = string( abs(Slimit) )
BIAS1 = string( bias )
BIAS2 = string( 100-bias )
ZRP = string( abs(Szp) )
PWR = string( abs(Spower) )
DMP = string( Sdamp )
denoised = defined(denoised) ? denoised : mt_lutxy(clp,clp.removegrain(4),"x "+NRL+" + y < x "+NRL+" + x "+NRL+" - y > x "+NRL+" - y ? ?",U=2,V=2)
NRdiff = mt_lutxy(clp,denoised,"x y - 128 +","x y - 128 +","x y - 128 +",U=3,V=3)
tame = mt_lutxy(clp,denoised,"x "+NRLL+" + y < x "+NRL2+" + x "+NRLL+" - y > x "+NRL2+" - x "+BIAS1+" * y "+BIAS2+" * + 100 / ? ?")
head = tame.sharpen2(Sstr,Spower,Szp,Sdamp,4)
# head = mt_merge(head,tame,tame.prewitt(multiplier=1.0).mt_expand().removegrain(20))
(ssx==1.0 && ssy==1.0) ? repair(tame.sharpen2(Sstr,Spower,Szp,Sdamp,Smode),head,1,-1,-1)
\ : repair(tame.lanczosresize(xss,yss).sharpen2(Sstr,Spower,Szp,Sdamp,Smode),head.bicubicresize(xss,yss,-.2,.6),1,-1,-1).lanczosresize(ox,oy)
# shrp=last
Soothess(last,tame,sootheT,sootheS)
sharpdiff= mt_lutxy(tame,last,"x y - 128 +",U=1,V=1)
mt_lutxy(clp,NRdiff,"y 128 "+NRL+" + > x "+NRL+" - y 128 "+NRL+" - < x "+NRL+" + x y 128 - - ? ?",
\ "y 128 "+NRL+" + > x "+NRL+" - y 128 "+NRL+" - < x "+NRL+" + x y 128 - - ? ?",
\ "y 128 "+NRL+" + > x "+NRL+" - y 128 "+NRL+" - < x "+NRL+" + x y 128 - - ? ?",U=3,V=3)
# NRR=last
Slimit>=0 ? mt_lutxy(last,sharpdiff,"y 128 "+SLIM+" + > x "+SLIM+" - y 128 "+SLIM+" - < x "+SLIM+" + x y 128 - - ? ?",U=2,V=2)
\ : mt_lutxy(last,sharpdiff,"y 128 = x x y 128 - abs 1 "+SlIM+" / ^ y 128 - y 128 - abs / * - ?",U=2,V=2)
# NRR .mergechroma(clp)
# sharpdiff.greyscale
# subtitle(SLIM)
return( last )
}
# ======= Modified sharpening function =======
function sharpen2(clip clp, float strength, int power, float zp, float ldmp, int rgmode)
{
STR = string( strength )
PWR = string( 1.0/float(power) )
ZRP = string( ZP )
DMP = string( ldmp )
mt_lutxy( clp, clp.RemoveGrain(rgmode,-1,-1), \
"x y = x x x y - abs "+ZRP+" / "+PWR+" ^ "+ZRP+" * "+STR+" * x y - 2 ^ x y - 2 ^ "+DMP+" + / * x y - x y - abs / * + ?",U=2,V=2)
return( last )
}
# ======= Soothess() function to stabilze sharpening =======
function Soothess(clip sharp, clip orig, int "sootheT", int "sootheS")
{
sootheT = default(sootheT, 25 )
sootheS = default(sootheS, 0 )
sootheT = (sootheT > 100) ? 100 : (sootheT < -100) ? -100 : sootheT
sootheS = (sootheS > 100) ? 100 : (sootheS < 0) ? 0 : sootheS
ST = string( 100 - abs(sootheT))
SSPT = string( 100 - abs(sootheS))
mt_lutxy(orig,sharp,"x y - 128 +","x y - 128 +","x y - 128 +", U=1,V=1)
(sootheS==0) ? last
\ : mt_lutxy( last, last.removegrain(20,-1,-1),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+SSPT+" * 128 + x 128 - abs y 128 - abs > x "+SSPT+" * y 100 "+SSPT+" - * + 100 / x ? ?", U=1,V=1)
mt_lutxy( last, last.temporalsoften(1,255,0,32,2),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+ST+" * 128 + x 128 - abs y 128 - abs > x "+ST+" * y 100 "+ST+" - * + 100 / x ? ?", U=1,V=1)
(sootheT > -1) ? last
\ : mt_lutxy( last, last.temporalsoften(1,255,0,32,2),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+ST+" * 128 + x 128 - abs y 128 - abs > x "+ST+" * y 100 "+ST+" - * + 100 / x ? ?", U=1,V=1)
mt_lutxy(orig,last,"x y 128 - -","x y 128 - -","x y 128 - -",U=1,V=1)
# mergechroma(sharp) # not needed in SeeSaw
return( last )
}
# ======= MOD4-and-atleast-16 helper function =======
function m4(float x) {x<16?16:int(round(x/4.0)*4)}
foxyshadis
12th December 2006, 14:27
mt_lutxy(last,sharpdiff,"y 128 == x x y etc...
stands out, but that's not even used since you didn't specify a negative slimit. It was corrected in the wiki (RIP) but that's gone now. Hmm. Too sleepy to thoroughly investigate now.
Aha, there's also a single = in sharpen2, that should be doubled.
The speckles are why I always avoided seesaw, I thought it was just part of the script, but I should have known better.
Pookie
12th December 2006, 14:36
It is the negative values in the Removegrain statements that makes the specks, but I haven't seen that artifact in transcoded files. Might it be 2.x of Masktools? I've only used the 1.5 version with SeeSaw.
Didée
12th December 2006, 14:56
It is the negative values in the Removegrain statements.
No, it is not. It's those single equal-sign's in the lut expressions.
A negative argument in RemoveGrain just means "don't process that plane", same as "Y/U/V = 1" does in MaskTools. Where negative arguments for RemoveGrain are appearing in the script, they are fully intentional.
It's those "x y = ... ?" in places where maskTools v2 requires "x y == ... ?" that completely f**k up the sharpening operation, and consequently all of the MT2 version of SeeSaw.
replacing "=" by "==" in line 55 (unimportant;)) and line 73 (essential) should fix the problem.
However, this is a Deja vu to me ... I could bet we've already had this discussion time ago, and the script in the Wiki had been corrected?
It's the old story ... even if only one single piece of a faulty script gets out of the house, it will spread around the world like mad. (Variant of Murphy's Law.)
The speckles are why I always avoided seesaw, I thought it was just part of the script,
Oh, come on!
but I should have known better.
Yep.
Pookie
12th December 2006, 18:42
The modification for MT_Masktools in Boulder's example appears to be on an early release of SeeSaw, as the "SdampLo" and "SdampHi" settings haven't appeared yet.
n3w813
12th December 2006, 19:25
Here is the newest SawSaw script that I have dated 1/2/06 4:54pm.
# SeeSaw v0.3e (02 Jan 2006)
#
# (Full Name: "Denoiser-and-Sharpener-are-riding-the-SeeSaw" )
#
# This function provides a (simple) implementation of the "crystality sharpen" principle.
# In conjunction with a user-specified denoised clip, the aim is to enhance
# weak detail, hopefully without oversharpening or creating jaggies on strong
# detail, and produce a result that is temporally stable without detail shimmering,
# while keeping everything within reasonable bitrate requirements.
# This is done by intermixing source, denoised source and a modified sharpening process,
# in a seesaw-like manner.
#
# This version is considered alpha.
#
# Usage:
#
# a = TheNoisySource
# b = a.YourPreferredDenoising()
# SeeSaw( a, b, [parameters] )
#
# You're very much encouraged to feed your own custom denoised clip into SeeSaw.
# If the "denoised" clip parameter is omitted, a simple "spatial pressdown" filter is used.
#
#
# Fiddled together by Did?, for your pleasure.
#
# ======= Main function =======
function SeeSaw( clip clp, clip "denoised",
\ int "NRlimit",int "NRlimit2",
\ float "Sstr", int "Slimit", float "Spower", float "SdampLo", float "SdampHi", float "Szp",
\ float "bias", int "Smode", int "sootheT", int "sootheS", float "ssx", float "ssy")
{
ssx = default( ssx, 1.0 ) # supersampling factor x / SeeSaw doesn't require supersampling urgently.
ssy = default( ssy, ssx ) # supersampling factor y / if at all, small values ~1.25 seem to be enough.
NRlimit = default( NRlimit, 2 ) # absolute limit for pixel change by denoising
NRlimit2 = default( NRlimit2, NRlimit+1) # limit for intermediate denoising
Sstr = default( Sstr, 1.5 ) # Sharpening strength (don't touch this too much)
Slimit = default( Slimit, NRlimit+2 ) # positive: absolute limit for pixel change by sharpening
# negative: pixel's sharpening difference is reduced to diff=pow(diff,1/abs(limit))
Spower = default( Spower, 4 ) # exponent for modified sharpener
Szp = default( Szp, 16+2 ) # zero point - below: overdrive sharpening - above: reduced sharpening
SdampLo = default( SdampLo, Spower+1 ) # reduces overdrive sharpening for very small changes
SdampHi = default( SdampHi, 24 ) # further reduces sharpening for big sharpening changes. Try 15~30. "0" disables.
bias = default( bias, 49 ) # bias towards detail ( >= 50 ) , or towards calm result ( < 50 )
Smode = default( Smode, ssx<1.35 ? 11 : ssx<1.51 ? 20 : 19 )
sootheT = default( sootheT, 49 ) # 0=minimum, 100=maximum soothing of sharpener's temporal instableness.
# (-100 .. -1 : will chain 2 instances of temporal soothing.)
sootheS = default( sootheS, 0 ) # 0=minimum, 100=maximum smoothing of sharpener's spatial effect.
Szp = Szp / pow(Sstr, 1.0/4.0) / pow( (ssx+ssy)/2.0, 1.0/2.0 )
SdampLo = SdampLo / pow(Sstr, 1.0/4.0) / pow( (ssx+ssy)/2.0, 1.0/2.0 )
ox=clp.width
oy=clp.height
xss = m4(ox*ssx)
yss = m4(oy*ssy)
NRL = string( NRlimit )
NRL2 = string( NRlimit2 )
NRLL = string( int(round( NRlimit2 * 100.0/bias - 1.0 )) )
SLIM = string( abs(Slimit) )
BIAS1 = string( bias )
BIAS2 = string( 100-bias )
#ZRP = string( abs(Szp) )
#PWR = string( abs(Spower) )
#DMP = string( SdampLo )
denoised = defined(denoised) ? denoised : yv12lutxy(clp,clp.removegrain(4,-1),"x "+NRL+" + y < x "+NRL+" + x "+NRL+" - y > x "+NRL+" - y ? ?",U=2,V=2)
NRdiff = yv12lutxy(clp,denoised,"x y - 128 +","x y - 128 +","x y - 128 +",U=3,V=3)
tame = yv12lutxy(clp,denoised,"x "+NRLL+" + y < x "+NRL2+" + x "+NRLL+" - y > x "+NRL2+" - x "+BIAS1+" * y "+BIAS2+" * + 100 / ? ?")
head = tame.sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,4)
# head = head.maskedmerge(tame,tame.prewitt(multiplier=1.0).expand().removegrain(20))
(ssx==1.0 && ssy==1.0) ? repair(tame.sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,Smode),head,1,-1,-1)
\ : repair(tame.lanczosresize(xss,yss).sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,Smode),head.bicubicresize(xss,yss,-.2,.6),1,-1,-1).lanczosresize(ox,oy)
Soothe(last,tame,sootheT,sootheS)
sharpdiff= yv12lutxy(tame,last,"x y - 128 +",U=1,V=1)
(NRlimit==0) ? clp : \
yv12lutxy(clp,NRdiff,"y 128 "+NRL+" + > x "+NRL+" - y 128 "+NRL+" - < x "+NRL+" + x y 128 - - ? ?",
\ "y 128 "+NRL+" + > x "+NRL+" - y 128 "+NRL+" - < x "+NRL+" + x y 128 - - ? ?",
\ "y 128 "+NRL+" + > x "+NRL+" - y 128 "+NRL+" - < x "+NRL+" + x y 128 - - ? ?",U=3,V=3)
Slimit>=0 ? yv12lutxy(last,sharpdiff,"y 128 "+SLIM+" + > x "+SLIM+" - y 128 "+SLIM+" - < x "+SLIM+" + x y 128 - - ? ?",U=2,V=2)
\ : yv12lutxy(last,sharpdiff,"y 128 = x x y 128 - abs 1 "+SlIM+" / ^ y 128 - y 128 - abs / * - ?",U=2,V=2)
return( last )
}
# ======= Modified sharpening function =======
function sharpen2(clip clp, float strength, int power, float zp, float lodmp, float hidmp, int rgmode)
{
STR = string( strength )
PWR = string( 1.0/float(power) )
ZRP = string( ZP )
DMP = string( lodmp )
HDMP = (hidmp==0) ? "1" : "1 x y - abs "+string(hidmp)+" / 4 ^ +"
yv12lutxy( clp, clp.RemoveGrain(rgmode,-1,-1), \
"x y = x x x y - abs "+ZRP+" / "+PWR+" ^ "+ZRP+" * "+STR+" * x y - 2 ^ x y - 2 ^ "+DMP+" + / * x y - x y - abs / * "+HDMP+" / + ?",U=2,V=2)
return( last )
}
# ======= Soothe() function to stabilze sharpening =======
function Soothe(clip sharp, clip orig, int "sootheT", int "sootheS")
{
sootheT = default(sootheT, 25 )
sootheS = default(sootheS, 0 )
sootheT = (sootheT > 100) ? 100 : (sootheT < -100) ? -100 : sootheT
sootheS = (sootheS > 100) ? 100 : (sootheS < 0) ? 0 : sootheS
ST = string( 100 - abs(sootheT))
SSPT = string( 100 - abs(sootheS))
yv12lutxy(orig,sharp,"x y - 128 +","x y - 128 +","x y - 128 +", U=1,V=1)
(sootheS==0) ? last
\ : yv12lutxy( last, last.removegrain(20,-1,-1),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+SSPT+" * 128 + x 128 - abs y 128 - abs > x "+SSPT+" * y 100 "+SSPT+" - * + 100 / x ? ?", U=1,V=1)
(sootheT==0) ? last
\ : yv12lutxy( last, last.temporalsoften(1,255,0,32,2),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+ST+" * 128 + x 128 - abs y 128 - abs > x "+ST+" * y 100 "+ST+" - * + 100 / x ? ?", U=1,V=1)
(sootheT > -1) ? last
\ : yv12lutxy( last, last.temporalsoften(1,255,0,32,2),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+ST+" * 128 + x 128 - abs y 128 - abs > x "+ST+" * y 100 "+ST+" - * + 100 / x ? ?", U=1,V=1)
yv12lutxy(orig,last,"x y 128 - -","x y 128 - -","x y 128 - -",U=1,V=1)
# mergechroma(sharp) # not needed in SeeSaw
return( last )
}
# ======= MOD4-and-atleast-16 helper function =======
function m4(float x) {x<16?16:int(round(x/4.0)*4)}
Boulder
12th December 2006, 19:37
The modification for MT_Masktools in Boulder's example appears to be on an early release of SeeSaw, as the "SdampLo" and "SdampHi" settings haven't appeared yet.I wish I remembered where I got the script from..we really need that sticky thread with all useful functions up-to-date :)
Blue_MiSfit
13th December 2006, 04:43
That was totally it Didee!
What a strange little bug!
Thanks guys, now I can use SeeSaw!!
Jeremy Duncan
13th December 2006, 08:33
Please compare my configuration to your SeeSaw configuration. :)
a = last
b = a.FluxSmoothT(3)
SeeSaw(a, b, NRlimit=2, NRlimit2=1, Sstr=1.4, Slimit=7, Spower=2, Sdamplo=8, SdampHi=10, Szp=10, bias=1, sootheT=30)
SPresso(limit=2, limitC=0, bias=15, biasC=0, RGmode=17, RGmodeC=0)
n3w813
13th December 2006, 17:50
Can some please post the latest working SeeSaw script that uses Masktools 2.0?
Thanks :)
foxyshadis
13th December 2006, 19:47
# SeeSaw v0.3e (02 Jan 2006)
#
# (Full Name: "Denoiser-and-Sharpener-are-riding-the-SeeSaw" )
#
# This function provides a (simple) implementation of the "crystality sharpen" principle.
# In conjunction with a user-specified denoised clip, the aim is to enhance
# weak detail, hopefully without oversharpening or creating jaggies on strong
# detail, and produce a result that is temporally stable without detail shimmering,
# while keeping everything within reasonable bitrate requirements.
# This is done by intermixing source, denoised source and a modified sharpening process,
# in a seesaw-like manner.
#
# This version is considered alpha.
#
# Usage:
#
# a = TheNoisySource
# b = a.YourPreferredDenoising()
# SeeSaw( a, b, [parameters] )
#
# You're very much encouraged to feed your own custom denoised clip into SeeSaw.
# If the "denoised" clip parameter is omitted, a simple "spatial pressdown" filter is used.
#
#
# Fiddled together by Didée, for your pleasure.
#
# ======= Main function =======
function SeeSaw( clip clp, clip "denoised",
\ int "NRlimit",int "NRlimit2",
\ float "Sstr", int "Slimit", float "Spower", float "SdampLo", float "SdampHi", float "Szp",
\ float "bias", int "Smode", int "sootheT", int "sootheS", float "ssx", float "ssy")
{
ssx = default( ssx, 1.0 ) # supersampling factor x / SeeSaw doesn't require supersampling urgently.
ssy = default( ssy, ssx ) # supersampling factor y / if at all, small values ~1.25 seem to be enough.
NRlimit = default( NRlimit, 2 ) # absolute limit for pixel change by denoising
NRlimit2 = default( NRlimit2, NRlimit+1) # limit for intermediate denoising
Sstr = default( Sstr, 1.5 ) # Sharpening strength (don't touch this too much)
Slimit = default( Slimit, NRlimit+2 ) # positive: absolute limit for pixel change by sharpening
# negative: pixel's sharpening difference is reduced to diff=pow(diff,1/abs(limit))
Spower = default( Spower, 4 ) # exponent for modified sharpener
Szp = default( Szp, 16+2 ) # zero point - below: overdrive sharpening - above: reduced sharpening
SdampLo = default( SdampLo, Spower+1 ) # reduces overdrive sharpening for very small changes
SdampHi = default( SdampHi, 24 ) # further reduces sharpening for big sharpening changes. Try 15~30. "0" disables.
bias = default( bias, 49 ) # bias towards detail ( >= 50 ) , or towards calm result ( < 50 )
Smode = default( Smode, ssx<1.35 ? 11 : ssx<1.51 ? 20 : 19 )
sootheT = default( sootheT, 49 ) # 0=minimum, 100=maximum soothing of sharpener's temporal instableness.
# (-100 .. -1 : will chain 2 instances of temporal soothing.)
sootheS = default( sootheS, 0 ) # 0=minimum, 100=maximum smoothing of sharpener's spatial effect.
Szp = Szp / pow(Sstr, 1.0/4.0) / pow( (ssx+ssy)/2.0, 1.0/2.0 )
SdampLo = SdampLo / pow(Sstr, 1.0/4.0) / pow( (ssx+ssy)/2.0, 1.0/2.0 )
ox=clp.width
oy=clp.height
xss = m4(ox*ssx)
yss = m4(oy*ssy)
NRL = string( NRlimit )
NRL2 = string( NRlimit2 )
NRLL = string( int(round( NRlimit2 * 100.0/bias - 1.0 )) )
SLIM = string( abs(Slimit) )
BIAS1 = string( bias )
BIAS2 = string( 100-bias )
#ZRP = string( abs(Szp) )
#PWR = string( abs(Spower) )
#DMP = string( SdampLo )
denoised = defined(denoised) ? denoised : mt_lutxy(clp,clp.removegrain(4,-1),"x "+NRL+" + y < x "+NRL+" + x "+NRL+" - y > x "+NRL+" - y ? ?",chroma="copy first")
NRdiff = mt_makediff(clp,denoised,chroma="process")
tame = mt_lutxy(clp,denoised,"x "+NRLL+" + y < x "+NRL2+" + x "+NRLL+" - y > x "+NRL2+" - x "+BIAS1+" * y "+BIAS2+" * + 100 / ? ?")
head = tame.sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,4)
# head = head.mt_merge(tame,tame.prewitt(multiplier=1.0).mt_expand().removegrain(20))
(ssx==1.0 && ssy==1.0) ? repair(tame.sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,Smode),head,1,-1,-1)
\ : repair(tame.lanczosresize(xss,yss).sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,Smode),head.bicubicresize(xss,yss,-.2,.6),1,-1,-1).lanczosresize(ox,oy)
SootheSS(last,tame,sootheT,sootheS)
sharpdiff= mt_makediff(tame,last)
(NRlimit==0) ? clp : \
mt_lutxy(clp,NRdiff, "y 128 "+NRL+" + > x "+NRL+" - y 128 "+NRL+" - < x "+NRL+" + x y 128 - - ? ?",chroma="process")
Slimit>=0 ? mt_lutxy(last,sharpdiff,"y 128 "+SLIM+" + > x "+SLIM+" - y 128 "+SLIM+" - < x "+SLIM+" + x y 128 - - ? ?",chroma="copy first")
\ : mt_lutxy(last,sharpdiff,"y 128 == x x y 128 - abs 1 "+SlIM+" / ^ y 128 - y 128 - abs / * - ?",chroma="copy first")
return( last )
}
# ======= Modified sharpening function =======
function sharpen2(clip clp, float strength, int power, float zp, float lodmp, float hidmp, int rgmode)
{
STR = string( strength )
PWR = string( 1.0/float(power) )
ZRP = string( ZP )
DMP = string( lodmp )
HDMP = (hidmp==0) ? "1" : "1 x y - abs "+string(hidmp)+" / 4 ^ +"
mt_lutxy( clp, clp.RemoveGrain(rgmode,-1,-1), \
"x y == x x x y - abs "+ZRP+" / "+PWR+" ^ "+ZRP+" * "+STR+" * x y - 2 ^ x y - 2 ^ "+DMP+" + / * x y - x y - abs / * "+HDMP+" / + ?",chroma="copy first")
return( last )
}
# ======= Soothe() function to stabilze sharpening =======
function SootheSS(clip sharp, clip orig, int "sootheT", int "sootheS")
{
sootheT = default(sootheT, 25 )
sootheS = default(sootheS, 0 )
sootheT = (sootheT > 100) ? 100 : (sootheT < -100) ? -100 : sootheT
sootheS = (sootheS > 100) ? 100 : (sootheS < 0) ? 0 : sootheS
ST = string( 100 - abs(sootheT))
SSPT = string( 100 - abs(sootheS))
mt_makediff(orig,sharp)
(sootheS==0) ? last
\ : mt_lutxy( last, last.removegrain(20,-1,-1),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+SSPT+" * 128 + x 128 - abs y 128 - abs > x "+SSPT+" * y 100 "+SSPT+" - * + 100 / x ? ?", chroma="ignore")
(sootheT==0) ? last
\ : mt_lutxy( last, last.temporalsoften(1,255,0,32,2),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+ST+" * 128 + x 128 - abs y 128 - abs > x "+ST+" * y 100 "+ST+" - * + 100 / x ? ?", chroma="ignore")
(sootheT > -1) ? last
\ : mt_lutxy( last, last.temporalsoften(1,255,0,32,2),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+ST+" * 128 + x 128 - abs y 128 - abs > x "+ST+" * y 100 "+ST+" - * + 100 / x ? ?",chroma="ignore")
mt_makediff(orig,last)
# mergechroma(sharp) # not needed in SeeSaw
return( last )
}
# ======= MOD4-and-atleast-16 helper function =======
function m4(float x) {x<16?16:int(round(x/4.0)*4)}
[/hugepost]
n3w813
13th December 2006, 22:06
Thanks Foxyshadis. :)
jeremyofmany
17th December 2006, 07:52
Greetings.
I need some scripting assistance if you don't mind. :)
I'm obviously using:
a= last
b=a.yourfavoritedenoiser()
SeeSaw(a,b, NRlimit=3, NRlimit2=4, Sstr=1.5, Slimit=5, Spower=5, Sdamplo=6, Szp=16)
and changed it to suit me:
AviSource("D:\Hamsters(DV).avi")
LoadPlugin("D:\Video Tools\AviSynth Filters\MVTools.dll")
fields=AviSource("D:\Hamsters(DV).avi").AssumeTFF().SeparateFields() # or AssumeBFF
backward_vec2 = fields.MVAnalyse(isb = true, delta = 2, pel = 2, overlap=4, sharp=2, idx = 1)
forward_vec2 = fields.MVAnalyse(isb = false, delta = 2, pel = 2, overlap=4, sharp=2, idx = 1)
fields.MVDegrain1(backward_vec2,forward_vec2,thSAD=400,idx=1)
Weave()
a = last
b = a.AssumeTFF().SeparateFields()
SeeSaw(a,b, NRlimit=3, NRlimit2=4, Sstr=1.5, Slimit=5, Spower=5, Sdamplo=6, Szp=16)
First, I don't know if the B section is correct when in accordance to the above script.
Second, it tells me there is no function called "SeeSaw".
I downloaded it from the first post in this thread, and it's just the .AVS file, right?
I'm very tired (2:50 AM), but I hope to see a response in the morning.
Cheers & Thanks,
Jeremy
Adub
17th December 2006, 08:02
In order to use Seesaw like a plugin you either have to use
Import()
or you can change the file extension to ".avsi" instead of ".avs"
try that and see if that works.
jeremyofmany
17th December 2006, 08:16
I take it Import() is a built-in function that I can use? You mean just throw it in the script before the "a = last"? That didn't work. Neither did Import(SeeSaw). Changing the file extension prevents Media Player Classic or VirtualDub from recognising it.
Adub
17th December 2006, 08:22
no, no, no.
here is an example of Import(). You throw it in at the very beginning of the script. Like this
Import("C:\Program Files\Avisynth 2.5\plugins\SeeSaw.avs")
I like to keep my Seesaw in the Avisynth plugins folder. Easy management.
With the .avsi extension, you take that SeeSaw script. Open Notepad. copy the script to Notepad. Save the script as either
Seesaw.avs or SeeSaw.avsi, the latter if you want it to autoload and not need the Import() function. You take that file and put it into the avisynth plugins folder. Then load your different script like the one you have in your above post and play it. Or encode it, whatever.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.