Skip to main content

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.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

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

Uploaded Source

Built Distribution

cmask2polygons-1.1.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cmask2polygons-1.1.2.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

Hashes for cmask2polygons-1.1.2.tar.gz
Algorithm Hash digest
SHA256 0e27052e16cc7d736ea55379ab0b101ee2dd603e01b10ecc724eea2012c3413f
MD5 0fd7c4678283db44b11b478c7ce24619
BLAKE2b-256 f880a2606b151a1dc70219ea1fede70f7d1c581f2e6fe4cf10c70f36ebca1a64

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cmask2polygons-1.1.2-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

Hashes for cmask2polygons-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8d3ae90cfdc7c992bb30573f724b035afedd7f5d1689481e1764591020921707
MD5 0aae0ec0acec5c403aab4d95df09c011
BLAKE2b-256 80b22aadb6ca83f4b9f7c42e244bd5b586911e2ea49c0e1eba36ac708d21398a

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