DrawLines


Author V. C. Mohan
Date Sep 14, 2005

A clearly demarcated area as a mask is needed for coloring. While several methods like edge detectors, grey value mappers etc can be used to generate such masks, often these do not descriminate fully (the original greyscale values being same for different objects that need to be separated). In such cases manual intervention is the only recourse, to prevent color leakage.

DrawLines as the name implies draws lines on a frame (the mask or a blank) which can be used by Inlay function as a second reference or if drawn on mask clip prevent ColorDrops, ColorBrush and ColorLine from crossing over the line.

If 'brush' = true, a 3 pixel wide line is drawn, otherwise a single pixel wide line is drawn.
The line coordinates are an array of x and y values. The points are joined by straight lines unless curve is required. For curved line consequtive 3 points are considered and they must have either all ascending x values or all ascending y values or all descending x values or all descending y values. The angle between the included (cords) line segments of curve should not be less than 120.

Coordinates can be translated and / or rotated within the range of start and end frames by specifying the total movement of x at left and right of frame and similarly for y at top and bottom of frame. If all these values are zero no movement occurs. If lx = rx then only translation along x axis.if lx = -rx only rotation along x axis takes place. If ty = by only translatory movement along y axis occurs. If ty = - by only rotation takes place. Otherwise a combination of these takes place. In case of curved lines it may be possible that the condition of all ascending or descending condition may not be fulfilled for some sets due to the rotation. Gaps may then result as such points will be skipped.


For "curve" atleast 3 pairs of coordinates must be input. All points are joined by one continuous line.
For "join" at least 2 coordinate pairs to be input. In this option all the points are joined one after other as straight line segments.
In "diff" option an even number of coordinate pairs must be input. Here pair of points are treated as a seperate line. eg:(x1y1--X2Y2), (X3Y3--X4Y4) etc are joined but not (X2Y2 X3Y3) etc

RGB32, RGB24, YUY2 and YV12 formats only are supported


Details of parameters
Description Name Type Limits Default
Input clip on which lines are to be drawn clip none
Starting frame number to process integer within clip none
End frame number to process integer within clip and not less than start frame none
Array of sets, each set having one X and one Y coordinate
first value of set: x coordinate of point integer within frame none
second value of set: y coordinate of point integer within frame none
type of line line string "curve" "diff" "join" "join"
grey value of line lval integer 0 t0 255 128
3 pixel brush or i pixel wide pencil? brush boolean true for brush or false for pencil false
Change in x at left by end frame lx integer 0 to frame width-1 0
change in x on right by end frame rx integer 0 to frame width lx
Change in y on top by end frame ty integer 0 to frame height 0
change in bottom y by end frame by integer 0 to frame height ty

Usage examples:-
B=blankclip(color=0)
# single line joined by straight lines, white, single pixel wide
cl=drawlines(B,0,50,0,220,40,240,120,240,150,230,180,210,210,210,260,140,280,110,300,80,350,90,500,94,560,100,650,80,719,80)
# curved lines 3 pixel wide
cl=drawlines(B,0,50,0,220,40,240,120,240,150,230,180,210,210,210,line="curve",brush=true)
# line joined by straight lines with both translatory and rotational movement linearly varying between frames 12 and 24
cl=drawlines(B,12,24,0,420,40,240,120,240,150,230,180,210,210,210,260,140,280,110,700,80 ,lx=60,rx=-80,ty=-120,by=100)

In the following example, a suitable mask demarcating land and the water could not be got with MaskMaker. So using drawlines, land area was separated.Colordrops could be safely used as in exaample.

dlmsk2 = drawlines(msk2,0,19,158,414,200,398,240,390,350,387)
cd2 = colordrops(cb,dlmsk2,0,19,200,380,$2f0f07,200,400,$3f68,350,350,$3f66)
stackhorizontal(dlmsk2.grid(), cd2)



To Colorit Synopsis
To my index page
down load plugin
To Avisynth