T
- The type of labels assigned to pixelsI
- The pixel type of the backing image. The LabelingMapping
maps sets of labels to index values which can be more compactly
stored.public class ImgLabeling<T,I extends IntegerType<I>> extends AbstractWrappedInterval<RandomAccessibleInterval<I>> implements RandomAccessibleInterval<LabelingType<T>>, IterableInterval<LabelingType<T>>, SubIntervalIterable<LabelingType<T>>
image
of integer
indices.LabelingMapping
sourceInterval
Constructor and Description |
---|
ImgLabeling(RandomAccessibleInterval<I> img) |
Modifier and Type | Method and Description |
---|---|
Cursor<LabelingType<T>> |
cursor()
Returns a
RealCursor that iterates with optimal speed without
calculating the location at each iteration step. |
Cursor<LabelingType<T>> |
cursor(Interval interval)
|
LabelingType<T> |
firstElement()
Get the first element of this
IterableRealInterval . |
static <T,I extends IntegerType<I>> |
fromImageAndLabels(RandomAccessibleInterval<I> img,
List<T> labels)
Creates a non empty ImgLabeling, from an index image and a list of
labels.
|
static <T,I extends IntegerType<I>> |
fromImageAndLabelSets(RandomAccessibleInterval<I> img,
List<Set<T>> labelSets)
Creates a non empty ImgLabeling, from an index image and a list of label
sets.
|
RandomAccessibleInterval<I> |
getIndexImg() |
LabelingMapping<T> |
getMapping() |
Object |
iterationOrder()
Returns the iteration order of this
IterableRealInterval . |
Iterator<LabelingType<T>> |
iterator() |
Cursor<LabelingType<T>> |
localizingCursor()
Returns a
RealLocalizable Iterator that calculates its
location at each iteration step. |
Cursor<LabelingType<T>> |
localizingCursor(Interval interval)
|
RandomAccess<LabelingType<T>> |
randomAccess()
Create a random access sampler for integer coordinates.
|
RandomAccess<LabelingType<T>> |
randomAccess(Interval interval)
Create a random access sampler for integer coordinates.
|
long |
size()
Returns the number of elements in this
Function . |
Object |
subIntervalIterationOrder(Interval interval)
Returns the iteration order given the interval.
|
boolean |
supportsOptimizedCursor(Interval interval)
|
dimension, dimensions, max, max, max, min, min, min
getSource, numDimensions, realMax, realMax, realMax, realMin, realMin, realMin
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAt, getAt, getAt
forEach, spliterator
dimension, max, max, max, maxAsLongArray, maxAsPoint, min, min, min, minAsLongArray, minAsPoint, realMax, realMin
maxAsDoubleArray, maxAsRealPoint, minAsDoubleArray, minAsRealPoint, realMax, realMax, realMin, realMin
allPositive, allPositive, dimensions, dimensions, dimensionsAsLongArray, dimensionsAsPoint, verify, verify, verifyAllPositive, verifyAllPositive
numDimensions
public ImgLabeling(RandomAccessibleInterval<I> img)
public static <T,I extends IntegerType<I>> ImgLabeling<T,I> fromImageAndLabelSets(RandomAccessibleInterval<I> img, List<Set<T>> labelSets)
Each pixel can have multiple labels. If there's only one label per pixel,
see fromImageAndLabels(net.imglib2.RandomAccessibleInterval<I>, java.util.List<T>)
The list of label sets gives the initial mapping between pixel values and labels. The pixel values of the index image must be non negative, and smaller than the size of the list of label sets. The first element of the list of label sets must always be the empty set. Every element in the list must be unique.
A pixel value of i represents a pixel, which has the labels, that are at index i in the list of label sets. A pixel value of 0 always represents a pixel with no labels, because the first entry in the list is always the empty set.
public static <T,I extends IntegerType<I>> ImgLabeling<T,I> fromImageAndLabels(RandomAccessibleInterval<I> img, List<T> labels)
This method does not support intersection labels, for intersecting labels
set see fromImageAndLabelSets(net.imglib2.RandomAccessibleInterval<I>, java.util.List<java.util.Set<T>>)
.
The pixel values of the index image must be between 0 and the length of the list of labels. A pixel value of zero represents a pixel with no label. A pixel value of N represents the label, which is given by the Nth entry in the list of labels.
public LabelingMapping<T> getMapping()
public RandomAccess<LabelingType<T>> randomAccess()
RandomAccessible
The returned random access covers as much of the domain as possible.
Please note:RandomAccessibleInterval
s have a finite domain (their Interval
),
so RandomAccessible.randomAccess()
is only guaranteed to cover this finite domain.
This may lead to unexpected results when using Views
. In
the following code
RandomAccessible<T> extended = Views.extendBorder( img ) RandomAccessibleInterval<T> cropped = Views.interval( extended, img ); RandomAccess<T> a1 = extended.randomAccess(); RandomAccess<T> a2 = cropped.randomAccess();The
access
a1
on the extended image is valid
everywhere. However, somewhat counter-intuitively, the
access
a2
on the extended and cropped image
is only valid on the interval img
to which the extended image was
cropped. The access is only required to cover this interval, because it
is the domain of the cropped image. Views
attempts to provide the
fastest possible access that meets this requirement, and will therefore
strip the extension.
To deal with this, if you know that you need to access pixels outside the
domain of the RandomAccessibleInterval
, and you know that the
RandomAccessibleInterval
is actually defined beyond its interval
boundaries, then use the RandomAccessible.randomAccess(Interval)
variant and
specify which interval you actually want to access. In the above example,
RandomAccess<T> a2 = cropped.randomAccess( Intervals.expand( img, 10 ) );will provide the extended access as expected.
randomAccess
in interface RandomAccessible<LabelingType<T>>
public RandomAccess<LabelingType<T>> randomAccess(Interval interval)
RandomAccessible
The returned random access is intended to be used in the specified
interval only. Thus, the RandomAccessible may provide optimized versions.
If the interval is completely contained in the domain, the random access
is guaranteed to provide the same values as that obtained by
RandomAccessible.randomAccess()
within the interval.
randomAccess
in interface RandomAccessible<LabelingType<T>>
interval
- in which interval you intend to use the random access.public Cursor<LabelingType<T>> cursor()
IterableRealInterval
Returns a RealCursor
that iterates with optimal speed without
calculating the location at each iteration step. Localization is
performed on demand.
Use this where localization is required rarely/ not for each iteration.
cursor
in interface IterableInterval<LabelingType<T>>
cursor
in interface IterableRealInterval<LabelingType<T>>
public Cursor<LabelingType<T>> localizingCursor()
IterableRealInterval
Returns a RealLocalizable
Iterator
that calculates its
location at each iteration step. That is, localization is performed with
optimal speed.
Use this where localization is required often/ for each iteration.
localizingCursor
in interface IterableInterval<LabelingType<T>>
localizingCursor
in interface IterableRealInterval<LabelingType<T>>
public LabelingType<T> firstElement()
IterableRealInterval
IterableRealInterval
. This is a
shortcut for cursor().next()
.
This can be used to create a new variable of type T using
firstElement().createVariable()
, which is useful in generic
methods to store temporary results, e.g., a running sum over pixels in
the IterableRealInterval
.firstElement
in interface IterableRealInterval<LabelingType<T>>
public Iterator<LabelingType<T>> iterator()
iterator
in interface Iterable<LabelingType<T>>
public long size()
IterableRealInterval
Returns the number of elements in this Function
.
size
in interface IterableRealInterval<LabelingType<T>>
public Object iterationOrder()
IterableRealInterval
IterableRealInterval
. If the
returned object equals (Object.equals(Object)
) the iteration
order of another IterableRealInterval
f then they can be
copied by synchronous iteration. That is, having an Iterator
on
this and another Iterator
on f, moving both in synchrony
will point both of them to corresponding locations in their source
domain. In other words, this and f have the same iteration order
and means and the same number of elements.iterationOrder
in interface IterableRealInterval<LabelingType<T>>
IterableRealInterval
.FlatIterationOrder
public boolean supportsOptimizedCursor(Interval interval)
SubIntervalIterable
supportsOptimizedCursor
in interface SubIntervalIterable<LabelingType<T>>
interval
- to be checkedCursor
can be optimized given the
Interval
public Object subIntervalIterationOrder(Interval interval)
SubIntervalIterable
subIntervalIterationOrder
in interface SubIntervalIterable<LabelingType<T>>
interval
- Interval
over which to iterateIterableRealInterval
public Cursor<LabelingType<T>> cursor(Interval interval)
SubIntervalIterable
cursor
in interface SubIntervalIterable<LabelingType<T>>
interval
- Interval
over which to iterateCursor
public Cursor<LabelingType<T>> localizingCursor(Interval interval)
SubIntervalIterable
localizingCursor
in interface SubIntervalIterable<LabelingType<T>>
interval
- Interval
over which to iterateCursor
public RandomAccessibleInterval<I> getIndexImg()
Copyright © 2015–2022 ImgLib2. All rights reserved.