반응형
폴리곤 좌표로 표현되어 있는 mask를 binary mask로 변환하는 방법을 알아보겠다.
구글링 해보니 잘 안나와서 한번 작성해본다.
여러 자료를 찾아봤는데 skimage.draw.polygon2mask 가 제일 편한것 같다.
from skimage.draw import polygon2mask 로 함수를 불러와서
image_shape와 np.array 타입의 polygon을 넣어주면 된다.
https://scikit-image.org/docs/stable/api/skimage.draw.html#skimage.draw.polygon2mask
Module: draw — skimage v0.19.2 docs
The range of values to sample pixel values from. For grayscale images the format is (min, max). For multichannel - ((min, max),) if the ranges are equal across the channels, and ((min_0, max_0), … (min_N, max_N)) if they differ. As the function supports
scikit-image.org
반응형
'Python > PyTorch 공부' 카테고리의 다른 글
segmentation mask 덩어리 갯수 확인하기 (0) | 2022.08.21 |
---|---|
Segmentation mask의 center point 계산하기 (0) | 2022.08.21 |
[PyTorch] CLIP의 text encoder에는 attention mask가 존재합니다. (0) | 2022.08.01 |
[PyTorch] Multi_head_attention에서 target sequence length와 source sequence length 의미 (0) | 2022.07.27 |
[PyTorch] Tensor.retain_grad() (0) | 2022.07.19 |