polyclip¶
- sofia_redux.toolkit.image.fill.polyclip(i, j, pol_x, pol_y, area=False)[source]¶
Clip a polygon to a square unit pixel
Uses the Sutherland-Hodgman polygon clipping algorithm. Pixel centers for pixel (i, j) is at (i + 0.5, j + 0.5).
- Parameters:
- ifloat, int
Pixel x-coordinate
- jfloat, int
Pixel y-coordinate
- pol_xarray_like of float
Polygon x-coordinates (N,)
- pol_yarray_like of float
Polygon y-coordinates (N,)
- areabool, optional
If True, return the area instead of the polygon
- Returns:
- ((list of float), (list of float)) or float
Clipped x and y coordinates of the polygon vertices. If a pixel if fully outside the specified polygon, x=None, y=None is returned. If area is set to True, then the resulting area will be returned as a float.