T
- the label typepublic class LabelRegion<T> extends PositionableInterval implements PositionableIterableRegion<BoolType>
ImgLabeling
as a
PositionableIterableRegion
. The interval bounds represent the
bounding box of all pixels having the label. If a RandomAccess
is
requested
for an interval not fully contained
in the bounding box, an OutOfBounds
access is created with the value
false for pixels outside the bounding box.currentOffset, initialMax, initialMin
position
n
Modifier | Constructor and Description |
---|---|
protected |
LabelRegion(LabelRegion<T> other)
Copy constructor.
|
|
LabelRegion(LabelRegions<T> regions,
net.imglib2.roi.labeling.LabelRegions.LabelRegionProperties regionProperties,
T label) |
Modifier and Type | Method and Description |
---|---|
LabelRegion<T> |
copy()
Create a copy of this
LabelRegion . |
LabelRegionCursor |
cursor()
Returns a
RealCursor that iterates with optimal speed without
calculating the location at each iteration step. |
long |
dimension(int d)
Default implementation of
Dimensions.dimension(int) . |
void |
dimensions(long[] dimensions)
Write the number of pixels in each dimension into long[].
|
Void |
firstElement()
Get the first element of this
IterableRealInterval . |
RealLocalizable |
getCenterOfMass() |
T |
getLabel() |
Object |
iterationOrder()
Returns the iteration order of this
IterableRealInterval . |
LabelRegionCursor |
iterator() |
LabelRegionCursor |
localizingCursor()
Returns a
RealLocalizable Iterator that calculates its
location at each iteration step. |
long |
max(int d)
Get the maximum in dimension d.
|
void |
max(long[] max)
Write the maximum of each dimension into long[].
|
void |
max(Positionable max)
Sets a
Positionable to the maximum of this Interval |
long |
min(int d)
Get the minimum in dimension d.
|
void |
min(long[] min)
Write the minimum of each dimension into long[].
|
void |
min(Positionable min)
Sets a
Positionable to the minimum of this Interval |
PositionableLocalizable |
origin()
Get the
Positionable , Localizable origin of this
interval. |
LabelRegionRandomAccess<T> |
randomAccess()
Create a random access sampler for integer coordinates.
|
RandomAccess<BoolType> |
randomAccess(Interval interval)
Create a random access sampler for integer coordinates.
|
void |
realMax(double[] max)
Write the maximum of each dimension into double[].
|
double |
realMax(int d)
Default implementation of
RealInterval.realMax(int) . |
void |
realMax(RealPositionable max)
Sets a
RealPositionable to the maximum of this Interval |
void |
realMin(double[] min)
Write the minimum of each dimension into double[].
|
double |
realMin(int d)
Default implementation of
RealInterval.realMin(int) . |
void |
realMin(RealPositionable min)
Sets a
RealPositionable to the minimum of this Interval |
long |
size()
Returns the number of elements in this
Function . |
bck, fwd, move, move, move, move, move, setPosition, setPosition, setPosition, setPosition, setPosition, toString
getDoublePosition, getFloatPosition, getIntPosition, getLongPosition, localize, localize, localize, localize
numDimensions
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAt, getAt, getAt
forEach, spliterator
maxAsLongArray, maxAsPoint, minAsLongArray, minAsPoint
maxAsDoubleArray, maxAsRealPoint, minAsDoubleArray, minAsRealPoint
allPositive, allPositive, dimensions, dimensionsAsLongArray, dimensionsAsPoint, verify, verify, verifyAllPositive, verifyAllPositive
numDimensions
getDoublePosition, getFloatPosition, getIntPosition, getLongPosition, localize, localize, localize, positionAsLongArray, positionAsPoint
localize, localize, localize, positionAsDoubleArray, positionAsRealPoint
bck, fwd, move, move, move, move, move, setPosition, setPosition, setPosition, setPosition, setPosition
public LabelRegion(LabelRegions<T> regions, net.imglib2.roi.labeling.LabelRegions.LabelRegionProperties regionProperties, T label)
protected LabelRegion(LabelRegion<T> other)
public LabelRegion<T> copy()
LabelRegion
. The copy can be independently
positioned and its origin can be independently changed. All copies are
linked to the original Labeling and reflect all changes.copy
in interface PositionableIterableInterval<Void>
copy
in interface PositionableIterableRegion<BoolType>
LabelRegion
.public PositionableLocalizable origin()
PositionableInterval
Positionable
, Localizable
origin of this
interval.
The origin is the relative offset of the position to the minimum. For
example if a positionable (bitmask) region is made from a BitType
image with a circular pattern, then it is more natural if the region
position refers to the center of the pattern instead of the upper left
corner of the BitType
image. This can be achieved by positioning
the origin.
Assume a region is created from a 9x9 bitmask. The region initially has
min=(0,0), max=(8,8), position=(0,0). Because both position and min are
(0,0), initially origin=(0,0). Now assume the origin is moved to the
center of the bitmask using
origin().setPosition(new int[]{4,4})
. After this,
min=(-4,-4), max=(4,4), position=(0,0), and origin=(4,4).
origin
in interface PositionableIterableInterval<Void>
origin
in class PositionableInterval
public T getLabel()
public RealLocalizable getCenterOfMass()
public LabelRegionRandomAccess<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<BoolType>
public RandomAccess<BoolType> 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<BoolType>
interval
- in which interval you intend to use the random access.public LabelRegionCursor 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<Void>
cursor
in interface IterableRealInterval<Void>
public LabelRegionCursor 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<Void>
localizingCursor
in interface IterableRealInterval<Void>
public long size()
IterableRealInterval
Returns the number of elements in this Function
.
size
in interface IterableRealInterval<Void>
public Void 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<Void>
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<Void>
IterableRealInterval
.FlatIterationOrder
public LabelRegionCursor iterator()
public double realMin(int d)
Interval
RealInterval.realMin(int)
.realMin
in interface Interval
realMin
in interface RealInterval
realMin
in class PositionableInterval
d
- dimensionpublic void realMin(double[] min)
RealInterval
realMin
in interface RealInterval
realMin
in class PositionableInterval
public void realMin(RealPositionable min)
RealInterval
RealPositionable
to the minimum of this Interval
realMin
in interface RealInterval
realMin
in class PositionableInterval
public double realMax(int d)
Interval
RealInterval.realMax(int)
.realMax
in interface Interval
realMax
in interface RealInterval
realMax
in class PositionableInterval
d
- dimensionpublic void realMax(double[] max)
RealInterval
realMax
in interface RealInterval
realMax
in class PositionableInterval
public void realMax(RealPositionable max)
RealInterval
RealPositionable
to the maximum of this Interval
realMax
in interface RealInterval
realMax
in class PositionableInterval
public long min(int d)
Interval
min
in interface Interval
min
in class PositionableInterval
d
- dimensionpublic void min(long[] min)
Interval
min
in interface Interval
min
in class PositionableInterval
public void min(Positionable min)
Interval
Positionable
to the minimum of this Interval
min
in interface Interval
min
in class PositionableInterval
public long max(int d)
Interval
max
in interface Interval
max
in class PositionableInterval
d
- dimensionpublic void max(long[] max)
Interval
max
in interface Interval
max
in class PositionableInterval
public void max(Positionable max)
Interval
Positionable
to the maximum of this Interval
max
in interface Interval
max
in class PositionableInterval
public void dimensions(long[] dimensions)
Dimensions
dimensions
in interface Dimensions
dimensions
in class PositionableInterval
public long dimension(int d)
Interval
Dimensions.dimension(int)
.dimension
in interface Dimensions
dimension
in interface Interval
dimension
in class PositionableInterval
Copyright © 2015–2022 ImgLib2. All rights reserved.