Convert Color label mask to Polygons per class
Project description
cmask2polygons
Convert Color label mask to Polygons per class
Install
$ pip install cmask2polygons
How to Use
from cmask2polygons import get_polygons_per_class
color_mask_path = '. . .'
color_mask = cv2.cvtColor(cv2.imread(color_mask_path), cv2.COLOR_BGR2RGB)
# Key:str, Val:tuple
cls_color_map = {
"class_name_1": (125, 125, 125), # RGB Color
"class_name_2": (70, 20, 225),
. . .
}
# Get Polygons from Color Label Mask
polygons_per_class = get_polygons_per_class(
color_mask=color_mask,
cls_color_map=cls_color_map,
min_area=100.0,
epsilon_param=8e-4,
pt_type=int,
add_closept=False,
)
Arguments
color_mask
: RGB Image (numpy.ndarray
)cls_color_map
: Color Value per Class (dict
)min_area
: Minimum area of object (float
). Default is 100.0epsilon_param
: Value for polygon approximating (float
). Default is 8e-4pt_type
: Data type of points. Default isint
add_closept
: Append end point (== start point) for representing closed. Default isFalse
Return
- Data type:
dict
- Key: Class name (
str
) - Value: list of polygon x (
pt_type
), y (pt_type
) coordinates
- Key: Class name (
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cmask2polygons-1.1.1.tar.gz
(3.4 kB
view details)
Built Distribution
File details
Details for the file cmask2polygons-1.1.1.tar.gz
.
File metadata
- Download URL: cmask2polygons-1.1.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07bc8a645054e367aeacd546658df6d20fcd63f4c926ffb871417d8431ba9433 |
|
MD5 | cd547e5344957cc0239e32e8bdfc569f |
|
BLAKE2b-256 | ef029b68f8627a2a4ac2cbf5d74bd93d0cf7b2a47978bb8cfbd2dc8e9355fea1 |
File details
Details for the file cmask2polygons-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: cmask2polygons-1.1.1-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45b62b10212fb851ebd80f7245db8166b56bd523e9dbb7959504ce46bdc7c395 |
|
MD5 | 40d9484769ba56b790e480b1926cbd11 |
|
BLAKE2b-256 | d04bd2735551b18cfcff2fba8f10309b303f119333805b6613d0a0dce445a73b |