Python/PyTorch 공부
폴리곤을 segmentation mask로 변환하기(Polygon to mask)
AI 꿈나무
2022. 12. 23. 19:19
반응형
폴리곤 좌표로 표현되어 있는 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
반응형