Skip to content

Commit

Permalink
Inplace draw convex polygon (kornia#3000)
Browse files Browse the repository at this point in the history
* inplace draw convex polygon

* linter
  • Loading branch information
Isalia20 authored Aug 28, 2024
1 parent 8a6faa9 commit f841e6c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kornia/utils/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,5 +351,5 @@ def draw_convex_polygon(images: Tensor, polygons: Union[Tensor, List[Tensor]], c
x_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

0 comments on commit f841e6c

Please sign in to comment.