Module iaf.color
Color functions.
Functions
def get_hilo_cmap(n: int = 256) ‑> matplotlib.colors.ListedColormap
-
Return the HiLo colormap that shows pixels at 0 intensity as blue and saturated pixels as red.
Parameters
n
:int
- Number of different colors (optional, default 256). Use 256 for 8-bit images and 65535 for 16-bit images.
Returns
colormap
:ListedColormap
- Colormap to be passed to
imshow()
and other matplotlib functions that take colormaps.
def get_labels_cmap(n: int = 256) ‑> matplotlib.colors.ListedColormap
-
Return a color map that is particularly suited to color-code labels.
Parameters
n
:int
- Number of different colors (optional, default 256). Use 256 for 8-bit images and 65535 for 16-bit images.
Returns
colormap
:ListedColormap
- Colormap to be passed to imshow() and other matplotlib functions that take colormaps.
def to_composite(images: list[numpy.ndarray], colors: list[typing.Union[iaf.color._color.Color, list, tuple]], clip_percentile: float = 0.1) ‑> numpy.ndarray
-
Create a composite image from a series of gray values images and the corresponding colors.
Parameters
images
:list[np.ndarray]
- List of gray-value images.
colors
:list[Union[Color, list, tuple]]
- List of colors to be used to create a composite. One for each image. Each color is a
Color
,list
ortuple
with values for(R, G, B)
between 0.0 and 1.0 clip_percentile
:float
- Percentile to clip intensity in the low and high parts of the dynamic range.
Returns
composite
:np.ndarray
- RGB composite image
def to_rgb(img: numpy.ndarray, color: Union[iaf.color._color.Color, list, tuple], clip_percentile: float = 0.1) ‑> numpy.ndarray
-
Create an RGB image from a single-channel image using a specific color.
Adapted from: https://bioimagebook.github.io/chapters/1-concepts/4-colors/python.html
Parameters
img
:np.ndarray
- 2D image to be displayed.
color
:Color, list
ortuple
- Values for
(R, G, B)
between 0.0 and 1.0 clip_percentile
:float
- Percentile to clip intensity in the low and high parts of the dynamic range.
Returns
rgb
:np.ndarray
- RGB image
Classes
class Color (*args, **kwds)
-
A few predefined colors.
Expand source code
class Color(Enum): """A few predefined colors.""" Red = (1.0, 0.0, 0.0) """Red = (1.0, 0.0, 0.0)""" Green = (0.0, 1.0, 0.0) """Green = (0.0, 1.0, 0.0)""" Blue = (0.0, 0.0, 1.0) """Blue = (0.0, 0.0, 1.0)""" Yellow = (1.0, 1.0, 0.0) """Yellow = (1.0, 1.0, 0.0)""" Cyan = (0.0, 1.0, 1.0) """Cyan = (0.0, 1.0, 1.0)""" Orange = (1.0, 0.5, 0.0) """Orange = (1.0, 0.5, 0.0)""" Gray = (1.0, 1.0, 1.0) """Gray = (1.0, 1.0, 1.0)"""
Ancestors
- enum.Enum
Class variables
var Blue
-
Blue = (0.0, 0.0, 1.0)
var Cyan
-
Cyan = (0.0, 1.0, 1.0)
var Gray
-
Gray = (1.0, 1.0, 1.0)
var Green
-
Green = (0.0, 1.0, 0.0)
var Orange
-
Orange = (1.0, 0.5, 0.0)
var Red
-
Red = (1.0, 0.0, 0.0)
var Yellow
-
Yellow = (1.0, 1.0, 0.0)