Visualization
visualization
¶
Functions¶
create_composite(RGB_image, label_image, label_blending_weight=0.5, IDs_to_labels=None, grayscale_RGB_overlay=True)
¶
Create a three-panel composite with an RGB image and a label
Parameters:
Name | Type | Description | Default |
---|---|---|---|
RGB_image |
ndarray
|
(h, w, 3) rgb image to be used directly as one panel |
required |
label_image |
ndarray
|
(h, w) image containing either integer labels or float scalars. Will be colormapped prior to display. |
required |
label_blending_weight |
float
|
Opacity for the label in the blended composite. Defaults to 0.5. |
0.5
|
IDs_to_labels |
Union[None, dict]
|
Mapping from integer IDs to string labels. Used to compute colormap. If None, a continous colormap is used. Defaults to None. |
None
|
grayscale_RGB_overlay |
bool
|
Convert the RGB image to grayscale in the overlay. Default is True. |
True
|
Raises:
Type | Description |
---|---|
ValueError
|
If the RGB image cannot be interpreted as such |
Returns:
Type | Description |
---|---|
np.ndarray: (h, 3*w, 3) horizontally composited image |
Source code in geograypher/utils/visualization.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
create_pv_plotter(off_screen, force_xvfb=False, plotter=None)
¶
Create a pyvista plotter while handling offscreen rendering
Parameters:
Name | Type | Description | Default |
---|---|---|---|
off_screen |
bool
|
Whether the plotter should be offscreen |
required |
force_xvfb |
bool
|
Should XVFB be used for rendering by default. Defaults to False. |
False
|
plotter |
None, pv.Plotter)
|
Existing plotter to use, will just return it if not None. Defaults to None |
None
|
Source code in geograypher/utils/visualization.py
get_vis_options_from_IDs_to_labels(IDs_to_labels, cmap_continous='viridis', cmap_10_classes='tab10', cmap_20_classes='tab20', cmap_many_classes='viridis')
¶
Determine vis options based on a given IDs_to_labels object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
IDs_to_labels |
Union[None, dict]
|
description |
required |
cmap_continous |
str
|
Colormap to use if the values are continous. Defaults to "viridis". |
'viridis'
|
cmap_10_classes |
str
|
Colormap to use if the values are discrete and there are 10 or fewer classes. Defaults to "tab10". |
'tab10'
|
cmap_20_classes |
str
|
Colormap to use if the values are discrete and there are 11-20 classes. Defaults to "tab20". |
'tab20'
|
cmap_many_classes |
str
|
Colormap to use if there are more than 20 classes. Defaults to "viridis". |
'viridis'
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Containing the cmap, vmin/vmax, and whether the colormap is discrete |