LabelImage¶
- MLModule¶
author
Florian Link
package
dll
definition
Purpose¶
The LabelImage stores a global label/tag image and allows modification to the image and undo/redo on all modifications.
It offers its API as MLBase output, so that other modules can interact with the label image.
NOTE: Currently the label image is fixed to MLuint8, but this could be extended in the future.
The idea of the LabelImage is that it provides a global store of the label image
and other modules can change the label image as they desire (e.g. paint on it),
while the LabelImage handles the core functionality like undo/redo, drawing a subimage, …
In contrast to DrawVoxels3D, this module allows much more flexibility and
advanced voxel drawing can be implemented in other modules that interact with this module,
e.g. LabelImageThresholdBrush.
Modules for interaction with the label image are:
Modules for drawing on a 2D viewer:
Related modules:
Details¶
Scripting¶
The outLabelInformation output returns a MLLabelInformationCollectionWrapper
object in Python. Access it with:
labelInfo = ctx.field(“LabelImage.outLabelInformation”).object()
The wrapper exposes these methods:
getInfo(label, timepoint=0)- return one label entry as a dict, orNoneif the label is not present.getInfoListForAllTimepoints(label)- return a list ofgetInforesults for all available timepoints.getInfoListForNonEmptyLabels(timepoint=0)- return a list of dicts for all labels withvoxelCount > 0at one timepoint.getInfoListsForNonEmptyLabelsAndAllTimepoints()- return one non-empty-label list per timepoint.getBoundingBox(timepoint=0)- return the combined bounding box for all labels withvoxelCount > 0at one timepoint as((minx, miny, minz), (maxx, maxy, maxz)).getBoundingBoxForAllTimepoints()- return the combined bounding box across all timepoints as((minx, miny, minz), (maxx, maxy, maxz)).mapVoxelToWorld(voxelPosition)- map a voxel position to world coordinates and return[x, y, z]as float values.mapWorldToVoxel(worldPosition)- map world coordinates to voxel coordinates and return[x, y, z]as float values.
For both mapping methods, voxelPosition / worldPosition must provide at least three numeric values.
Tuple/list-like inputs are supported and additional trailing values are ignored.
Malformed inputs (for example too few values or non-numeric coordinates) raise an error.
The returned Python dict from getInfo contains these keys:
label: integer label value.timepoint: integer timepoint index.minPos: list of three integers[xmin, ymin, zmin].maxPos: list of three integers[xmax, ymax, zmax].voxelCount: integer voxel count.
The wrapper is implemented by MLLabelInformationCollectionWrapper.
Example Python usage:¶
# Read non-empty label information for all available timepoints.
label_info = ctx.field("LabelImage.outLabelInformation").object()
all_timepoints = label_info.getInfoListsForNonEmptyLabelsAndAllTimepoints()
for timepoint, entries in enumerate(all_timepoints):
print(f"Timepoint {timepoint}: {len(entries)} non-empty labels")
for info in entries:
label = info["label"]
voxel_count = info["voxelCount"]
min_pos = info["minPos"]
max_pos = info["maxPos"]
print(
f" label={label}, voxels={voxel_count}, "
f"bbox={min_pos}->{max_pos}"
)
Input Fields¶
input0¶
- name: input0, type: Image¶
The input reference image.
inUndoContext¶
- name: inUndoContext, type: UndoContext(MLBase)¶
connect an UndoManager for Undo/Redo
For accessing this object via scripting, see the Scripting Reference:
MLUndoContextWrapper.
Output Fields¶
output0¶
- name: output0, type: Image¶
The label image as global memory image.
outSelf¶
- name: outSelf, type: MLBase¶
Offers the LabelImage C++ API as MLBase object.
Parameter Fields¶
Field Index¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Visible Fields¶
Reset From Input Image¶
- name: resetFromInputImage, type: Trigger¶
Reset with content of input image.
Reset¶
- name: reset, type: Trigger¶
Rest the label image to 0.
Release Image¶
- name: releaseImage, type: Trigger¶
Releases the image, undo history and all other internally stored data. The output image is cleared/invalid after this operation.
Clear Undoable¶
- name: clearUndoable, type: Trigger¶
Clear to 0 (undoable)
Reset Manual Change Tracking¶
- name: resetManualChangeTracking, type: Trigger¶
Resets the change tracking for interpolation.
interactionAboutToStart¶
- name: interactionAboutToStart, type: Trigger¶
interactionFinished¶
- name: interactionFinished, type: Trigger¶
Labels¶
- name: labelsToInterpolate, type: IntegerList, persistent: no¶
Changed Labels¶
- name: changedLabels, type: IntegerList, persistent: no¶
Axis¶
- name: labelsToInterpolateAxis, type: Integer, persistent: no¶
Timepoint¶
- name: labelsToInterpolateTimepoint, type: Integer, default: 0¶
LabelImage DataType¶
- name: selectDataType, type: Enum, default: DATA_TYPE_UINT8¶
Values:
Title |
Name |
|---|---|
Uint8 |
DATA_TYPE_UINT8 |
Uint16 |
DATA_TYPE_UINT16 |
Uint32 |
DATA_TYPE_UINT32 |
Uint64 |
DATA_TYPE_UINT64 |
Input |
DATA_TYPE_INPUT |