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 (
int
), y (int
) 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.0.tar.gz
(3.4 kB
view details)
Built Distribution
File details
Details for the file cmask2polygons-1.1.0.tar.gz
.
File metadata
- Download URL: cmask2polygons-1.1.0.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 | f904742b87bf18feecd761f4d6eb6cb258284caec77a194877a3400133b81241 |
|
MD5 | 1cfed242145c6afbe4f220d4657783b7 |
|
BLAKE2b-256 | 52d17bc84237832c4dc712b2a1957e0ba10129ef5da8ac350d1a0fda0bafe0fa |
File details
Details for the file cmask2polygons-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: cmask2polygons-1.1.0-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 | 588dc71da7123ddf801d4178e9327ff8f6a8d606dda913899c0a331c53e7b69a |
|
MD5 | ebf66b788dfc134a988234bee6ab59e0 |
|
BLAKE2b-256 | 56674a45c4a34c364721042ffab928cc0fcab830bccbda71962e4f0d1f10790c |