Visualizer2
visualizer2
#
Functions:
Name | Description |
---|---|
display_slices |
Display orthogonal slices of a 3D array. |
ImageVisualizer
dataclass
#
Simple visualizer for sitk based images.
Methods:
Name | Description |
---|---|
from_image |
Create an ImageVisualizer from a SimpleITK image. |
from_image_and_mask |
Create an ImageVisualizer with a mask overlay on the image. |
view_grid |
Visualize slices in a grid. |
from_image
classmethod
#
from_image(
image: SimpleITK.Image,
) -> imgtools.vizualize.visualizer2.ImageVisualizer
from_image_and_mask
classmethod
#
from_image_and_mask(
image: SimpleITK.Image,
mask: SimpleITK.Image,
label: int = 1,
as_contour: bool = False,
mask_color: imgtools.vizualize.visualizer2.MaskColor = imgtools.vizualize.visualizer2.MaskColor.GREEN,
opacity: float = 0.5,
background_label: int = 0,
crop_to_bbox: bool = True,
croppad: int = 2,
) -> imgtools.vizualize.visualizer2.ImageVisualizer
Create an ImageVisualizer with a mask overlay on the image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
SimpleITK.Image
|
Base image for visualization |
required |
|
SimpleITK.Image
|
Mask image to overlay on the base image |
required |
|
int
|
Label value in the mask to use for overlay |
1
|
|
bool
|
If True, convert the mask to a contour before overlay |
False
|
|
imgtools.vizualize.visualizer2.MaskColor
|
Color to use for the mask overlay |
MaskColor.GREEN
|
|
float
|
Opacity of the mask overlay (0.0-1.0) |
0.5
|
|
int
|
Label value in the mask to treat as background |
0
|
|
bool
|
If True, crop the image to the bounding box of the mask |
True
|
|
int
|
Padding to add around the crop region |
2
|
Returns:
Type | Description |
---|---|
imgtools.vizualize.visualizer2.ImageVisualizer
|
Instance with the mask overlaid on the image |
Source code in src/imgtools/vizualize/visualizer2.py
view_grid
#
view_grid(
every: int = 1,
fig: matplotlib.pyplot.Figure | None = None,
) -> matplotlib.pyplot.Figure
Visualize slices in a grid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
int
|
Step size for slice selection |
1
|
|
matplotlib.pyplot.Figure
|
Existing figure to use for visualization If None, a new figure will be created |
None
|
Returns:
Type | Description |
---|---|
matplotlib.pyplot.Figure
|
Figure containing the grid of slices |
Source code in src/imgtools/vizualize/visualizer2.py
MaskColor
#
Bases: enum.Enum
Predefined color values for mask overlays.
Each color is represented as an RGB list with values from 0-255. The RGB value specifically contains concatenated R, G, B channels for sitk colormap.
display_slices
#
Display orthogonal slices of a 3D array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
numpy.ndarray
|
3D numpy array representing the image volume |
required |
|
int
|
Index for slice in the x dimension |
required |
|
int
|
Index for slice in the y dimension |
required |
|
int
|
Index for slice in the z dimension |
required |