label matrix coloring algorithm
Project description
ncolor
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ncolor-1.1.2.tar.gz
.
File metadata
- Download URL: ncolor-1.1.2.tar.gz
- Upload date:
- Size: 77.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eea0d0e687d1b885bce8d0697cae03f47b6a59852b390d6855a5b8f41a56ee08 |
|
MD5 | 7e57b2692dc97ca6dc366e2e5f1ad400 |
|
BLAKE2b-256 | 19ced6cf88a1c32610ad28d6420309e70d814261c3f60c8fa304f89bb19ca687 |
File details
Details for the file ncolor-1.1.2-py3-none-any.whl
.
File metadata
- Download URL: ncolor-1.1.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b730cd8e79e206e4789ecd91a6ab87fc1ada95388876fb3e5de70de23381dee6 |
|
MD5 | 470754cd5fb3c918204251294dd56e0b |
|
BLAKE2b-256 | 159d7384edd0ba2dbcad55a3a1d4ed7e717201f2d98937558b67a44fcd5a0eef |