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 isintadd_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.3.tar.gz
(3.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cmask2polygons-1.1.3.tar.gz.
File metadata
- Download URL: cmask2polygons-1.1.3.tar.gz
- Upload date:
- Size: 3.3 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 |
1384acbaa3804599b0233a771073ea0e3003634046b4a10c4428cefa3af314fb
|
|
| MD5 |
e711f33e397f1584eec31236ba494c28
|
|
| BLAKE2b-256 |
a7ae5124ea6a96077cfb2ea75b540d2a30db9d2a6c903e79e9387fb2fe10143a
|
File details
Details for the file cmask2polygons-1.1.3-py3-none-any.whl.
File metadata
- Download URL: cmask2polygons-1.1.3-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 |
aad2b888c28c2c1d0bfd5eda1b5f604d502387ebf5131f5cd55f3b93244f1304
|
|
| MD5 |
a6ec0950508dfcf314b18b4eab28c8bf
|
|
| BLAKE2b-256 |
5e5fdb5c22b2e41a989fbe2fb31b5d99e5e0d3b63ecd56172def8e08dea12106
|