Implementation:Kornia Kornia Colormap Data
| Knowledge Sources | |
|---|---|
| Domains | Vision, Color_Processing |
| Last Updated | 2026-02-09 15:00 GMT |
Overview
This module provides the raw RGB color data for 19 built-in colormaps extracted from matplotlib, each defined as a list of 64 base RGB color triplets.
Description
_colormap_data.py is a data module in the Kornia library's color subpackage. It stores the base color palettes used to construct colormaps for visualizing grayscale or scalar-valued tensors. Each colormap is represented as a function that returns a list of 64 RGB color triplets (each a list of three floats in the range [0, 1]). The colormaps are extracted from matplotlib's standard colormaps. This module serves as the backend data source for the ColorMap and ColorMapType classes defined in colormap.py.
The 19 available colormaps are: autumn, bone, jet, winter, rainbow, ocean, summer, spring, cool, hsv, brg (bgr), pink, hot, plasma, viridis, cividis, twilight, turbo, and seismic.
Usage
Users typically do not import from this module directly. Instead, they use ColorMap or ColorMapType from kornia.color.colormap, which internally loads data from this module. Direct import is useful only when creating custom colormaps or inspecting the raw base color arrays.
Code Reference
Source Location
- Repository: Kornia
- File: kornia/color/_colormap_data.py
- Lines: 1-1337
Signature
RGBColor = List[float]
def get_autumn_base() -> list[RGBColor]: ...
def get_bone_base() -> list[RGBColor]: ...
def get_jet_base() -> list[RGBColor]: ...
def get_winter_base() -> list[RGBColor]: ...
def get_rainbow_base() -> list[RGBColor]: ...
def get_ocean_base() -> list[RGBColor]: ...
def get_summer_base() -> list[RGBColor]: ...
def get_spring_base() -> list[RGBColor]: ...
def get_cool_base() -> list[RGBColor]: ...
def get_hsv_base() -> list[RGBColor]: ...
def get_bgr_base() -> list[RGBColor]: ...
def get_pink_base() -> list[RGBColor]: ...
def get_hot_base() -> list[RGBColor]: ...
def get_plasma_base() -> list[RGBColor]: ...
def get_viridis_base() -> list[RGBColor]: ...
def get_cividis_base() -> list[RGBColor]: ...
def get_twilight_base() -> list[RGBColor]: ...
def get_turbo_base() -> list[RGBColor]: ...
def get_seismic_base() -> list[RGBColor]: ...
Import
from kornia.color._colormap_data import get_viridis_base, RGBColor
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (none) | N/A | N/A | Each function takes no parameters. |
Outputs
| Name | Type | Description |
|---|---|---|
| return | list[RGBColor] (i.e. list[list[float]]) | A list of 64 RGB color triplets, each a list of three floats in the range [0.0, 1.0]. |
Usage Examples
Basic Usage
from kornia.color._colormap_data import get_viridis_base, get_autumn_base
# Retrieve the viridis base colormap (64 RGB triplets)
viridis_colors = get_viridis_base()
print(len(viridis_colors)) # 64
print(viridis_colors[0]) # e.g. [0.267004, 0.004874, 0.329415]
# Retrieve the autumn base colormap
autumn_colors = get_autumn_base()
print(autumn_colors[0]) # [1.0, 0.0, 0.0]
print(autumn_colors[-1]) # [1.0, 1.0, 0.0]