Unfurl


Author V. C. Mohan
Sep 4, 2008

This plugin requires libFFTw3f-3.dll or FFTw3.dll to be in the path ( place in windows/system32 folder)

In one of the discussion threads of Doom9 Forum on Avisynth Development, a request for a script using existing functions or a new plugin was aired. The problem was to stitch into a panaroma the frames of a clip discarding overlaps. The clip is a video of a canvas which is being rolled at left end while being unrolled at the right the camera being steady.

This plugin finds out the newly emerged part in each frame and appends to the earlier part. One need to specify the estimated ( average or approximate) shift per frame, minimum shift , maximum shift and number of rows to be used for determining. Using these parameters, actual shift for each frame is determined and one output frame is built.

In case actual shift value (within min and max) could not be found then and only it uses the specified shift value.

Care must be taken that the resulting output is not too long to handle conveniently. No internal limits are placed for this.

This plugin works for RGB, YUY2 and YV12 color spaces. Incase of YUY2 or YV12 values of shifts may be specified as even numbers.

In case of scenes with little greyscale contrasts it may not work very well. In general for such situations RGB yields better results. May need to fine tune parameters.


Details of parameters
Description Name Type Limits Default
Input clip clip short clip none
estimated shift per frame shift integer between 4 and one fourth of width frame width/8
number or rows to use for shift determination nr integer between 8 and frame height frame height/4
minimum shift per frame min integer between 0 and shift shift/2
maximum shift per frame max integer between shift and twice shift one and half times shift

Since input is not readily available the following scheme starting with version(), or colorbars(), or a imagereader 1600 X768 image is used to create it and prove the working of this plugin. Colorbars output is not satisfactory ( length is short. Missed some estimations and used specified shift) due to insufficient grain in the greyscale. RGB also outputs short for the image used. However most of the time by properly tuning the parameters one can get better results.


loadPlugin ("------------\Unfurl.dll")
#colorbars()
version()

stackhorizontal(last,last,last)
# # comment next for colorbars()
stackvertical(last,last,last)
#imagereader("E:\images\canyon.jpg", end = 3)
#imagereader("E:\images\insects.jpg", end = 3)

converttorgb24()
## the following 3 lines if uncommented should producea frame without any shift
#trim(0,10)
#Unfurl(shift = 20, min = 0, max = 40, nr = last.height)
#return (last)

trim(1,1)

#return (last)
c0 = crop(0,0,240,0)
c1 = crop(40,0,240,0)
c2 = crop(70,0,240,0)
c3 = crop(90,0,240,0)
c4 = crop(112,0,240,0)
c5 = crop(140,0,240,0)
c6 = crop(180,0,240,0)
c7 = crop(200,0,240,0)
c8 = crop(240,0,240,0)
c9 = crop(260,0,240,0)
c10 = crop(288,0,240,0)
c11 = crop(320,0,240,0)
c12 = crop(360,0,240,0)
c = c0 + c1 + c2 + c3 + c4 + c5+c6 +c7+c8+c9+c10+c11+c12 #

c20 = crop(400,0,240,0)
c21 = crop(440,0,240,0)
c22 = crop(464,0,240,0)
c23 = crop(490,0,240,0)
c24 = crop(512,0,240,0)
c25 = crop(540,0,240,0)
c26 = crop(580,0,240,0)
c27 = crop(600,0,240,0)
c28 = crop(640,0,240,0)
c29 = crop(660,0,240,0)
c30 = crop(688,0,240,0)
c31 = crop(720,0,240,0)
c32 = crop(760,0,240,0)
 c + c20 + c21  + c22 + c23 + c24 + c25+c26 +c27+c28+c29+c30+c31+c32 
#return (last)	# input canvas roll
Unfurl(shift = 30, min = 20, max = 48)
info()# to check output width

output should have width of 1000
Output for version() as input

output with colorbars

first input frame

output after unfurl

To my index page down load plugin To Avisynth