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
File details
Details for the file ncolor-1.1.6.tar.gz
.
File metadata
- Download URL: ncolor-1.1.6.tar.gz
- Upload date:
- Size: 114.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74746ffd4376bdff8244e5cf426a48e38d13787577256427ba090ac5a294698a |
|
MD5 | b42517555f0e3dd75c7322fdb2ddf550 |
|
BLAKE2b-256 | 8032b633bd416428a8411749b51bccd449275c33c3134e1928c60e0a179accb5 |