net.imglib2.histogram

## Class Histogram1d<T>

• ### Constructor Summary

Constructors
Constructor and Description
`Histogram1d(BinMapper1d<T> mapper)`
Construct a histogram from a bin mapping algorithm.
`Histogram1d(Histogram1d<T> other)`
Construct a histogram whose bin mappings match another histogram.
```Histogram1d(Iterable<T> data, BinMapper1d<T> mapper)```
Construct a histogram from an iterable set of data and a bin mapping algorithm.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`void` `addData(Iterable<T> data)`
Counts additional data contained in a given iterable collection.
`Histogram1d<T>` `copy()`
`void` `countData(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(long binPos)`
Directly decrement a bin by position.
`void` `decrement(T value)`
Directly decrement a bin by value,
`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.
`ImgFactory<LongType>` `factory()`
Get a `ImgFactory` that creates `Img`s of the same kind as this one.
`T` `firstDataValue()`
Returns the first data value of the input iteration.
`LongType` `firstElement()`
Get the first element of this `IterableRealInterval`.
`long` `frequency(long binPos)`
Returns the frequency count of the values within a bin.
`long` `frequency(T value)`
Returns the frequency count of values within a bin using a representative value.
`long` `getBinCount()`
Returns the number of bins contained in the histogram.
`void` ```getCenterValue(long binPos, T value)```
Gets the value associated with the center of a bin.
`void` ```getLowerBound(long binPos, T value)```
Gets the value associated with the left edge of a bin.
`void` ```getUpperBound(long binPos, T value)```
Gets the value associated with the right edge of the bin.
`boolean` `hasTails()`
Returns true if the histogram has tail bins at both ends which count extreme values.
`long` `ignoredCount()`
Returns the frequency count of values that were ignored because they could not be mapped to any bin.
`boolean` `includesLowerBound(long binPos)`
Returns true if the given bin interval is closed on the left
`boolean` `includesUpperBound(long binPos)`
Returns true if the given bin interval is closed on the right
`void` `increment(long binPos)`
Directly increment a bin by position.
`void` `increment(T value)`
Directly increment a bin by value.
`boolean` `isInLowerTail(T value)`
Returns true if a given value is mapped to the lower tail of the distribution.
`boolean` `isInMiddle(T value)`
Returns true if a given value is mapped to the middle of the distribution.
`boolean` `isInUpperTail(T value)`
Returns true if a given value is mapped to the upper tail of the distribution.
`boolean` `isOutside(T value)`
Returns true if a given value is 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 the lower tail bin (if any).
`long` `map(T value)`
Returns a bin position by mapping from a representative value.
`long` `max()`
`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)`
`long` `min()`
`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)`
`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.
`double` `realMax()`
`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)`
`double` `realMin()`
`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)`
`double` ```relativeFrequency(long binPos, boolean includeTails)```
Returns the relative frequency of values within a bin.
`double` ```relativeFrequency(T value, boolean includeTails)```
Returns the relative frequency of values within a bin using a representative value.
`void` `resetCounters()`
Resets all data counts to 0.
`long` `size()`
Returns the number of elements in this `Function`.
`void` `subtractData(Iterable<T> data)`
Uncounts some original data contained in a given iterable collection.
`long[]` `toLongArray()`
Returns a bare long[] histogram with the same bin counts as this histogram.
`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 the upper tail bin (if any).
`long` `valueCount()`
Returns the frequency count of all values in the middle of the distribution.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Methods inherited from interface net.imglib2.RandomAccessible

`getAt, getAt, getAt`
• ### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`
• ### Methods inherited from interface net.imglib2.Interval

`maxAsLongArray, maxAsPoint, minAsLongArray, minAsPoint`
• ### Methods inherited from interface net.imglib2.RealInterval

`maxAsDoubleArray, maxAsRealPoint, minAsDoubleArray, minAsRealPoint`
• ### Methods inherited from interface net.imglib2.Dimensions

`allPositive, allPositive, dimensions, dimensionsAsLongArray, dimensionsAsPoint, verify, verify, verifyAllPositive, verifyAllPositive`
• ### Constructor Detail

• #### Histogram1d

`public Histogram1d(BinMapper1d<T> mapper)`
Construct a histogram from a bin mapping algorithm. Use countData() to populate it.
Parameters:
`mapper` - The algorithm used to map values to bins
• #### Histogram1d

`public Histogram1d(Histogram1d<T> other)`
Construct a histogram whose bin mappings match another histogram. After this construction the histogram bins are unpopulated.
Parameters:
`other` - The histogram to copy.
• #### Histogram1d

```public Histogram1d(Iterable<T> data,
BinMapper1d<T> mapper)```
Construct a histogram from an iterable set of data and a bin mapping algorithm.
Parameters:
`data` - The iterable set of values to calculate upon
`mapper` - The algorithm used to map values to bins
• ### Method Detail

• #### firstDataValue

`public T firstDataValue()`
Returns the first data value of the input iteration.
• #### hasTails

`public boolean hasTails()`
Returns true if the histogram has tail bins at both ends which count extreme values.
• #### lowerTailCount

`public long lowerTailCount()`
Returns the frequency count of values in the lower tail bin (if any).
• #### upperTailCount

`public long upperTailCount()`
Returns the frequency count of values in the upper tail bin (if any).
• #### valueCount

`public long valueCount()`
Returns the frequency count of all values in the middle of the distribution.
• #### distributionCount

`public long distributionCount()`
Returns the frequency count of all values in the distribution: lower tail + middle + upper tail. Does not include ignored values.
• #### ignoredCount

`public long ignoredCount()`
Returns the frequency count of values that were ignored because they could not be mapped to any bin.
• #### totalCount

`public long totalCount()`
Returns the total count of all values observed; both within and without the entire distribution. Thus it includes ignored values. One should decide carefully between using distributionCount() and totalCount().
• #### frequency

`public long frequency(T value)`
Returns the frequency count of values within a bin using a representative value. Note that multiple values can be mapped to one bin so this is NOT the frequency count of this exact value in the distribution.
Parameters:
`value` - A representative value of interest
• #### frequency

`public long frequency(long binPos)`
Returns the frequency count of the values within a bin.
• #### relativeFrequency

```public double relativeFrequency(T value,
boolean includeTails)```
Returns the relative frequency of values within a bin using a representative value. Note that multiple values can be mapped to one bin so this is NOT the relative frequency of this exact value in the distribution.

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.

Parameters:
`value` - A representative value of interest
`includeTails` - Flag for determining whether to include tails in calculation.
• #### relativeFrequency

```public double relativeFrequency(long binPos,
boolean includeTails)```
Returns the relative frequency of values within a bin.

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.

Parameters:
`binPos` - The position of the bin of interest
`includeTails` - Flag for determining whether to include tails in calculation.
• #### getBinCount

`public long getBinCount()`
Returns the number of bins contained in the histogram.
• #### map

`public long map(T value)`
Returns a bin position by mapping from a representative value.
• #### getCenterValue

```public void getCenterValue(long binPos,
T value)```
Gets the value associated with the center of a bin.
Parameters:
`binPos` - The bin number of interest
`value` - The output to fill with the center value
• #### getLowerBound

```public void getLowerBound(long binPos,
T value)```
Gets the value associated with the left edge of a bin.
Parameters:
`binPos` - The bin number of interest
`value` - The output to fill with the left edge value
• #### getUpperBound

```public void getUpperBound(long binPos,
T value)```
Gets the value associated with the right edge of the bin.
Parameters:
`binPos` - The bin number of interest
`value` - The output to fill with the right edge value
• #### includesUpperBound

`public boolean includesUpperBound(long binPos)`
Returns true if the given bin interval is closed on the right
Parameters:
`binPos` - The bin number of the interval of interest
• #### includesLowerBound

`public boolean includesLowerBound(long binPos)`
Returns true if the given bin interval is closed on the left
Parameters:
`binPos` - The bin number of the interval of interest
• #### isInLowerTail

`public boolean isInLowerTail(T value)`
Returns true if a given value is mapped to the lower tail of the distribution.
Parameters:
`value` - The value to determine the location of
• #### isInUpperTail

`public boolean isInUpperTail(T value)`
Returns true if a given value is mapped to the upper tail of the distribution.
Parameters:
`value` - The value to determine the location of
• #### isInMiddle

`public boolean isInMiddle(T value)`
Returns true if a given value is mapped to the middle of the distribution.
Parameters:
`value` - The value to determine the location of
• #### isOutside

`public boolean isOutside(T value)`
Returns true if a given value is outside the distribution.
Parameters:
`value` - The value to determine the location of
• #### dfd

`public DiscreteFrequencyDistribution dfd()`
Get the discrete frequency distribution associated with this histogram.
• #### countData

`public void countData(Iterable<T> data)`
Counts the data contained in the given data source using the underlying bin distribution.
Parameters:
`data` - The total data to count

`public void addData(Iterable<T> data)`
Counts additional data contained in a given iterable collection. One can use this to update an existing histogram with a subset of values.
Parameters:
`data` - The new data to count
• #### subtractData

`public void subtractData(Iterable<T> data)`
Uncounts some original data contained in a given iterable collection. One can use this to update an existing histogram with a subset of values.
Parameters:
`data` - The old data to uncount
• #### increment

`public void increment(long binPos)`
Directly increment a bin by position.
Parameters:
`binPos` - The 1-d index of the bin
• #### decrement

`public void decrement(long binPos)`
Directly decrement a bin by position.
Parameters:
`binPos` - The 1-d index of the bin
• #### increment

`public void increment(T value)`
Directly increment a bin by value.
Parameters:
`value` - The value to map to a bin position
• #### decrement

`public void decrement(T value)`
Directly decrement a bin by value,
Parameters:
`value` - The value to map to a bin position
• #### resetCounters

`public void resetCounters()`
Resets all data counts to 0.
• #### toLongArray

`public long[] toLongArray()`
Returns a bare long[] histogram with the same bin counts as this histogram.
• #### numDimensions

`public int numDimensions()`
Return the number of dimensions of the frequency distribution of this histogram.
Specified by:
`numDimensions` in interface `EuclideanSpace`
• #### dimension

`public long dimension(int d)`
Return the size of the given dimension of the frequency distribution of this histogram.
Specified by:
`dimension` in interface `Dimensions`
Specified by:
`dimension` in interface `Interval`
• #### dimensions

`public void dimensions(long[] dims)`
Fill the provided long[] with the sizes of all dimensions of the frequency distribution of this histogram.
Specified by:
`dimensions` in interface `Dimensions`
• #### randomAccess

`public RandomAccess<LongType> randomAccess()`
Description copied from interface: `RandomAccessible`
Create a random access sampler for integer coordinates.

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.
Specified by:
`randomAccess` in interface `RandomAccessible<LongType>`
Returns:
random access sampler
• #### randomAccess

`public RandomAccess<LongType> randomAccess(Interval interval)`
Description copied from interface: `RandomAccessible`
Create a random access sampler for integer coordinates.

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.

Specified by:
`randomAccess` in interface `RandomAccessible<LongType>`
Parameters:
`interval` - in which interval you intend to use the random access.
Returns:
random access sampler
• #### min

`public long min()`
• #### min

`public long min(int d)`
Description copied from interface: `Interval`
Get the minimum in dimension d.
Specified by:
`min` in interface `Interval`
Parameters:
`d` - dimension
Returns:
minimum in dimension d.
• #### min

`public void min(long[] min)`
Description copied from interface: `Interval`
Write the minimum of each dimension into long[].
Specified by:
`min` in interface `Interval`
• #### min

`public void min(Positionable min)`
Description copied from interface: `Interval`
Specified by:
`min` in interface `Interval`
• #### max

`public long max()`
• #### max

`public long max(int d)`
Description copied from interface: `Interval`
Get the maximum in dimension d.
Specified by:
`max` in interface `Interval`
Parameters:
`d` - dimension
Returns:
maximum in dimension d.
• #### max

`public void max(long[] max)`
Description copied from interface: `Interval`
Write the maximum of each dimension into long[].
Specified by:
`max` in interface `Interval`
• #### max

`public void max(Positionable max)`
Description copied from interface: `Interval`
Specified by:
`max` in interface `Interval`
• #### realMin

`public double realMin()`
• #### realMin

`public double realMin(int d)`
Description copied from interface: `Interval`
Default implementation of `RealInterval.realMin(int)`.
Specified by:
`realMin` in interface `Interval`
Specified by:
`realMin` in interface `RealInterval`
Parameters:
`d` - dimension
Returns:
minimum in dimension d.
• #### realMin

`public void realMin(double[] min)`
Description copied from interface: `RealInterval`
Write the minimum of each dimension into double[].
Specified by:
`realMin` in interface `RealInterval`
• #### realMin

`public void realMin(RealPositionable min)`
Description copied from interface: `RealInterval`
Specified by:
`realMin` in interface `RealInterval`
• #### realMax

`public double realMax()`
• #### realMax

`public double realMax(int d)`
Description copied from interface: `Interval`
Default implementation of `RealInterval.realMax(int)`.
Specified by:
`realMax` in interface `Interval`
Specified by:
`realMax` in interface `RealInterval`
Parameters:
`d` - dimension
Returns:
maximum in dimension d.
• #### realMax

`public void realMax(double[] max)`
Description copied from interface: `RealInterval`
Write the maximum of each dimension into double[].
Specified by:
`realMax` in interface `RealInterval`
• #### realMax

`public void realMax(RealPositionable max)`
Description copied from interface: `RealInterval`
Specified by:
`realMax` in interface `RealInterval`
• #### cursor

`public Cursor<LongType> cursor()`
Description copied from interface: `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.

Specified by:
`cursor` in interface `IterableInterval<LongType>`
Specified by:
`cursor` in interface `IterableRealInterval<LongType>`
Returns:
fast iterating iterator
• #### localizingCursor

`public Cursor<LongType> localizingCursor()`
Description copied from interface: `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.

Specified by:
`localizingCursor` in interface `IterableInterval<LongType>`
Specified by:
`localizingCursor` in interface `IterableRealInterval<LongType>`
Returns:
fast localizing iterator
• #### size

`public long size()`
Description copied from interface: `IterableRealInterval`

Returns the number of elements in this `Function`.

Specified by:
`size` in interface `IterableRealInterval<LongType>`
Returns:
number of elements
• #### firstElement

`public LongType firstElement()`
Description copied from interface: `IterableRealInterval`
Get the first element of this `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`.
Specified by:
`firstElement` in interface `IterableRealInterval<LongType>`
Returns:
the first element in iteration order.
• #### iterator

`public Iterator<LongType> iterator()`
Specified by:
`iterator` in interface `Iterable<LongType>`
• #### factory

`public ImgFactory<LongType> factory()`
Description copied from interface: `Img`
Get a `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.
Specified by:
`factory` in interface `Img<LongType>`
Returns:
a factory for Imgs of the same kind as this one.
• #### copy

`public Histogram1d<T> copy()`
Specified by:
`copy` in interface `Img<LongType>`
Returns:
- A copy of the current `Img` instance, all pixels are duplicated