Class LabelObjects<T>
Object
LabelObjects<T>
- Type Parameters:
T
- element-type, which must be an object-mask or an element containing an object-mask.
Writes a unique ID (successive integer IDs) for each elements's voxels into a channel, and 0 for
background.
An element can be an object-mask or any other class from which an object-mask can be derived.
- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionLabelObjects
(Function<T, ObjectMask> extractObject, BiFunction<T, ReadableTuple3i, T> shiftElement) Creates a newLabelObjects
instance.LabelObjects
(Optional<UnaryOperator<T>> operationBeforeLabelling, Optional<Consumer<OverlappingObject<T>>> overlappingObjectConsumer, Function<T, ObjectMask> extractObject, BiFunction<T, ReadableTuple3i, T> shiftElement) Creates a newLabelObjects
instance. -
Method Summary
Modifier and TypeMethodDescriptioncreateLabelledChannel
(BoundedList<T> elements, Optional<Map<Integer, T>> mapLabels) Creates a channel that contains a unique integer (label) for each element's object-representation.void
Replaces the contents of the channel so that all element's voxels are labelled with successive unique integer identifiers 1,2,3 etc. and voxels in no element are 0.
-
Constructor Details
-
LabelObjects
public LabelObjects(Optional<UnaryOperator<T>> operationBeforeLabelling, Optional<Consumer<OverlappingObject<T>>> overlappingObjectConsumer, Function<T, ObjectMask> extractObject, BiFunction<T, ReadableTuple3i, T> shiftElement) Creates a newLabelObjects
instance.- Parameters:
operationBeforeLabelling
- An operation that is applied after any elements have been added tomapLabels
but before the voxels are written with the labelled intensity valuesoverlappingObjectConsumer
- if set, this is called once with any overlapping object (afteroperationAfterMap is applied
). Otherwise, an exception is thrown if an overlapping object is encountered.extractObject
- Extracts an object-mask representation from an elementshiftElement
- Shifts the element in the positive direction.
-
LabelObjects
public LabelObjects(Function<T, ObjectMask> extractObject, BiFunction<T, ReadableTuple3i, T> shiftElement) Creates a newLabelObjects
instance.- Parameters:
extractObject
- Extracts an object-mask representation from an elementshiftElement
- Shifts the element in the positive direction.
-
-
Method Details
-
createLabelledChannel
public Channel createLabelledChannel(BoundedList<T> elements, Optional<Map<Integer, T>> mapLabels) throws CreateExceptionCreates a channel that contains a unique integer (label) for each element's object-representation.Specifically, a channel is created that is exactly the same-size as the bounding-box around a collection of element, and labels the background with 0, and each element in the list with an incrementing unique integer identifier.
- Parameters:
elements
- the elements to write IDs for and a bounding-box that contains them all.mapLabels
- if set, an entry is added for every labelled element (unscaled) to the label it is assigned.- Returns:
- a channel of the same-size as the containing bounding-box in
elements
and with unique IDs for each element, and 0 for voxels not belonging to any element. - Throws:
CreateException
- if there are more than 255 objects, or if two objects overlap when this cannot handled gracefully.
-
labelElements
public void labelElements(Channel channel, Iterable<T> elements, Optional<Map<Integer, T>> mapLabels) throws CreateExceptionReplaces the contents of the channel so that all element's voxels are labelled with successive unique integer identifiers 1,2,3 etc. and voxels in no element are 0.- Parameters:
channel
- the channel whose voxels will be replacedelements
- the element to write IDs for.mapLabels
- if set, an entry is added for every labelled element (unscaled) to the label it is assigned- Throws:
CreateException
- if there are more than 255 objects, or if two objects overlap (andoverlappingObjectConsumer
is not set).
-