View Full Version : improve this resize?
trolltuning
2nd January 2005, 17:12
Here is the script. The first screenshot is from the original avi capture the second after deinterlacing sharpening and resizing. I know its not a great source but is there a way to make this a little better?
LoadPlugIn("C:\Program Files\AviScript 2.8 (Fullversion)\PlugIns\mpeg2dec.dll")
AviSource("D:\capture\SPH1\sailorshornpipe.avi")
ConvertToYUY2().SmartDeinterlace(2,15,false,false,false)
last.Trim(3615,6033)
Crop(176,64,384,364)
#384*364
Sharpen(.46,.46)
Lanczos4resize(768,728)
Crop(28,190,-20,-58)
http://atlantic.net/~andypo/fra3615.jpg
http://atlantic.net/~andypo/frame5.jpg
Mug Funky
2nd January 2005, 17:41
yikes!
you could put the sharpen after the resize instead of before, and maybe use limitedsharpen in it's place, but there's seriously not much you can do about that video.
this isn't CSI, you know :)
[edit]
oh, and MVbob could be used instead of smartdeinterlace, but that's not going to get you much extra resolution considering there's almost none there to begin with.
trolltuning
2nd January 2005, 19:00
Thanks.OK I thought I'd try limitedsharpen first. I get the following error:
There is no function named yv12lutXy (line 56)
(Preview line 11)
Here is the script:
LoadPlugIn("C:\Program Files\AviSynth 2.5\plugins\New Folder\MaskTools.dll")
LoadPlugIn("C:\Program Files\AviSynth 2.5\plugins\New Folder\aWarpSharp.dll")
#LoadPlugIn("C:\Program Files\AviSynth 2.5\PlugIns\New Folder\Limited.avsi")
AviSource("D:\capture\SPH1\sailorshornpipe.avi")
#ConvertToYUY2().SmartDeinterlace(2,15,false,false,false)
#last.Trim(3615,6033)
#Crop(176,64,384,364)
#384*364
Lanczos4resize(768,728)
LimitedSharpen()
#(.46,.46)
#Crop(28,190,-20,-58)
____________________________________________________________
Here is the version of the function I'm using:
# LimitedSharpen()
#
# A multi-purpose sharpener by Didée
#
function LimitedSharpen( clip clp,
\ float "ss_x", float "ss_y",
\ int "dest_x", int "dest_y",
\ int "Smode" , int "strength", int "radius",
\ int "Lmode", bool "wide", int "overshoot",
\ bool "soft", int "edgemode", bool "special",
\ int "exborder" )
{
ox = clp.width
oy = clp.height
ss_x = default( ss_x, 1.5 )
ss_y = default( ss_y, 1.5 )
dest_x = default( dest_x, ox )
dest_y = default( dest_y, oy )
Smode = default( Smode, 3 )
strength = Smode==1
\ ? default( strength, 160 )
\ : default( strength, 100 )
strength = Smode==2&&strength>100 ? 100 : strength
radius = default( radius, 2 )
Lmode = default( Lmode, 1 )
wide = default( wide, false )
overshoot= default( overshoot, 1)
overshoot= overshoot<0 ? 0 : overshoot
soft = default( soft, false )
edgemode = default( edgemode, 0 )
special = default( special, false )
exborder = default( exborder, 0)
#radius = round( radius*(ss_x+ss_y)/2) # If it's you, Mug Funky - feel free to activate it again
xxs=round(ox*ss_x/8)*8
yys=round(oy*ss_y/8)*8
smx=exborder==0?dest_x:round(dest_x/Exborder/4)*4
smy=exborder==0?dest_y:round(dest_y/Exborder/4)*4
clp.isYV12() ? clp : clp.converttoyv12()
ss_x != 1.0 || ss_y != 1.0 ? last.lanczosresize(xxs,yys) : last
tmp = last
edge = logic( tmp.DEdgeMask(0,255,0,255,"5 10 5 0 0 0 -5 -10 -5", divisor=2)
\ ,tmp.DEdgeMask(0,255,0,255,"5 0 -5 10 0 -10 5 0 -5", divisor=2)
\ ,"max").levels(0,0.86,128,0,255,false)
bright_limit = (soft == true) ? tmp.blur(1.0) : tmp
dark_limit1 = bright_limit.inpand()
bright_limit1 = bright_limit.expand()
dark_limit = (wide==false) ? dark_limit1 : dark_limit1 .inflate.deflate.inpand()
bright_limit = (wide==false) ? bright_limit1 : bright_limit1.deflate.inflate.expand()
minmaxavg = special==false
\ ? yv12lutxy(dark_limit1,bright_limit1,yexpr="x y + 2 /")
\ : maskedmerge(dark_limit,bright_limit,tmp,Y=3,U=-128,V=-128)
Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
\ : yv12lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")
OS = string(overshoot)
Lmode == 1 ? yv12lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x "+OS+" + ?")
\ : yv12lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
Lmode == 1 ? yv12lutxy( dark_limit, last, yexpr="y x "+OS+" - > y x "+OS+" - ?")
\ : yv12lutxy( dark_limit, last, yexpr="y x "+OS+" - > y x x y - "+OS+" - 1 2 / ^ - "+OS+" - ?")
edgemode==0 ? NOP
\ : edgemode==1 ? MaskedMerge(tmp,last,edge.inflate.inflate.blur(1.0),Y=3,U=1,V=1)
\ : MaskedMerge(last,tmp,edge.inflate.inflate.blur(1.0),Y=3,U=1,V=1)
(ss_x != 1.0 || ss_y != 1.0)
\ || (dest_x != ox || dest_y != oy) ? lanczosresize(dest_x,dest_y) : last
ex=blankclip(last,width=smx,height=smy,color=$FFFFFF).addborders(2,2,2,2).coloryuv(levels="TV->PC")
\.blur(1.3).inpand().blur(1.3).bicubicresize(dest_x,dest_y,1.0,.0)
tmp=clp.lanczosresize(dest_x,dest_y)
clp.isYV12() ? ( exborder==0 ? tmp.mergeluma(last)
\ : maskedmerge(tmp,last,ex,Y=3,U=1,V=1) )
\ : ( exborder==0 ? tmp.mergeluma(last.converttoyuy2())
\ : tmp.mergeluma( maskedmerge(tmp.converttoyv12(),last,ex,Y=3,U=1,V=1)
\ .converttoyuy2()) )
return last
}
#
ObiKenobi
2nd January 2005, 19:27
Do you have masktools (http://manao4.free.fr/MaskTools-v1.5.5.dll)?
Manao
2nd January 2005, 19:43
The latest version is available at http://manao4.free.fr
trolltuning
2nd January 2005, 20:00
Thanks Obikenobi
I thought the version I had predated the limitedsharpen thread but I must have screwed up. It works now.
@Manao Thanks if that's a stilllater version I'll switch to it next time I download dlls. I'm still trying to understand all the wonderful things masktools does.I need to find a script so I don't have six levels to click through every time I extract or an extraction program that will let me set the default target.
Onwards to mvbob(). CSIavisynth lives:)
ObiKenobi
2nd January 2005, 20:06
You might also want to look into using something like DeGrainMedian to get rid of some of the noise in the picture too.
trolltuning
2nd January 2005, 20:57
Oops ignore this- I just found Richard Berg's post about removing this parameter from the function.
OK I went one step further and tried to use mvBob:
I'm getting:
mvanalyse does not have a named argument compensate (line 54)
preview(line 10)
#LoadPlugIn("C:\Program Files\AviScript 2.8 (Fullversion)\PlugIns\mpeg2dec.dll")
LoadPlugIn("C:\Program Files\AviSynth 2.5\plugins\MaskTools-v1.5.5.dll")
LoadPlugIn("C:\Program Files\AviSynth 2.5\plugins\New Folder\aWarpSharp.dll")
LoadPlugIn("C:\Program Files\AviSynth 2.5\plugins\UnDot.dll")
LoadPlugIn("C:\Program Files\AviSynth 2.5\plugins\Avisynth_2.5\TomsMoComp.dll")
LoadPlugIn("C:\Program Files\AviSynth 2.5\plugins\mvtools.dll")
AviSource("D:\capture\SPH1\sailorshornpipe.avi")
#ConvertToYUY2()#.SmartDeinterlace(2,15,false,false,false))
last.Trim(3615,6033)
mvBob()
Crop(176,64,384,364)
#384*364
Lanczos4resize(768,728)
LimitedSharpen()#(.46,.46)
Crop(28,190,-20,-58)
__________________________
#mvbob.avsi follows
function MVbob(clip c,int "blksize", int "pel", int "lambda", int "thy", int "thc", int "bobth", bool "predenoise", bool
"showmask")
{
#Helper functions:
function tmcstupid(clip c)
{ input=c.converttoyuy2(interlaced=true).separatefields.tomsmocomp(1,-1,0)
a = getparity(input) ? input.selectodd : input.selecteven
b = getparity(input) ? input.selecteven : input.selectodd
a=stackvertical(a.crop(0,0,0,1-a.height),a.crop(0,0,0,-1))
output = getparity(input) ? interleave(b,a) : interleave(a,b)
output.assumeframebased().converttoyv12()
}
#disable all scene detection, because it is self-correcting
sc=255
showmask=default(showmask,false)
# luma and chroma thresholds for correcting false detected motion
thy=default(thy,20)
thc=default(thc,10)
# threshold of kerneldeint
bobth=default(bobth,8)
#denoise the video for kerneldeint (better static areas for noisy video)
predenoise=default(predenoise,false)
blksize=default(blksize,4)
scd=(blksize==8)? 300 : round(300/4)
pel=default(pel,2)
#I decided lambda=0 being better, cause it stupidly trys to catch everything. errors are corrected afterwards.
lambda=default(lambda,0)
#determine clip Fieldorder
order=(c.getparity==true)? 1:0
# create clip for motion analysis and hole-filling
bobx=predenoise ? c.temporalsoften(2,5,7) : c
bobx=bobx.kerneldeint(order=order,threshold=bobth).undot()
bobd=bobx.verticalreduceby2()
#bobd=bobd.lanczos4resize(bobx.width,bobx.height)
bobd=bobd.tomsmocomp(-1,-1,0).undot()
# create clip for motion compensation
fields=c.tmcstupid().undot()
# define clip for hole filling
fields1=bobx
# create motion vectors
mvf=bobd.mvanalyse(blksize=blksize,pel=pel,isb=false,compensate=false,search=3,searchparam=10)
mvb=bobd.mvanalyse(blksize=blksize,pel=pel,isb=true,compensate=false,search=3,searchparam=10)
# detect mismatched areas of motion compensation
bobdf=bobd.mvcompensate(mvf,mode=1,thscd1=scd,thSCD2=sc)
bobdb=bobd.mvcompensate(mvb,mode=1,thscd1=scd,thSCD2=sc)
difff=interleave(bobdf,bobd).motionmask(thy1=thy,thy2=thy,thc1=thc,thc2=thc,thSD=sc).selectodd()
diffb=interleave(bobdb,bobd).motionmask(thy1=thy,thy2=thy,thc1=thc,thc2=thc,thSD=sc).selectodd()
diff=logic(difff,diffb,"OR")
# do the deinterlacing
even1=c.separatefields().selecteven()
odd1a=fields.mvcompensate(mvf,mode=1,thscd1=scd,thSCD2=sc)
odd1a=maskedmerge(odd1a,fields1,difff,y=3,u=3,v=3).selecteven()
odd1b=fields.mvcompensate(mvb,mode=1,thscd1=scd,thSCD2=sc)
odd1b=maskedmerge(odd1b,fields1,diffb,y=3,u=3,v=3).selecteven()
odd1=mergeluma(odd1a,odd1b,0.5).mergechroma(odd1b,0.5)
odd1=(order==1) ? odd1.separatefields().selecteven() : odd1.separatefields().selectodd()
even2=c.separatefields().selectodd()
odd2a=fields.mvcompensate(mvf,mode=1,thscd1=scd,thSCD2=sc)
odd2a=maskedmerge(odd2a,fields1,difff,y=3,u=3,v=3).selectodd()
odd2b=fields.mvcompensate(mvb,mode=1,thscd1=scd,thSCD2=sc)
odd2b=maskedmerge(odd2b,fields1,diffb,y=3,u=3,v=3).selectodd()
odd2=mergeluma(odd2a,odd2b,0.5).mergechroma(odd2b,0.5)
odd2=(order==1) ? odd2.separatefields().selectodd() : odd2.separatefields().selecteven()
even=interleave(even1,odd1)
even=even.weave()
odd=interleave(even2,odd2)
odd=odd.weave()
# output
interleave(even,odd)
analysis=maskedmerge(last.levels(0,1,255,0,200),diff,diff,y=3,u=3,v=3)
showmask ? analysis : last
}
#usage: generally just mvbob()
#but if static areas are flickering (logos, subtitles etc.)
#one need to raise bobth and/or set predenoise to true.#
#if motion errors appear (small dot-like holes) one need to lower the bobth.
#thy (luma) and thc (chroma) are used for artifact prevention from mvtools.
#the lower those values, the more artifacts are catched, but the more detail as well.
#blksize, pel and lambda should be clear.
#within mvbob() I am currently using ,search=3,searchparam=10
#it makes a better compensation, but is painly slow.
#you may want to delete ,search=3,searchparam=10 from both line for better speed
trolltuning
2nd January 2005, 23:57
With this script :
#LoadPlugIn("C:\Program Files\AviScript 2.8 (Fullversion)\PlugIns\mpeg2dec.dll")
LoadPlugIn("C:\Program Files\AviSynth 2.5\plugins\MaskTools-v1.5.5.dll")
LoadPlugIn("C:\Program Files\AviSynth 2.5\plugins\New Folder\aWarpSharp.dll")
LoadPlugIn("C:\Program Files\AviSynth 2.5\plugins\UnDot.dll")
LoadPlugIn("C:\Program Files\AviSynth 2.5\plugins\Avisynth_2.5\TomsMoComp.dll")
LoadPlugIn("C:\Program Files\AviSynth 2.5\plugins\mvtools.dll")
AviSource("D:\capture\SPH1\sailorshornpipe.avi")
#ConvertToYUY2()#.SmartDeinterlace(2,15,false,false,false))
last.Trim(3615,6033)
mvBob()
Crop(176,64,384,364)
#384*364
Lanczos4resize(768,728)
LimitedSharpen()#(.46,.46)
Crop(28,190,-20,-58)
#I get this type of result
http://atlantic.net/~andypo/mvbob.jpg
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.