morphogen.viz.png¶
PNG images and colour maps without plotting libraries (used by the GUI and the CLI).
to_rgb turns a 2D array into colours: phase indices with a categorical palette,
real fields with a perceptual colour map (viridis-like); encode_png writes 8-bit RGB
PNG data (zlib, standard library only).
- morphogen.viz.png.PALETTE = array([[236, 236, 230], [ 31, 78, 121], [214, 96, 77], [ 91, 155, 94], [237, 177, 32], [126, 87, 160], [ 77, 175, 214], [140, 86, 75]], dtype=uint8)¶
light background, 1: dark blue…).
- Type:
Colours of the phases 0, 1, 2… (0
- morphogen.viz.png.colormap(values, vmin=None, vmax=None) ndarray[source]¶
RGB (uint8) of real values with a viridis-like map.
- morphogen.viz.png.label_colors(labels) ndarray[source]¶
RGB of integer labels (grains): a pseudo-random colour per label, black for -1.
- morphogen.viz.png.to_rgb(image2d, kind: str = 'auto', vmin=None, vmax=None) ndarray[source]¶
Colours of a 2D array:
phase(palette),labelsorfield(colour map);autopicks phases for small non-negative integers and a colour map otherwise.
- morphogen.viz.png.upscale(rgb: ndarray, factor: int) ndarray[source]¶
Nearest-neighbour enlargement (crisp voxels in small images).
- morphogen.viz.png.encode_png(rgb) bytes[source]¶
PNG bytes of an RGB (h, w, 3) or grey (h, w) uint8 array.
- morphogen.viz.png.decode_png(data: bytes) ndarray[source]¶
RGB array of PNG bytes written by
encode_png()(for tests).