logo Sign In

Post #309478

Author
g-force
Parent topic
GOUT image stabilization - Released
Link to post in topic
https://originaltrilogy.com/post/id/309478/action/topic#309478
Date created
7-Feb-2008, 11:47 PM

#######################################################################################
#################### GOUT Filter By G-force V.15.00 USE ONLY ON ANH ###################
#######################################################################################

########## setup
episode = 4
Mpeg2Source("C:\Documents and Settings\Owner\Desktop\AviSynth Scripts\VTS_03_1.d2v") # <-----Set path

########## cut off some of the black bars for faster processing (but keep mod 16)
Crop(0,96,0,-96,align=true)

########## black level/gamma, hue
Levels(10,1.08,255,0,255).Tweak(hue=-3)

########## de-ring
pm = last
h4 = pm.RemoveGrain(4,-1)
Median1(pm,  MT_Convolution(horizontal="1",vertical="  0 0 0 1 0 .1 -.1"  ,chroma="copy first"),h4,Chroma="copy first")
Median1(last,MT_Convolution(horizontal="1",vertical="0 0 0 0 1 0 0 .1 -.1",chroma="copy first"),h4,Chroma="copy first")
Contra(last,pm)

########## global motion stabilization
orig = last
temp = orig.TemporalSoften(3,255,255,25,2)
int  = Interleave(temp.Repair(orig),orig)
DePan(int,data=DePanEstimate(int,trust=0,dxmax=1,dymax=0),offset=-1)
SelectEvery(2,0)

episode==5 ? last.Trim(0,92103)++orig.Trim(92104,93601)++last.Trim(93602,0) : last

########## local motion stabilization/degrain stage
source  = last
sigma   = 5
fft     = source.FFT3dFilter(sigma=sigma,sigma2=sigma*.75,sigma3=sigma*.5,sigma4=sigma*.25)

fft.Clense(grey=true)
filt    = Contra(last.Repair(fft,2,-1),last).MergeChroma(source)

idx1    = filt.MSuper(pel=2,sharp=1)
bw_vec1 = MAnalyse(idx1,isb=true, delta=1,overlap=4,plevel=0,dct=1)
fw_vec1 = MAnalyse(idx1,isb=false,delta=1,overlap=4,plevel=0,dct=1)

idx2    = source.MSuper(pel=2,sharp=1,levels=1,chroma=false)
pcorr   = source.MDegrain1(idx2,bw_vec1,fw_vec1,thSAD=800,thSCD1=150,thSCD2=75,plane=0)
corr1   = Median1(source,pcorr,filt,chroma="copy first")

idx3    = corr1.MSuper(pel=2,sharp=1,levels=1,chroma=false)
corr1.MDegrain1(idx3,bw_vec1,fw_vec1,thSAD=400,thSCD1=150,thSCD2=75,plane=0)

Median1(corr1,last,filt,chroma="copy first")

Contra(last,source)

########## restore stars
prest = last
prest.MT_Binarize(threshold=20,upper=true,chroma="copy first").MT_Expand(chroma="copy first")
MT_Merge(prest,source,last,chroma="copy first")

########## additional "Lucasfilm" and "Along time ago..." stabilization
prest.Trim(0,265)++prest.Trim(266,687).TemporalSoften(3,255,255,25,2)++last.Trim(688,0)

########## anti-alias
NNEDI2(dh=true, field=0)
NNEDI2(dh=false,field=1)

########## resize to 16x9 AR, remove sides, add borders
Spline16Resize(728,388).Crop(8,10,-4,-14,align=true).AddBorders(2,58,2,58)

########## subtitle
episode==4 ? ANH(last) : episode==6 ? ROTJ(last) : last

#######################################################################################
Function ANH(clip input)
{input

f     = "Franklin Gothic Medium Cond"
f_col = $EEEEEE
f_wid = 9
f_pos = 464
f_siz = 36

Subtitle ("Going somewhere, Solo?",
\ -1,f_pos,70663,70698,f,f_siz,f_col,font_width=f_wid)
Subtitle ("It’s too late. You should have paid him when you had the chance.",
\ -1,f_pos,70825,70931,f,f_siz,f_col,font_width=f_wid)
Subtitle ("Jabba’s put a price on your head so large...",
\ -1,f_pos,70940,71005,f,f_siz,f_col,font_width=f_wid)
Subtitle ("...every bounty hunter in the galaxy will be looking for you.",
\ -1,f_pos,71014,71088,f,f_siz,f_col,font_width=f_wid)
Subtitle ("I’m lucky I found you first.",
\ -1,f_pos,71098,71137,f,f_siz,f_col,font_width=f_wid)
Subtitle ("If you give it to me, I might forget I found you.",
\ -1,f_pos,71203,71282,f,f_siz,f_col,font_width=f_wid)
Subtitle ("Jabba’s through with you.",
\ -1,f_pos,71365,71406,f,f_siz,f_col,font_width=f_wid)
Subtitle ("He has no time for smugglers...",
\ -1,f_pos,71435,71489,f,f_siz,f_col,font_width=f_wid)
Subtitle ("...who drop their shipments at the first sign of an Imperial cruiser.",
\ -1,f_pos,71498,71595,f,f_siz,f_col,font_width=f_wid)
Subtitle ("You can tell that to Jabba. He may only take your ship.",
\ -1,f_pos,71656,71748,f,f_siz,f_col,font_width=f_wid)
Subtitle ("That’s the idea.",
\ -1,f_pos,71806,71833,f,f_siz,f_col,font_width=f_wid)
Subtitle ("I’ve been looking forward to this for a long time.",
\ -1,f_pos,71843,71931,f,f_siz,f_col,font_width=f_wid)

Return(last)
}

#######################################################################################
Function Contra(clip denoised, clip orig)
{# re-write of Didée's contra sharpening routine from TemporalDegrain.avs

rg12d = MT_MakeDiff(denoised,denoised.RemoveGrain(12,-1))
rg12d.Repair(MT_MakeDiff(orig,denoised),9,-1).MT_LUTxy(rg12d,"x 128 - abs y 128 - abs < x y ?")

denoised.MT_AddDiff(last,chroma="copy first")

Return(last)
}

#######################################################################################
Function Median1(clip input_1, clip input_2, clip input_3, string "chroma")
{# median of 3 clips from Helpers.avs by G-force

chroma = Default(chroma,"process") #default is "process". Alternates: "copy first" or "copy second"

Interleave(input_1,input_2,input_3)
chroma == "process" ? Clense(reduceflicker=false) : Clense(reduceflicker=false,grey=true)
SelectEvery(3,1)

chroma == "copy first" ? last.MergeChroma(input_1) : chroma == "copy second" ? last.MergeChroma(input_2) : last

Return(last)
}

#######################################################################################
########################## GOUT Filter By G-force V.15.01 ESB #########################
#######################################################################################

########## setup
Mpeg2Source("C:\Documents and Settings\Owner\Desktop\AviSynth Scripts\VTS_ESB.d2v") # <-----Set path

########## cut off some of the black bars for faster processing (but keep mod 16)
Crop(0,96,0,-96,align=true)

########## black level/gamma, hue
Levels(10,1.08,255,0,255).Tweak(hue=-3)

########## de-ring
drng = last.MT_Convolution(horizontal="1",vertical="-.085 .165 -.185 1 -.185 .165 -.085",chroma="copy first")
drng.MT_Convolution(horizontal="1",vertical="-.1 1 -.1",chroma="copy first")
drng.Trim(0,687)++last.Trim(688,2801)++drng.Trim(2802,0)

########## global motion stabilization
orig = last
temp = orig.TemporalSoften(3,255,255,25,2)
int  = Interleave(temp.Repair(orig),orig)
DePan(int,data=DePanEstimate(int,trust=0,dxmax=1,dymax=0),offset=-1)
SelectEvery(2,0)

last.Trim(0,92103)++orig.Trim(92104,93601)++last.Trim(93602,0)

########## local motion stabilization/degrain stage
source  = last
fft     = source.FFT3dFilter(sigma=5,plane=4)

fft.Clense()
filt    = Contra(last.Repair(fft),last)

idx1    = filt.MSuper(pel=2,sharp=1)
bw_vec1 = MAnalyse(idx1,isb=true, delta=1,overlap=4,plevel=0,dct=1)
fw_vec1 = MAnalyse(idx1,isb=false,delta=1,overlap=4,plevel=0,dct=1)

idx2    = source.MSuper(pel=2,sharp=1,levels=1)
pcorr   = source.MDegrain1(idx2,bw_vec1,fw_vec1,thSAD=800,thSCD1=150,thSCD2=75)
corr1   = Median1(source,pcorr,filt,chroma="process")

idx3    = corr1.MSuper(pel=2,sharp=1,levels=1)
corr1.MDegrain1(idx3,bw_vec1,fw_vec1,thSAD=400,thSCD1=150,thSCD2=75)

Median1(corr1,last,filt,chroma="process")

Contra(last,source)

########## restore stars
prest = last
prest.MT_Binarize(threshold=20,upper=true,chroma="copy first").MT_Expand(chroma="copy first")
MT_Merge(prest,source,last,chroma="copy first")

########## additional "Lucasfilm" and "Along time ago..." stabilization
prest.Trim(0,265)++prest.Trim(266,687).TemporalSoften(3,255,255,25,2)++last.Trim(688,0)

########## anti-alias
NNEDI2(dh=true, field=0)
NNEDI2(dh=false,field=1)

########## resize to 16x9 AR, remove sides, add borders
Spline16Resize(728,388).Crop(8,14,-6,-10,align=true).AddBorders(3,58,3,58)

 


#######################################################################################
Function Contra(clip denoised, clip orig)
{# re-write of Didée's contra sharpening routine from TemporalDegrain.avs

MT_MakeDiff(denoised,denoised.RemoveGrain(12,-1)).Repair(MT_MakeDiff(orig,denoised),9,-1)

denoised.MT_AddDiff(last,chroma="copy first")

Return(last)
}

#######################################################################################
Function Median1(clip input_1, clip input_2, clip input_3, string "chroma")
{# median of 3 clips from Helpers.avs by G-force

chroma = Default(chroma,"process") #default is "process". Alternates: "copy first" or "copy second"

Interleave(input_1,input_2,input_3)
chroma == "process" ? Clense(reduceflicker=false) : Clense(reduceflicker=false,grey=true)
SelectEvery(3,1)

chroma == "copy first" ? last.MergeChroma(input_1) : chroma == "copy second" ? last.MergeChroma(input_2) : last

Return(last)

#######################################################################################
################### GOUT Filter By G-force V.15.03 PAL ROTJ to NTSC ###################
#######################################################################################

########## setup
Mpeg2Source("C:\Users\Garica\Desktop\VTS_01_1.d2v") # <-----Set path

########## change framereate (PAL to NTSC)
AssumeFPS(24000,1001)

########## cut off some of the black bars for faster processing (but keep mod 16)
Crop(0,112,0,-112,align=true).AddBorders(8,0,8,0)

########## black level/gamma, hue
Levels(10,1.08,255,0,255).Tweak(hue=-3)

########## global motion stabilization
orig = last
temp = orig.TemporalSoften(3,255,255,25,2)
int  = Interleave(temp.Repair(orig),orig)
DePan(int,data=DePanEstimate(int,trust=0,dxmax=1,dymax=0),offset=-1)
SelectEvery(2,0)

last.Trim(0,92103)++orig.Trim(92104,93601)++last.Trim(93602,0)

########## local motion stabilization/degrain stage
source  = last
fft     = source.FFT3dFilter(sigma=5,plane=4)

fft.Clense()
filt    = Contra(last.Repair(fft),last)

idx1    = filt.MSuper(pel=2,sharp=1)
bw_vec1 = MAnalyse(idx1,isb=true, delta=1,overlap=4,plevel=0,dct=1)
fw_vec1 = MAnalyse(idx1,isb=false,delta=1,overlap=4,plevel=0,dct=1)

idx2    = source.MSuper(pel=2,sharp=1,levels=1)
pcorr   = source.MDegrain1(idx2,bw_vec1,fw_vec1,thSAD=800,thSCD1=150,thSCD2=75)
corr1   = Median1(source,pcorr,filt,chroma="process")

idx3    = corr1.MSuper(pel=2,sharp=1,levels=1)
corr1.MDegrain1(idx3,bw_vec1,fw_vec1,thSAD=400,thSCD1=150,thSCD2=75)

Median1(corr1,last,filt,chroma="process")

Contra(last,source)

########## restore stars
prest = last
prest.MT_Binarize(threshold=20,upper=true,chroma="copy first").MT_Expand(chroma="copy first")
MT_Merge(prest,source,last,chroma="copy first")

########## additional "Lucasfilm" and "Along time ago..." stabilization
prest.Trim(0,265)++prest.Trim(266,687).TemporalSoften(3,255,255,25,2)++last.Trim(688,0)

########## anti-alias
NNEDI2(dh=true, field=0)
NNEDI2(dh=false,field=1)

########## resize to 16x9 AR, remove sides, add borders
Spline16Resize(744,396).Crop(18,16,-12,-16,align=true).AddBorders(3,58,3,58)

########## subtitle
f     = "Franklin Gothic Medium Cond"
f_col = $EEEEEE
f_wid = 9
f_pos = 465
f_siz = 36

Subtitle ("There will be no bargain.",
\ -1,f_pos,14382,14476,f,f_siz,f_col,font_width=f_wid)
Subtitle ("I will not give up my favorite decoration.",
\ -1,f_pos,14538,14706,f,f_siz,f_col,font_width=f_wid)
Subtitle ("I like Captain Solo where he is.",
\ -1,f_pos,14741,14824,f,f_siz,f_col,font_width=f_wid)
Subtitle ("I have come for the bounty on this Wookiee.",
\ -1,f_pos,20524,20626,f,f_siz,f_col,font_width=f_wid)
Subtitle ("At last we have the mighty Chewbacca.",
\ -1,f_pos,20774,20886,f,f_siz,f_col,font_width=f_wid)
Subtitle ("I want fifty thousand. No less.",
\ -1,f_pos,21502,21553,f,f_siz,f_col,font_width=f_wid)
Subtitle ("This bounty hunter is my kind of scum...",
\ -1,f_pos,22554,22663,f,f_siz,f_col,font_width=f_wid)
Subtitle ("...fearless and inventive.",
\ -1,f_pos,22685,22753,f,f_siz,f_col,font_width=f_wid)
Subtitle ("It's too late for that, Solo.",
\ -1,f_pos,28765,28856,f,f_siz,f_col,font_width=f_wid)
Subtitle ("You may have been a good smuggler...",
\ -1,f_pos,28857,28972,f,f_siz,f_col,font_width=f_wid)
Subtitle ("...but now you're Bantha fodder.",
\ -1,f_pos,28973,29058,f,f_siz,f_col,font_width=f_wid)
Subtitle ("Take him away.",
\ -1,f_pos,29224,29273,f,f_siz,f_col,font_width=f_wid)
Subtitle ("Bring her to me.",
\ -1,f_pos,29449,29503,f,f_siz,f_col,font_width=f_wid)
Subtitle ("I'm sure.",
\ -1,f_pos,29750,29796,f,f_siz,f_col,font_width=f_wid)
Subtitle ("I told you not to admit him.",
\ -1,f_pos,33466,33568,f,f_siz,f_col,font_width=f_wid)
Subtitle ("He must be allowed to speak.",
\ -1,f_pos,33615,33684,f,f_siz,f_col,font_width=f_wid)
Subtitle ("You weak-minded fool!",
\ -1,f_pos,33703,33774,f,f_siz,f_col,font_width=f_wid)
Subtitle ("He's using an old Jedi mind trick.",
\ -1,f_pos,33821,33927,f,f_siz,f_col,font_width=f_wid)
Subtitle ("Your mind powers will not work on me, boy.",
\ -1,f_pos,34154,34280,f,f_siz,f_col,font_width=f_wid)
Subtitle ("There will be no bargain, young Jedi.",
\ -1,f_pos,34685,34795,f,f_siz,f_col,font_width=f_wid)
Subtitle ("I shall enjoy watching you die.",
\ -1,f_pos,34824,34910,f,f_siz,f_col,font_width=f_wid)
Subtitle ("Bring me Solo and the Wookiee.",
\ -1,f_pos,39727,39816,f,f_siz,f_col,font_width=f_wid)
Subtitle ("They will all suffer for this outrage.",
\ -1,f_pos,39817,39920,f,f_siz,f_col,font_width=f_wid)
Subtitle ("Soon you will learn to appreciate me.",
\ -1,f_pos,43151,43304,f,f_siz,f_col,font_width=f_wid)
Subtitle ("Move him into position.",
\ -1,f_pos,45220,45288,f,f_siz,f_col,font_width=f_wid)
Subtitle ("Put him in.",
\ -1,f_pos,45866,45922,f,f_siz,f_col,font_width=f_wid)


#######################################################################################
Function Contra(clip denoised, clip orig)
{# re-write of Didée's contra sharpening routine from TemporalDegrain.avs

MT_MakeDiff(denoised,denoised.RemoveGrain(12,-1)).Repair(MT_MakeDiff(orig,denoised),9,-1)

denoised.MT_AddDiff(last,chroma="copy first")

Return(last)
}

#######################################################################################
Function Median1(clip input_1, clip input_2, clip input_3, string "chroma")
{# median of 3 clips from Helpers.avs by G-force

chroma = Default(chroma,"process") #default is "process". Alternates: "copy first" or "copy second"

Interleave(input_1,input_2,input_3)
chroma == "process" ? Clense(reduceflicker=false) : Clense(reduceflicker=false,grey=true)
SelectEvery(3,1)

chroma == "copy first" ? last.MergeChroma(input_1) : chroma == "copy second" ? last.MergeChroma(input_2) : last

Return(last)
}