upxo.pxtal.fm_steel_3d.hierarchy_colouring module
Colour composites of the FM steel hierarchy.
A composite is a float32 RGB array shaped like the grain label grid plus a trailing axis of 3, painted from coarse to fine so that the finest level present wins:
isolated grains (grains in no PAG), coloured by grain id;
PAGs, one colour each;
blocks, or packets, in the hue of their packet’s habit plane;
optionally sub-blocks, in the same hue.
The hue of a habit plane is taken from the packet colour map. Within a grain the lightness rises with the position of a block among the blocks of its grain, and within a block with the position of a sub-block among the sub-blocks of its block.
A block id has the grain id of its packet as its third underscore-separated field.
- upxo.pxtal.fm_steel_3d.hierarchy_colouring.packet_hues(packet_cmap: str | object = 'tab10') List[float][source]
Hue (0..1) of each habit plane: the packet colour map sampled at 0, 1/3, 2/3 and 1.
- upxo.pxtal.fm_steel_3d.hierarchy_colouring.order_lightness(position: int, count: int) float[source]
Lightness of the
position-th ofcountsiblings: 0.35 for the first up to 0.90 for the last, and 0.60 when there is only one.
- upxo.pxtal.fm_steel_3d.hierarchy_colouring.base_composite(grain_id_map: ndarray, pag_id_map: ndarray, pag_cmap, isolated_cmap) ndarray[source]
Composite of isolated grains and PAGs.
Voxels of a grain in no PAG take
isolated_cmapat the grain id scaled to 0..1; PAGkofntakespag_cmapat(k - 1) / (n - 1). Void stays black.
- upxo.pxtal.fm_steel_3d.hierarchy_colouring.paint_blocks(rgb: ndarray, blocks: dict, grain_to_plane_idx: dict, hues: Sequence[float], grain_to_blocks: dict | None = None) None[source]
Paint each block, in place, in the hue of its packet’s habit plane.
The lightness is 0.60 for every block, or, when
grain_to_blocksis given, graded by the position of the block among the blocks of its grain.
- upxo.pxtal.fm_steel_3d.hierarchy_colouring.paint_subblocks(rgb: ndarray, subblocks: dict, block_to_subblocks: dict, grain_to_plane_idx: dict, hues: Sequence[float]) None[source]
Paint each sub-block, in place, in the hue of its packet’s habit plane with a lightness graded by its position among the sub-blocks of its block.
- upxo.pxtal.fm_steel_3d.hierarchy_colouring.subblock_hue_table(label_to_subblock: Dict[int, str], block_to_subblocks: dict, grain_to_plane_idx: dict, hues: Sequence[float]) ndarray[source]
RGB per sub-block label, as
paint_subblockscolours them.Row
kis the colour of labelk; rows of labels that are unknown or whose sub-block is in no block are black. The table hasmax(label) + 2rows (2 for no labels).
- upxo.pxtal.fm_steel_3d.hierarchy_colouring.block_level_composite(grain_id_map, pag_id_map, blocks, grain_to_plane_idx, grain_to_blocks, pag_cmap, isolated_cmap, packet_cmap='tab10') ndarray[source]
PAG -> block composite:
base_compositewith the blocks painted over it, their lightness graded within each grain.
- upxo.pxtal.fm_steel_3d.hierarchy_colouring.subblock_level_composite(grain_id_map, pag_id_map, blocks, subblocks, block_to_subblocks, grain_to_plane_idx, pag_cmap, isolated_cmap, packet_cmap='tab10') ndarray[source]
PAG -> packet -> sub-block composite:
base_composite, the blocks in the plain hue of their packet, and the sub-blocks over them.