Skip to main content

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.0
  • epsilon_param: Value for polygon approximating (float). Default is 8e-4
  • pt_type: Data type of points. Default is int
  • add_closept: Append end point (== start point) for representing closed. Default is False



Return

  • Data type: dict
    • Key: Class name (str)
    • Value: list of polygon x (pt_type), y (pt_type) coordinates

Metadata

Release files for cmask2polygons 1.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cmask2polygons 1.1.3
File Size Uploaded
cmask2polygons-1.1.3.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cmask2polygons 1.1.3
File Interpreter ABI Platform
cmask2polygons-1.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 7.0 kB

Release files / cmask2polygons-1.1.3.tar.gz

Download URL cmask2polygons-1.1.3.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1384acbaa3804599b0233a771073ea0e3003634046b4a10c4428cefa3af314fb
BLAKE2b-256 checksum
How to use checksums
a7ae5124ea6a96077cfb2ea75b540d2a30db9d2a6c903e79e9387fb2fe10143a
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / cmask2polygons-1.1.3-py3-none-any.whl

Download URL cmask2polygons-1.1.3-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aad2b888c28c2c1d0bfd5eda1b5f604d502387ebf5131f5cd55f3b93244f1304
BLAKE2b-256 checksum
How to use checksums
5e5fdb5c22b2e41a989fbe2fb31b5d99e5e0d3b63ecd56172def8e08dea12106
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.1.3 This release

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page