View Full Version : stab function results (errors) and explanation
Terka
21st June 2010, 13:39
Looked in different threads about deshaker, depan(stabilize), stab.
Speaking about handheld camcorder, know that the shaking could be totaly different.
1. Had anyone compared the results of the 3 above?
2. How does the stab work (logic behind the function)?
Does it average of 7 prev + 7 next frames and moves the current picture to it? I rewrote the stab to be easily readable fo me:
function StabExplained (clip clp, int "ts", int "range", int "dxmax", int "dymax") {
#dxmax=2,ts=3 ok
ts = default(ts, 7)
range = default(range, 3)
dxmax = default(dxmax, 30)
dymax = default(dymax, 30)
ts7 = clp.TemporalSoften(ts,255,255,25,2)
ts1 = clp.TemporalSoften(1,255,255,25,2)
ts71 = ts7.Repair(ts1)
inter = Interleave(ts71,clp) #interleave
#motion data
mdata = DePanEstimate(inter,range=range,pixaspect=1.094, trust=0,dxmax=dxmax,dymax=dymax)
DePan(inter,data=mdata,offset=-1) # -1.0 is full backward motion compensation
SelectEvery(2,0)
}
What about the parameters? Is ts=7 good value? What about the range parameter? Cant see much difference when changing it.
Terka
21st June 2010, 13:56
When tested the stab, it looks like it leaves black borders 1 pixel wide.
Could someone confirm that the border can be wide only 1 pixel?
I wrote a small function to add borders, they could be removed after stab()
function borderresize (clip clp, int "pixels") {
pixels= default (pixels, 2)
x = pixels
mask_border = Blankclip(clp, pixel_type="RGB32").AddBorders(x,x,x,x,$FFFFFF).converttoyv12(matrix="pc.601")
clpborders = clp.AddBorders(x,x,x,x,$FFFFFF)
clpresize = clp.BicubicResize(clp.width()+2*x,clp.height()+2*x)
MaskedMerge(clpresize,clpborders,mask_border.invert())
}
x=2
clp
borderresize(x)
stab()
Crop(x,x,-x,-x)
Gavino
21st June 2010, 14:55
Blankclip(clp).mt_lut("0").Trim(1,1).Loop(Framecount(clp)).converttorgb().AddBorders(x,x,x,x,$FFFFFF).converttoyv12()
The converttoyv12 needs matrix="pc.601" to preserve (0,255).
The whole thing can also be simplified to
Blankclip(clp, pixel_type="RGB32").AddBorders(x,x,x,x,$FFFFFF).converttoyv12(matrix="pc.601")
Terka
21st June 2010, 15:12
Thank you Gavino! This was one more question i wanted to ask - how to simplify this line. And also i was experiencing some mask problems. Thank you!
Terka
21st June 2010, 15:44
after some testing it looks for me that when:
when after some small shaking some bigger motion is present, stab makes the first translation in bigger motion bigger.
like translation values:
1 3 1 3 7
to
2 2 2 2 9
could be tested creating depan or deshaker log, where the values are visible.
Terka
22nd June 2010, 10:49
see the graph where stab has increased the shakiness:
http://ulozto.cz/5165199/stab.jpg
(cant upload it to http://www.imageshack.us/ or similar from my work)
Could someone eplain the behaviour?
markanini
22nd June 2010, 13:34
Thanks for looking into stab for us Terka. I tried stab a while ago and hoping it would be a good 'quick fix' alternative to deshaker but was somewhat underwhelmed. I'll try it again soon and play more with the tr parameter.
Deshaker is really tempermental and you spend a lot of time to finding good settings for each source. Wish I could say something about depan but my scripting skills arent good enough so I rely on others scripts. I know that Videofreds script uses depan, Do you happen to know if it's based on Mvtools2 these days?
Terka
22nd June 2010, 14:10
i know that Videofred has something for deshaking. someone posts here that stab is better. but as you can see in the last graph, stab has 'errors'. but it fills the borders nice.
and IMHO the temporalsoften probably helps to find global motion on different scenes, because it blurs the local motion.
regarding mvtools, ask Videofred or look yourselves, but depan is separate function, not dependent on mvtools. (but the global motion found by mvtools(1/2) could be used by depan.
deshaker is probably the best, but im now fiddling with depan because of 1 pass needed.
now im trying to fill the edges, there is ExInpaint and also Seamer. Maybee they could be usefull.
my idea is first upsize, then stabilize (maybee with filled borders) then crop to original size.
if someone has tried something like this, please post your comments, could be helpful!
poisondeathray
22nd June 2010, 14:14
my idea is first upsize, then stabilize (maybee with filled borders) then crop to original size.
if someone has tried something like this, please post your comments, could be helpful!
one potential problem is you don't know how much to upsize if you scale before stabilizing
Terka
22nd June 2010, 14:15
exists some kind of non-liner resize? like the resize factor will grow with the distance from center?
Terka
22nd June 2010, 14:16
poisondeathray:one potential problem is you don't know how much to upsize if you scale before stabilizing
yuo can set the maximum of dxmax, dymax, see depan doc:
dxmax - limit of horizontal correction, in pixels (default = 60);
dymax - limit of vertical correction, in pixels (default = 30);
you also dont know how much you want to stabilize...
there must be a parameter to tweak...
poisondeathray
22nd June 2010, 14:20
Oh I see. Then what is the advantage for scaling before vs. after?
If you scale before, it will be larger dimensions and take longer for the algorithm to analyze
Terka
22nd June 2010, 14:39
1. dont know yet. (im not zooming, im filling the black borders)
2. depan is 'quite' fast. but yes, you are right.
poisondeathray
22nd June 2010, 14:41
ExInpaint and also Seamer
how are these for edge filling ? I didn't like depan/depanstabilize's mirror or edge fill , but maybe I didn't use it correctly.
Terka
22nd June 2010, 14:55
spatially ok, temporarily awful.
depanstabilize edgefill is not so bad. you prefer deshaker?
videoFred
22nd June 2010, 15:03
but the global motion found by mvtools(1/2) could be used by depan.
Never tought of this... Might be useful... Please test it!
now im trying to fill the edges,
In Depan, mirror=15 fills the edges with a mirrored image. This is better than black edges.
Depan also works the best if dxmax and dymax are the same, both in DepanEstimate() and in DepanStabilize().
Fred.
Terka
22nd June 2010, 15:22
Fred, you use in your processing zoom instead of edges, arent you?
videoFred
22nd June 2010, 16:06
Fred, you use in your processing zoom instead of edges, arent you?
No, I do not use zoom. Zoom is an option in the MVTools Depan. As far as I remember, the zoom option in MVTools does not work at all. So I'm using the stand alone Depan. Also to avoid conflicts because I'm using MVTools for degraining too.
Fred.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.