public class HistogramNd<T> extends Object implements Img<LongType>
Note: the last three classifications may not be present depending upon the makeup of the input data.
Constructor and Description |
---|
HistogramNd(HistogramNd<T> other)
Construct a histogram whose bin mappings match another histogram.
|
HistogramNd(Iterable<List<T>> data,
List<BinMapper1d<T>> mappers)
Construct a histogram from an iterable set of data and a list of bin
mapping algorithms.
|
HistogramNd(List<BinMapper1d<T>> mappers)
Construct a histogram from a list of bin mapping algorithms.
|
HistogramNd(List<Iterable<T>> data,
List<BinMapper1d<T>> mappers)
Construct a histogram from an iterable set of data and a list of bin
mapping algorithms.
|
Modifier and Type | Method and Description |
---|---|
void |
addData(Iterable<List<T>> data)
Counts additional data contained in a given iterable collection.
|
void |
addData(List<Iterable<T>> data)
Counts additional data contained in a given iterable collection.
|
HistogramNd<T> |
copy() |
void |
countData(Iterable<List<T>> data)
Counts the data contained in the given data source using the underlying
bin distribution.
|
void |
countData(List<Iterable<T>> data)
Counts the data contained in the given data source using the underlying
bin distribution.
|
Cursor<LongType> |
cursor()
Returns a
RealCursor that iterates with optimal speed without
calculating the location at each iteration step. |
void |
decrement(List<T> values)
Directly decrement a bin by value,
|
void |
decrement(long[] binPos)
Directly decrement a bin by position.
|
DiscreteFrequencyDistribution |
dfd()
Get the discrete frequency distribution associated with this histogram.
|
long |
dimension(int d)
Return the size of the given dimension of the frequency distribution of
this histogram.
|
void |
dimensions(long[] dims)
Fill the provided long[] with the sizes of all dimensions of the
frequency distribution of this histogram.
|
long |
distributionCount()
Returns the frequency count of all values in the distribution: lower tail
+ middle + upper tail.
|
long |
distributionCount(int dim,
long dimVal)
Returns the frequency count of all values in the specified dimension of
the distribution: lower tail + middle + upper tail.
|
ImgFactory<LongType> |
factory()
Get a
ImgFactory that creates Img s of the same kind as
this one. |
LongType |
firstElement()
Get the first element of this
IterableRealInterval . |
long |
frequency(List<T> values)
Returns the frequency count of values within a bin using a set of
representative values.
|
long |
frequency(long[] binPos)
Returns the frequency count of the values within a bin.
|
long |
getBinCount()
Returns the number of bins contained in the histogram.
|
void |
getCenterValues(long[] binPos,
List<T> values)
Gets the values associated with the center of a bin.
|
void |
getLowerBounds(long[] binPos,
List<T> values)
Gets the values associated with the left edge of a bin.
|
void |
getUpperBounds(long[] binPos,
List<T> values)
Gets the values associated with the right edge of a bin.
|
boolean |
hasTails()
Returns true if the histogram has tail bins which count extreme values
for one or more dimensions
|
boolean |
hasTails(int dim)
Returns true if the histogram has tail bins which count extreme values
for the given dimension.
|
long |
ignoredCount()
Returns the frequency count of values that were ignored because they
could not be mapped to any bin.
|
boolean |
includesLowerBound(int dim,
long binPos)
Returns true if the given bin interval is closed on the left for the
given dimension.
|
boolean |
includesLowerBounds(long[] binPos)
Returns true if the given bin interval is closed on the left
|
boolean |
includesUpperBound(int dim,
long binPos)
Returns true if the given bin interval is closed on the right for the
given dimension.
|
boolean |
includesUpperBounds(long[] binPos)
Returns true if the given bin interval is closed on the right
|
void |
increment(List<T> values)
Directly increment a bin by value.
|
void |
increment(long[] binPos)
Directly increment a bin by position.
|
boolean |
isInLowerTail(int dim,
T value)
Returns true if a given value for a given dimension is mapped to the
lower tail of the distribution.
|
boolean |
isInLowerTail(List<T> values)
Returns true if a given set of values are mapped to the lower tail of the
distribution.
|
boolean |
isInMiddle(int dim,
T value)
Returns true if a given value for a given dimension is mapped to the
middle of the distribution.
|
boolean |
isInMiddle(List<T> values)
Returns true if a given set of values are mapped to the middle of the
distribution.
|
boolean |
isInUpperTail(int dim,
T value)
Returns true if a given value for a given dimension is mapped to the
upper tail of the distribution.
|
boolean |
isInUpperTail(List<T> values)
Returns true if a given set of values are mapped to the upper tail of the
distribution.
|
boolean |
isOutside(int dim,
T value)
Returns true if a given value for a given dimension is outside the
distribution.
|
boolean |
isOutside(List<T> values)
Returns true if a given set of values are outside the distribution.
|
Object |
iterationOrder()
Returns the iteration order of this
IterableRealInterval . |
Iterator<LongType> |
iterator() |
Cursor<LongType> |
localizingCursor()
Returns a
RealLocalizable Iterator that calculates its
location at each iteration step. |
long |
lowerTailCount()
Returns the frequency count of values in all lower tail bins (if any).
|
long |
lowerTailCount(int dim)
Returns the frequency count of values in the lower tail bin (if any) for
the given dimension.
|
void |
map(List<T> values,
long[] binPos)
Fills a bin position by mapping from a set of representative values.
|
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 |
int |
numDimensions()
Return the number of dimensions of the frequency distribution of this
histogram.
|
RandomAccess<LongType> |
randomAccess()
Create a random access sampler for integer coordinates.
|
RandomAccess<LongType> |
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 |
double |
relativeFrequency(List<T> values,
boolean includeTails)
Returns the relative frequency of values within a bin using a set of
representative values.
|
double |
relativeFrequency(long[] binPos,
boolean includeTails)
Returns the relative frequency of values within a bin.
|
void |
resetCounters()
Resets all data counts to 0.
|
long |
size()
Returns the number of elements in this
Function . |
void |
subtractData(Iterable<List<T>> data)
Uncounts some original data contained in a given iterable collection.
|
void |
subtractData(List<Iterable<T>> data)
Uncounts some original data contained in a given iterable collection.
|
long |
totalCount()
Returns the total count of all values observed; both within and without
the entire distribution.
|
long |
upperTailCount()
Returns the frequency count of values in all upper tail bins (if any).
|
long |
upperTailCount(int dim)
Returns the frequency count of values in the upper tail bin (if any) for
the given dimension.
|
long |
valueCount()
Returns the frequency count of all values in the middle of the
distribution.
|
long |
valueCount(int dim)
Returns the frequency count of all values in the middle of the
distribution for a given dimension.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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
public HistogramNd(List<BinMapper1d<T>> mappers)
mappers
- The algorithms used to map values to binspublic HistogramNd(HistogramNd<T> other)
other
- The histogram to copy.public HistogramNd(Iterable<List<T>> data, List<BinMapper1d<T>> mappers)
data
- The iterable set of values to calculate uponmappers
- The algorithms used to map values to binspublic HistogramNd(List<Iterable<T>> data, List<BinMapper1d<T>> mappers)
data
- The iterable set of values to calculate uponmappers
- The algorithms used to map values to binspublic boolean hasTails(int dim)
public boolean hasTails()
public long lowerTailCount(int dim)
public long lowerTailCount()
public long upperTailCount(int dim)
public long upperTailCount()
public long valueCount(int dim)
public long valueCount()
public long distributionCount(int dim, long dimVal)
public long distributionCount()
public long ignoredCount()
public long totalCount()
public long frequency(List<T> values)
values
- A set of representative values of interestpublic long frequency(long[] binPos)
public double relativeFrequency(List<T> values, boolean includeTails)
This calculation is of the number of values in the bin divided by either the number of values in the distribution or the number of values in the center of the distribution (tails ignored).
One can devise other ways to count relative frequencies that consider ignored values also. If needed one can use the various count methods and frequency methods to calculate any relative frequency desired.
values
- A representative set of values of interestincludeTails
- Flag for determining whether to include tails in calculation.public double relativeFrequency(long[] binPos, boolean includeTails)
This calculation is of the number of values in the bin divided by either the number of values in the distribution or the number of values in the center of the distribution (tails ignored).
One can devise other ways to count relative frequencies that consider ignored values also. If needed one can use the various count methods and frequency methods to calculate any relative frequency desired.
binPos
- The position of the bin of interestincludeTails
- Flag for determining whether to include tails in calculation.public long getBinCount()
public void map(List<T> values, long[] binPos)
public void getCenterValues(long[] binPos, List<T> values)
binPos
- The bin index of interestvalues
- The outputs to fill with the center valuespublic void getLowerBounds(long[] binPos, List<T> values)
binPos
- The bin index of interestvalues
- The outputs to fill with the left edge valuespublic void getUpperBounds(long[] binPos, List<T> values)
binPos
- The bin index of interestvalues
- The outputs to fill with the right edge valuespublic boolean includesUpperBounds(long[] binPos)
binPos
- The bin number of the interval of interestpublic boolean includesLowerBounds(long[] binPos)
binPos
- The bin number of the interval of interestpublic boolean includesUpperBound(int dim, long binPos)
dim
- The dimension of interestbinPos
- The bin number of the interval of interestpublic boolean includesLowerBound(int dim, long binPos)
dim
- The dimension of interestbinPos
- The bin number of the interval of interestpublic boolean isInLowerTail(List<T> values)
values
- The set of values to determine the location ofpublic boolean isInLowerTail(int dim, T value)
dim
- The dimension number of the axis of interestvalue
- The value to determine the location ofpublic boolean isInUpperTail(List<T> values)
values
- The set of values to determine the location ofpublic boolean isInUpperTail(int dim, T value)
dim
- The dimension number of the axis of interestvalue
- The value to determine the location ofpublic boolean isInMiddle(List<T> values)
values
- The set of values to determine the location ofpublic boolean isInMiddle(int dim, T value)
dim
- The dimension number of the axis of interestvalue
- The value to determine the location ofpublic boolean isOutside(List<T> values)
values
- The set of values to determine the location ofpublic boolean isOutside(int dim, T value)
value
- The value to determine the location ofpublic DiscreteFrequencyDistribution dfd()
public void countData(Iterable<List<T>> data)
data
- The total data to countpublic void countData(List<Iterable<T>> data)
data
- The total data to countpublic void addData(Iterable<List<T>> data)
data
- The new data to countpublic void addData(List<Iterable<T>> data)
data
- The new data to countpublic void subtractData(Iterable<List<T>> data)
data
- The old data to uncountpublic void subtractData(List<Iterable<T>> data)
data
- The old data to uncountpublic void increment(long[] binPos)
binPos
- The 1-d index of the binpublic void decrement(long[] binPos)
binPos
- The 1-d index of the binpublic void increment(List<T> values)
values
- The values to map to a bin positionpublic void decrement(List<T> values)
values
- The values to map to a bin positionpublic void resetCounters()
public int numDimensions()
numDimensions
in interface EuclideanSpace
public long dimension(int d)
dimension
in interface Dimensions
dimension
in interface Interval
public void dimensions(long[] dims)
dimensions
in interface Dimensions
public RandomAccess<LongType> 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<LongType>
public RandomAccess<LongType> 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<LongType>
interval
- in which interval you intend to use the random access.public long min(int d)
Interval
public void min(long[] min)
Interval
public void min(Positionable min)
Interval
Positionable
to the minimum of this Interval
public long max(int d)
Interval
public void max(long[] max)
Interval
public void max(Positionable max)
Interval
Positionable
to the maximum of this Interval
public double realMin(int d)
Interval
RealInterval.realMin(int)
.realMin
in interface Interval
realMin
in interface RealInterval
d
- dimensionpublic void realMin(double[] min)
RealInterval
realMin
in interface RealInterval
public void realMin(RealPositionable min)
RealInterval
RealPositionable
to the minimum of this Interval
realMin
in interface RealInterval
public double realMax(int d)
Interval
RealInterval.realMax(int)
.realMax
in interface Interval
realMax
in interface RealInterval
d
- dimensionpublic void realMax(double[] max)
RealInterval
realMax
in interface RealInterval
public void realMax(RealPositionable max)
RealInterval
RealPositionable
to the maximum of this Interval
realMax
in interface RealInterval
public Cursor<LongType> 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<LongType>
cursor
in interface IterableRealInterval<LongType>
public Cursor<LongType> 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<LongType>
localizingCursor
in interface IterableRealInterval<LongType>
public long size()
IterableRealInterval
Returns the number of elements in this Function
.
size
in interface IterableRealInterval<LongType>
public LongType 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<LongType>
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<LongType>
IterableRealInterval
.FlatIterationOrder
public ImgFactory<LongType> factory()
Img
ImgFactory
that creates Img
s of the same kind as
this one.
This is useful to create Imgs for temporary storage in generic methods
where the specific Img type is unknown. Note, that the factory can be
used even if all references to this Img have been invalidated.Copyright © 2015–2022 ImgLib2. All rights reserved.