This module provides functions making masks on an image.
The Polygon class provides checking if a point is inside a polygon.
The whole module uses the (row, col) (i.e., (y, x))) convention for 2D coordinates.
Generates coordinate of image points lying in a disk.
Parameters: |
|
---|---|
Returns: | Array coordinates of points inside the disk (might be negative) |
Return type: | 2-tuple of numpy.ndarray (rows, cols) |
line(row0, col0, row1, col1) -> tuple
Line includes both end points. Width is handled by drawing parallel lines, so junctions of lines belonging to different octant with width > 1 will not look nice.
Using Bresenham line algorithm: Bresenham, J. E. Algorithm for computer control of a digital plotter. IBM Systems Journal. Vol 4 No 1. 1965. pp 25-30
Parameters: |
|
---|---|
Returns: | Array coordinates of points inside the line (might be negative) |
Return type: | 2-tuple of numpy.ndarray (rows, cols) |
Return a mask of boolean, True for pixels inside a polygon.
Parameters: |
|
---|---|
Returns: | Mask corresponding to the polygon |
Return type: | numpy.ndarray of dimension shape |
Define a polygon that provides inside check and mask generation.
Parameters: | vertices (Nx2 array of floats of (row, col)) – corners of the polygon |
---|
Check if (row, col) is inside or outside the polygon
Parameters: |
|
---|---|
Returns: | True if position is inside polygon, False otherwise |
Create a mask array representing the filled polygon
Parameters: |
|
---|---|
Returns: | 2D array (height, width) |