View Full Version : Depanstabilize
lisztfr9
8th October 2012, 14:12
Hi,
I'm still working on my very noisy (and shaky) video :
http://www.mediafire.com/?3ve5vytmnvk1181
First, i wanted to get ride of the jittering that occurs sometime.
I tried with Deshaker from VD, but was unable to prevent the image from "floating" sometimes. I guess i should simply interpolate the culprit frames.
I tried also with depanstabilize, but it fails on scene changes. Also i found that Fluxsmooth is too weak for the heavy noise here, i don't know what to use ? i will try MCTemporalDenoise
==========================
AVISource("H:\DVD\DVD2\temps & chambre_d2v_vfapi.avi").ConvertToYV12()
video=last
AssumeTFF()
SeparateFields()
i = ConvertToYV12()
mdata = DePanEstimate(i, range=1, trust=5.5, log="depan.log")
DePanInterleave(i,data=mdata, prev=1, next=1, matchfields=true)
FluxSmooth_FluxSmoothST(temporal_threshold=10, spatial_threshold=10)
SelectEvery(3, 1)
mdata = DePanEstimate(i)
DePanStabilize(i, data=mdata, dxmax=0, zoommax=0, rotmax=0)
Weave()
#SwapFields()
StackHorizontal(last, video)
W = width()
H = height()
#W=W/2
#H=H/2
LanczosResize(W, H)
Any suggestions ?
Thanks, L
Jenyok
8th October 2012, 15:30
LoadPlugIn("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\DESCRATCH_25_DLL_20050330\descratch.dll")
LoadPlugIn("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\DESPOT_3_6_1\despot.dll")
LoadPlugIn("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\DEPAN_20061128\depanestimate.dll")
LoadPlugIn("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\DEPAN_20061128\depan.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MVTOOLS-V2_5_11_3\mvtools2.dll")
LoadPlugIn("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\FFT3DFILTER_20070220\fft3dfilter.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\MASKTOOLS-V2_0A48\mt_masktools-25.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\DFTTESTV_1_6\dfttest.dll")
LoadPlugin("C:\PROGRAM FILES\AVISYNTH 2.5\PLUGINS\REMOVEGRAINT-1_0\removegraint.dll")
# Constants
#
#par = 1.094 # pixaspect = 1.094 for standard PAL 720x576
par = 1.0 # square pixaspect = 1.000 for standard PAL 768x576
# Constants
# MSuper()
#
blkh = 8
blkv = 8
chroma = true
pel = 4
isse = true
# MAnalyse()
#
overlap = 4
overlapV = 4
# MDepan()
#
range = 2 # = 0
# DepanStabilize()
#
cutoff = 0.1
dxmax = 40 # 4 : 3
dymax = 30 # 4 : 3
rot = true
rotmax = 0.5
mirror = 15
addzoom = true
zoommax = 1.05
prev = 2
next = 2
# Constants
#
ColorWhite = $FFFFFF
# Constants
#
isDebug = false
#isDebug = true
AVISource("05-build_avi_1991_Zelenograd_Frames_Correction_Sharpen 02.avi")
ConvertToYUY2()
# Для отладки фильтров часть 1
#
SourceView = (isDebug == true) ? last.AddBorders(0, 0, 8, 0, Color=ColorWhite) : last
# Глобальная стабилизация изображения часть 1
#
mdata = DePanEstimate(last, \
dxmax = dxmax, \
dymax = dymax, \
improve = true, \
zoommax = zoommax, \
range = range, \
trust = 5.0, \
pixaspect = par)
# function DePanStabilize(clip, clip data, float cutoff, float damping, bool addzoom, \
# int prev, int next, int mirror, int blur, int dxmax, int dymax, \
# float zoommax, float rotmax, int subpixel, float pixaspect, \
# int fitlast, float tzoom, bool info, string inputlog)
#
DepanStabilize(last, \
data = mdata, \
cutoff = cutoff, \
damping = 0.9, \
initzoom = 1.0, \
addzoom = addzoom, \
prev = prev, \
next = next, \
mirror = mirror, \
blur = 50, \
dxmax = dxmax, \
dymax = dymax, \
zoommax = zoommax, \
rotmax = rotmax, \
subpixel = 2, \
pixaspect = par, \
fitlast = 0, \
tzoom = 3.0, \
info = false)
# Глобальная стабилизация изображения часть 2
#
# function FFT3DFilter(clip, float "sigma", float "beta", int "plane", int "bw", int "bh", int "bt", int "ow", int "oh", \
# float "ratio", float "sharpen", float "scutoff", float "svr", float "smin", float "smax", bool "measure", \
# bool "interlaced", int "wintype", int "pframe", int "px", int "py", bool "pshow", float "pcutoff", \
# float "pfactor", float "sigma2", float "sigma3", float "sigma4", float "degrid", float "dehalo", \
# float "hr", float "ht", int "ncpu")
#
prefiltered = FFT3DFilter(last, \
sigma = 3, \
plane = 4, \
bt = 4, \
sharpen = 0.75, \
interlaced = false, \
dehalo = 1.0, \
ncpu = 2)
# function MSuper(clip, int "hpad", int "vpad", int "pel", int "levels", bool "chroma", \
# int "sharp", int "rfilter", clip "pelclip", bool "isse", bool "planar")
#
prefilteredSuper = MSuper(prefiltered, \
hpad = blkh, \
vpad = blkv, \
pel = pel, \
levels = 0, \
chroma = chroma, \
sharp = 2, \
rfilter = 2, \
isse = isse, \
planar = false)
# function MAnalyse(clip super, int "blksize", int "blksizeV", int "level", int "search", int "searchparam", \
# int "pelsearch", bool "isb", int "lambda", bool "chroma", int "delta", bool "truemotion", \
# int "lsad", int "plevel", bool "global", int "pnew", int "pzero", int "pglobal", int "overlap", \
# int "overlapV", string "outfile", int "dct", int "divide", int "sadx264", int "badSAD", \
# int "badrange", bool "isse", int "full", bool "meander", bool "temporal")
#
vectors = MAnalyse(prefilteredSuper, \
blksize = blkh * 2, \
blksizeV = blkv * 2, \
isb = false, \
chroma = chroma, \
delta = 1, \
truemotion = false, \
search = 4, \
searchparam = 6, \
plevel = 0, \
overlap = overlap, \
overlapV = overlapV, \
divide = 0, \
badSAD = 10000, \
isse = isse)
# function MDepan(clip, clip vectors, clip "mask", bool "zoom", bool "rot", float "pixaspect", float "error", bool "info", \
# string "log", float "wrong", float "zerow", int "range", int "thSCD1", int "thSCD2", bool "isse", bool planar)
#
globalmotion = MDepan(prefiltered, \
vectors, \
zoom = addzoom, \
rot = rot, \
pixaspect = par, \
error = 15.0, \
info = false, \
wrong = 10.0, \
zerow = 0.05, \
range = range, \
thSCD1 = 400, \
thSCD2 = 130, \
isse = isse, \
planar = false)
# function DePanStabilize(clip, clip data, float cutoff, float damping, bool addzoom, \
# int prev, int next, int mirror, int blur, int dxmax, int dymax, \
# float zoommax, float rotmax, int subpixel, float pixaspect, \
# int fitlast, float tzoom, bool info, string inputlog)
#
DepanStabilize(last, \
data = globalmotion, \
cutoff = cutoff, \
damping = 0.9, \
initzoom = 1.0, \
addzoom = addzoom, \
prev = prev, \
next = next, \
mirror = mirror, \
blur = 300, \
dxmax = dxmax, \
dymax = dymax, \
zoommax = zoommax, \
rotmax = rotmax, \
subpixel = 2, \
pixaspect = par, \
fitlast = 0, \
tzoom = 3.0, \
info = false)
# Для отладки фильтров часть 2
#
(isDebug == true) ? StackHorizontal(SourceView, last) : last
lisztfr9
8th October 2012, 21:52
I have the feeling that my parameters works slightly better, however the result is not absolutly fixed vertically.
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DePan.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DePanEstimate.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\FluxSmooth.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\deflicker.dll")
AVISource("H:\DVD\DVD2\temps & chambre_d2v_vfapi.avi").ConvertToYV12()
DeFlicker(scene=20, info=false)
# Constants
#
ColorWhite = $FFFFFF
video=last.AddBorders(8, 8, 0, 0, Color=ColorWhite)
last=video
function unshake(last)
{
AssumeTFF()
SeparateFields()
#~ i = ConvertToYV12()
#~ mdata = DePanEstimate(i, range=1, trust=5.5, log="depan.log")
#~ DePanInterleave(i,data=mdata, prev=1, next=1, matchfields=true)
#~ FluxSmooth_FluxSmoothST(temporal_threshold=10, spatial_threshold=10)
#~ SelectEvery(3, 1)
i=last
mdata = DePanEstimate(i, dxmax=0, dymax=4, zoommax=1, trust=0)
DePanStabilize(i, data=mdata, dxmax=0, dymax=4, zoommax=1, rotmax=0)
Weave()
#SwapFields()
return(last)
}
A=Trim(1,112)
B=Trim(112,400).unshake()
C=Trim(401,2085)
A+B+C
StackHorizontal(last, video)
W = width()
H = height()
#W=W/2
#H=H/2
LanczosResize(W, H)
lisztfr9
9th October 2012, 11:18
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DePan.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DePanEstimate.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\FluxSmooth.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\deflicker.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\degrainmedian.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\degrainmedian.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\FFT3DFilter.dll")
AVISource("H:\DVD\DVD2\temps & chambre_d2v_vfapi.avi").ConvertToYUY2()
DeFlicker(scene=20, info=false)
# Constants
#
ColorWhite = $FFFFFF
video=last.AddBorders(8, 8, 0, 0, Color=ColorWhite)
last=video
#denoise =========================================
SeparateFields()
fft3dfilter(sigma=10, bt=5, bw=32, bh=32, ow=16, oh=16, sharpen=0.4)
#DeGrainMedian(limitY=5, limitUV=7, mode=0, interlaced=true)
#DeGrainMedian(limitY=2, limitUV=3, mode=1, interlaced=true)
#DeGrainMedian(limitY=2, limitUV=3, mode=1, interlaced=true)
Weave()
#=================================================
function unshake(last)
{
AssumeTFF()
SeparateFields()
#~ i = ConvertToYV12()
#~ mdata = DePanEstimate(i, range=1, trust=5.5, log="depan.log")
#~ DePanInterleave(i,data=mdata, prev=1, next=1, matchfields=true)
#~ FluxSmooth_FluxSmoothST(temporal_threshold=10, spatial_threshold=10)
#~ SelectEvery(3, 1)
i=last
mdata = DePanEstimate(i, dxmax=0, dymax=5, zoommax=1, trust=0)
DePanStabilize(i, data=mdata, dxmax=0, dymax=5, zoommax=1, rotmax=0)
Weave()
#SwapFields()
return(last)
}
A=Trim(1,112)
B=Trim(112,400).unshake()
C=Trim(401,2085)
A+B+C
StackHorizontal(last, video)
W = width()
H = height()
#W=W/2
#H=H/2
LanczosResize(W, H)#.ConvertToRGB
StainlessS
9th October 2012, 11:45
@lisztfr9
The 'Insert Link' button in bar above text entry box does work OK even though the forum software no longer properly inserts hyperlinks automatically.
Would also be nice if you could wrap your code in CODE tags via the advanced text entry box, its unpleasant reading non formatted code. :)
videoFred
9th October 2012, 12:09
I tried also with depanstabilize, but it fails on scene changes.
Set info=true and then you will see 'Base". this is the scene change detection. "Base" must reset to zero at scene change. If not, lower the trust parameter until you have good scene detection. Use small steps, somewhere between 0.5 and 1.5.
Fred.
lisztfr9
9th October 2012, 14:35
"You will see that 'base' changes to 'BASE!' at scene change"
Nevertheless, after scenes changes sometimes the image goes down for a while, and "recover" slowly. The most secured is to disable depan when not needed....
What cause me troubles is to figure out how to remove theses vertical artifacts here :
http://cjoint.com/12oc/BJjpzaMG92r.htm
I should overlay some transparent png with just some vertical pattern, but building this overlay is puzzling. And then applying it is another story, because it should be applied only on dark backgrounds. The pattern are too large for Descratch too...
Original video :
http://www.mediafire.com/?3ve5vytmnvk1181
Thanks to all, i think i'm going for leaving the vertical patterns, and just removing some shake and noise.
D9JK
4th February 2014, 15:35
I've been using Depanstabilize to deshake my driving videos. I've noticed that the filter often picks up the windscreen wiper motion, although not always. The frame rate value plays a small role too; 60 FPS may pick it up more often, while 30 FPS not so often. Nevertheless, I would like to try to eliminate this completely, but I'm not sure which of the settings might be useful to control this.
So far I've been adjusting the winX/Y and DX/Ymax settings. Cutout I guess can spread the 'dampening' effect over a few seconds, if you go low enough.
bxyhxyh
17th December 2014, 11:00
Since this thread is about depanstabilize I just wanted to ask here.
If i increase range value to 2 or more, will stabilization become better?
foxyshadis
19th December 2014, 05:57
Since this thread is about depanstabilize I just wanted to ask here.
If i increase range value to 2 or more, will stabilization become better?
Just from my experience (I don't use it often), I've found that increasing range leads to a big increase in bad detections if the motion is shaky, like most handheld video, but it can help a little where it's just wobbling around slowly, like in some lousy DVD transfers or where someone's making an effort to hold it still.
bxyhxyh
19th December 2014, 07:14
Just from my experience (I don't use it often), I've found that increasing range leads to a big increase in bad detections if the motion is shaky, like most handheld video, but it can help a little where it's just wobbling around slowly, like in some lousy DVD transfers or where someone's making an effort to hold it still.
Ok thanks.
My source is shaky and grainy.
Is it safe to use denoised clip for estimation and use it on original clip?
like
orig = source()
deg = orig.fft3dfilter(sigma=2,oh=16,ow=16,bt=1).gradfun3(thr=0.5,smode=2)
mdata = deg.DepanEstimate(trust=2.9,dxmax=30,dymax=20)
DepanStabilize(orig,mdata,dxmax=3,dymax=2,mirror=15)
crop(4,2,-4,2)
foxyshadis
19th December 2014, 07:33
Oh yeah, if it's really noisy, it's practically required to denoise it. Can't tell how much is good for you, but just test until it works better. You definitely don't need gradfun for the degrained version, that's a waste of time
Even fft3d is overly slow. FluxSmoothST or HQdn3d should work fine, but of course, if fft3d works for you, go for it.
Taurus
19th December 2014, 08:28
@bxyhxyh
Does the scipt work?
Because their is a typo:
orig = source()
deg = orig.fft3dfilter(sigma=2,oh=16,ow=16,bt=1).gradfun3(thr=0.5,smode=2)
mdata = deg.DepanEstimate(trust=2.9,dxmax=30,dymax=20)
DepanStabilze(orig,mdata,dxmax=3,dymax=2,mirror=15)
crop(4,2,-4,2)
Should be DepanStabilize
bxyhxyh
28th February 2015, 14:32
Hello, again.
I've got a problem reading log file in DepanStabilize function.
I'm using Deshaker's log file tweaking it into DepanEstimate's log format. It throws Avisynth: Access Violation at 0x00008085 in DePan.dll attempting to read from 0x00000000
Same for DepanEstimate's log file. Script is only
DepanStabilize(inputlog="F:\Deshaker.log")
What am I doing wrong?
EDIT: Stuped me. I solved the problem. I just forgot to call mdata clip.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.