cmapy


Namecmapy JSON
Version 0.6.6 PyPI version JSON
download
home_pagehttps://gitlab.com/cvejarano-oss/cmapy/
SummaryUse Matplotlib colormaps with OpenCV in Python.
upload_time2020-02-12 11:46:36
maintainer
docs_urlNone
authorCamilo Vejarano
requires_python>=2.7
licenseMIT
keywords colormaps opencv
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # cmapy

Use Matplotlib colormaps with OpenCV in Python.

Matplotlib provides a lot of [nice colormaps](https://matplotlib.org/tutorials/colors/colormaps.html). 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 | ![](https://gitlab.com/cvejarano-oss/cmapy/raw/master/examples/imgs/gradient.png) | ![](https://gitlab.com/cvejarano-oss/cmapy/raw/master/examples/imgs/jupiter.png) | ![](https://gitlab.com/cvejarano-oss/cmapy/raw/master/examples/imgs/woman.png) |
| -- | -- | -- | -- |
|viridis|![](https://gitlab.com/cvejarano-oss/cmapy/raw/master/docs/imgs/gradient_viridis.png)|![](https://gitlab.com/cvejarano-oss/cmapy/raw/master/docs/imgs/jupiter_viridis.png)|![](https://gitlab.com/cvejarano-oss/cmapy/raw/master/docs/imgs/woman_viridis.png)|

See all of the available colormaps as of Matplotlib 2.2.3 in this [all colormaps example](https://gitlab.com/cvejarano-oss/cmapy/blob/master/docs/colorize_all_examples.md).

## Requirements

* Python 2.7 or 3.
* Matplotlib.
* OpenCV >= 3.3.0 (to use cv2.applyColorMap()).

## Installation

Python 2.7, with pip:

```bash
pip install cmapy
```

Python 3.x, with pip:

```bash
pip3 install cmapy
```

Or, in a Conda environment:

```bash
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:

```python
img_colorized = cv2.applyColorMap(img, cmapy.cmap('viridis'))
```

Alternatively, you can use cmapy.colorize() directly:

```python
img_colorized = cmapy.colorize(img, 'viridis')
```

See the full [colorize example](https://gitlab.com/cvejarano-oss/cmapy/blob/master/examples/colorize.py).

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

```python
# 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](https://gitlab.com/cvejarano-oss/cmapy/blob/master/examples/draw_with_colors.py).
            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/cvejarano-oss/cmapy/",
    "name": "cmapy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=2.7",
    "maintainer_email": "",
    "keywords": "colormaps,opencv",
    "author": "Camilo Vejarano",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/25/47/f1d2c686253bea1454cc7db687a09ae912fbe4648a86ef7fcd9765f7639f/cmapy-0.6.6.tar.gz",
    "platform": "",
    "description": "# cmapy\n\nUse Matplotlib colormaps with OpenCV in Python.\n\nMatplotlib provides a lot of [nice colormaps](https://matplotlib.org/tutorials/colors/colormaps.html). Cmapy exposes these colormaps as lists of colors that can be used with OpenCV to colorize images or for other drawing tasks in Python.\n\n| Original image | ![](https://gitlab.com/cvejarano-oss/cmapy/raw/master/examples/imgs/gradient.png) | ![](https://gitlab.com/cvejarano-oss/cmapy/raw/master/examples/imgs/jupiter.png) | ![](https://gitlab.com/cvejarano-oss/cmapy/raw/master/examples/imgs/woman.png) |\n| -- | -- | -- | -- |\n|viridis|![](https://gitlab.com/cvejarano-oss/cmapy/raw/master/docs/imgs/gradient_viridis.png)|![](https://gitlab.com/cvejarano-oss/cmapy/raw/master/docs/imgs/jupiter_viridis.png)|![](https://gitlab.com/cvejarano-oss/cmapy/raw/master/docs/imgs/woman_viridis.png)|\n\nSee all of the available colormaps as of Matplotlib 2.2.3 in this [all colormaps example](https://gitlab.com/cvejarano-oss/cmapy/blob/master/docs/colorize_all_examples.md).\n\n## Requirements\n\n* Python 2.7 or 3.\n* Matplotlib.\n* OpenCV >= 3.3.0 (to use cv2.applyColorMap()).\n\n## Installation\n\nPython 2.7, with pip:\n\n```bash\npip install cmapy\n```\n\nPython 3.x, with pip:\n\n```bash\npip3 install cmapy\n```\n\nOr, in a Conda environment:\n\n```bash\nconda install -c conda-forge cmapy \n```\n\n## How to use\n\n### Colorize images\n\nColorize means to apply a colormap to an image. This is done by getting the colormap\nwith cmapy.cmap() and then applying cv2.applyColorMap(), like this:\n\n```python\nimg_colorized = cv2.applyColorMap(img, cmapy.cmap('viridis'))\n```\n\nAlternatively, you can use cmapy.colorize() directly:\n\n```python\nimg_colorized = cmapy.colorize(img, 'viridis')\n```\n\nSee the full [colorize example](https://gitlab.com/cvejarano-oss/cmapy/blob/master/examples/colorize.py).\n\n### Draw with colors\n\nUse the cmapy.color() function and an index between 0 and 255 to get a color \nfrom a colormap. Cmapy.color() returns a list of BGR (or RGB) values that can be\nused with OpenCV drawing functions.\n\n```python\n# Get color in BGR order (default) by index.\nbgr_color = cmapy.color('viridis', 127)\n\n# Get color in RGB order with a float value.\nrgb_color = cmapy.color('viridis', 0.5, rgb_order=True)\n```\n\nSee a complete [drawing with colors example](https://gitlab.com/cvejarano-oss/cmapy/blob/master/examples/draw_with_colors.py).",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Use Matplotlib colormaps with OpenCV in Python.",
    "version": "0.6.6",
    "project_urls": {
        "Bug Reports": "https://gitlab.com/cvejarano-oss/cmapy/issues/",
        "Homepage": "https://gitlab.com/cvejarano-oss/cmapy/"
    },
    "split_keywords": [
        "colormaps",
        "opencv"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2547f1d2c686253bea1454cc7db687a09ae912fbe4648a86ef7fcd9765f7639f",
                "md5": "c3a4125046b77aac870e675ae0975cd5",
                "sha256": "cb52a6b3057c49a146fb0964b8302f2fb7d61dfe6ae6de1a98b636aace805255"
            },
            "downloads": -1,
            "filename": "cmapy-0.6.6.tar.gz",
            "has_sig": false,
            "md5_digest": "c3a4125046b77aac870e675ae0975cd5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7",
            "size": 4244,
            "upload_time": "2020-02-12T11:46:36",
            "upload_time_iso_8601": "2020-02-12T11:46:36.429699Z",
            "url": "https://files.pythonhosted.org/packages/25/47/f1d2c686253bea1454cc7db687a09ae912fbe4648a86ef7fcd9765f7639f/cmapy-0.6.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-02-12 11:46:36",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "cvejarano-oss",
    "gitlab_project": "cmapy",
    "lcname": "cmapy"
}
        
Elapsed time: 0.21941s