Skip to main content

label matrix coloring algorithm

Project description

PyPI version Downloads

ncolor bacteria

Fast remapping of instance labels 1,2,3,...,M to a smaller set of repeating, disjoint labels, 1,2,...,N. The four-color-theorem guarantees that at most four colors are required for any 2D segmentation/map, but this algorithm will opt for 5 or 6 to give an acceptable result if it fails to find a 4-color mapping quickly. Also works for 3D labels (<8 colors typically required) and perhaps higher dimensions as well.

Usage

If you have an integer array called masks, you may transform it into an N-color representation as follows:

import ncolor.ncolor as ncolor
ncolor_masks = ncolor.label(masks)

The integer array ncolor_masks can then be visualized using any color map you prefer. The example in this README uses the viridis colormap. See example.ipynb for more details.

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

ncolor-1.1.8.tar.gz (114.9 kB view details)

Uploaded Source

Built Distribution

ncolor-1.1.8-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file ncolor-1.1.8.tar.gz.

File metadata

  • Download URL: ncolor-1.1.8.tar.gz
  • Upload date:
  • Size: 114.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for ncolor-1.1.8.tar.gz
Algorithm Hash digest
SHA256 5aaadef63ac0f60c52a63ad78b99d06db249810efdea82721c73f31365452edf
MD5 ae46aef439a14a59335b7ca4383fb631
BLAKE2b-256 b6c79f7e373669dd8b210a88486af352fb4ed6a231227991fc2400f72398d914

See more details on using hashes here.

File details

Details for the file ncolor-1.1.8-py3-none-any.whl.

File metadata

  • Download URL: ncolor-1.1.8-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for ncolor-1.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 280b1ac0730f3d8864fe61a4103f941a637c19ef858a6558b614e742c05a7416
MD5 7717afd06c276ce858dcff7f8f5d59c3
BLAKE2b-256 5a17ec913cb1060134106ef571fc609d3435db5f8219f3c4f475f9632b2a1d1a

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