draw_line_mask#
- cbclib.bin.draw_line_mask(shape: Tuple[int, Ellipsis], lines: Union[numpy.ndarray, Sequence[numpy.ndarray]], max_val: int = 255, dilation: float = 0.0, profile: str = 'tophat')[source]#
Draw thick lines with variable thickness and the antialiasing applied on a single frame by using the Bresenham’s algorithm [BSH]. The lines must follow the LSD convention, see the parameters for more info.
- Parameters
inp – Input array.
lines (Union[numpy.ndarray, Sequence[numpy.ndarray]]) –
An array of the detected lines. Must have a shape of (N, 7), where N is the number of lines. Each line is comprised of 7 parameters as follows:
[x0, y0], [x1, y1] : The coordinates of the line’s ends.
width : Line’s width.
p : Angle precision [0, 1] given by angle tolerance over 180 degree.
-log10(NFA) : Number of false alarms.
max_val (int) – Maximum pixel value of a drawn line.
dilation (float) – Size of the binary dilation applied to the output array.
profile (str) –
Line width profiles. The following keyword values are allowed:
tophat : Top-hat (rectangular) function profile.
linear : Linear (triangular) function profile.
quad : Quadratic (parabola) function profile.
gauss : Gaussian funtion profile.
- Raises
ValueError – If inp is not a 2-dimensional array.
ValueError – If lines has an incompatible shape.
RuntimeError – If C backend exited with error.
References
- BSH
“Bresenham’s line algorithm.” Wikipedia, Wikimedia Foundation, 20 Sept. 2022, https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm.
- Returns
Output array with the lines drawn.
- Return type
See also
cbclib.bin.LSD: Line Segment Detector.