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
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 191 192 193 |
|
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 |
Source code in geograypher/utils/visualization.py
merge_cylinders(starts, ends, community_IDs, cmap, norm)
¶
Create and merge a set of cylinders one by one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ray_starts
|
N, 3) np.ndarray
|
The 3D locations of the starting points of N rays |
required |
ray_ends
|
N, 3) np.ndarray
|
The 3D locations of the ending points of N rays |
required |
community_IDs
|
N,) np.ndarray
|
The IDs for groups of rays. For example, if there are 10 rays with 5 in group 0 and 5 in group 1, this would be [0, 0, 0, 0, 0, 1, 1, 1, 1, 1] |
required |
cmap
|
ListedColormap
|
Colormap to use on the normalized community IDs |
required |
norm
|
Normalize
|
Normalization function that spans from min to max of the community IDs |
required |
Returns: pv.Polydata mesh representing the given rays with cylinders.
Source code in geograypher/utils/visualization.py
show_segmentation_labels(label_folder, image_folder, savefolder=None, num_show=10, label_suffix='.png', image_suffix='.JPG', IDs_to_labels=None)
¶
Visualize and optionally save composite images showing segmentation labels overlaid on their corresponding images.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label_folder
|
PATH_TYPE
|
Path to the folder containing label images. |
required |
image_folder
|
PATH_TYPE
|
Path to the folder containing original images. |
required |
savefolder
|
PATH_TYPE
|
If provided, composites are saved here; otherwise, they are displayed using pyplot. Defaults to None. |
None
|
num_show
|
int
|
Number of samples to show or save. Defaults to 10. |
10
|
label_suffix
|
str
|
Suffix for label image files. Defaults to ".png". |
'.png'
|
image_suffix
|
str
|
Suffix for image files. Defaults to ".JPG". |
'.JPG'
|
IDs_to_labels
|
dict
|
Mapping from label IDs to class names. If None, will attempt to load from label_folder. Defaults to None. |
None
|
Source code in geograypher/utils/visualization.py
visualize_intersections_as_mesh(ray_starts, ray_ends, community_IDs, community_points, out_dir, batch=250, cube_side_len=0.2)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ray_starts
|
N, 3) np.ndarray
|
The 3D locations of the starting points of N rays |
required |
ray_ends
|
N, 3) np.ndarray
|
The 3D locations of the ending points of N rays |
required |
community_IDs
|
N,) np.ndarray
|
The IDs for groups of rays. For example, if there are 10 rays with 5 in group 0 and 5 in group 1, this would be [0, 0, 0, 0, 0, 1, 1, 1, 1, 1] |
required |
community_points
|
M, 3) np.ndarray
|
One 3D point per community, indicating the center of the grouped rays. In the example above, this would be an (2, 3) array with 2 points. |
required |
out_dir
|
PATH_TYPE
|
|
required |
batch
|
int
|
Defaults to 250. |
250
|
cube_side_len
|
float
|
Defaults to 0.2 |
0.2
|
Saves
out_dir / rays.ply out_dir / points.ply
Source code in geograypher/utils/visualization.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
|
visualize_intersections_in_pyvista(plotter, ray_starts, ray_ends, community_IDs, community_points)
¶
Visualize the given grouped rays and detected points in a pyvista plotter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
plotter
|
Plotter
|
Existing pyvista plotter to add intersection lines/points to |
required |
ray_starts
|
N, 3) np.ndarray
|
The 3D locations of the starting points of N rays |
required |
ray_ends
|
N, 3) np.ndarray
|
The 3D locations of the ending points of N rays |
required |
community_IDs
|
N,) np.ndarray
|
The IDs for groups of rays. For example, if there are 10 rays with 5 in group 0 and 5 in group 1, this would be [0, 0, 0, 0, 0, 1, 1, 1, 1, 1] |
required |
community_points
|
M, 3) np.ndarray
|
One 3D point per community, indicating the center of the grouped rays. In the example above, this would be an (2, 3) array with 2 points. |
required |