π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
Inplace draw convex polygon (#3000)
Irakli Saliaf841e6c1d19f
diff --git a/kornia/utils/draw.py b/kornia/utils/draw.pyindex abaff6e0a..6ad6b0671 100644--- a/kornia/utils/draw.py+++ b/kornia/utils/draw.py@@ -351,5 +351,5 @@ def draw_convex_polygon(images: Tensor, polygons: Union[Tensor, List[Tensor]], cx_left, x_right = _get_convex_edges(polygons, h_i, w_i)ws = torch.arange(w_i, device=device, dtype=dtype_p)[None, None, :]fill_region = (ws >= x_left[..., :, None]) & (ws <= x_right[..., :, None])- images = (~fill_region[:, None]) * images + fill_region[:, None] * colors[..., None, None]+ images.mul_(~fill_region[:, None]).add_(fill_region[:, None] * colors[..., None, None])return images