Skip to main content

Convert Color label mask to Polygons per class

Project description

cmask2polygons

Convert Color label mask to Polygons per class



How to Use

from cmask2polygons import get_polygons_per_class


IMG_PATH = '. . .'
color_mask = cv2.cvtColor(cv2.imread(IMG_PATH), cv2.COLOR_BGR2RGB)
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,
    epsilon_param=8e-4,
)

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



Return

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

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.0.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

cmask2polygons-1.0.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file cmask2polygons-1.0.0.tar.gz.

File metadata

  • Download URL: cmask2polygons-1.0.0.tar.gz
  • Upload date:
  • Size: 3.2 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

Hashes for cmask2polygons-1.0.0.tar.gz
Algorithm Hash digest
SHA256 613fc3227b072ff200b33cd6285b77bb4115006e5f01e6a41e1eea075d98f6da
MD5 02377ea033441b54225ab1031bf6e682
BLAKE2b-256 0ebc672eecf1a0154e8f488ffea321f99f735eab8660991f09318c4a7d7cae96

See more details on using hashes here.

File details

Details for the file cmask2polygons-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: cmask2polygons-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.5 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

Hashes for cmask2polygons-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5439fab14b5cfe6663fd3b32bb4cb996d8085042204243ee96debe2e13490b00
MD5 1bceb5a123f979de7fd12b1b656d5cb2
BLAKE2b-256 2a41376a4a73aa0178fcda2152419fd66f7a2ded07b1c890b1e9e06dcf63a2b5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page