cmapy
Use Matplotlib colormaps with OpenCV in Python.
Matplotlib provides a lot of nice colormaps. Cmapy exposes these colormaps as lists of colors that can be used with OpenCV to colorize images or for other drawing tasks in Python.
| Original image | |||
|---|---|---|---|
| viridis |
See all of the available colormaps as of Matplotlib 2.2.3 in this all colormaps example.
Requirements
- Python 2.7 or 3.
- Matplotlib.
- OpenCV >= 3.3.0 (to use cv2.applyColorMap()).
Installation
Python 2.7, with pip:
pip install cmapy
Python 3.x, with pip:
pip3 install cmapy
Or, in a Conda environment:
conda install -c conda-forge cmapy
How to use
Colorize images
Colorize means to apply a colormap to an image. This is done by getting the colormap with cmapy.cmap() and then applying cv2.applyColorMap(), like this:
img_colorized = cv2.applyColorMap(img, cmapy.cmap('viridis'))
Alternatively, you can use cmapy.colorize() directly:
img_colorized = cmapy.colorize(img, 'viridis')
See the full colorize example.
Draw with colors
Use the cmapy.color() function and an index between 0 and 255 to get a color from a colormap. Cmapy.color() returns a list of BGR (or RGB) values that can be used with OpenCV drawing functions.
# Get color in BGR order (default) by index.
bgr_color = cmapy.color('viridis', 127)
# Get color in RGB order with a float value.
rgb_color = cmapy.color('viridis', 0.5, rgb_order=True)
See a complete drawing with colors example.
Metadata
Release files for cmapy 0.6.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cmapy-0.6.6.tar.gz | 4.2 kB | Without provenance | Details for cmapy-0.6.6.tar.gz |
Release files / cmapy-0.6.6.tar.gz
| Download URL | cmapy-0.6.6.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb52a6b3057c49a146fb0964b8302f2fb7d61dfe6ae6de1a98b636aace805255
|
|
BLAKE2b-256 checksum How to use checksums |
2547f1d2c686253bea1454cc7db687a09ae912fbe4648a86ef7fcd9765f7639f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/38.6.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.12
|
Security for cmapy 0.6.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.