#include "diplib/histogram.h"
Configuration struct
Configuration information for how the histogram is computed.
Contents
Note that if mode == Mode::COMPUTE_BINS
, binSize
will be adjusted so that a whole number of bins
fits between the bounds. If binSize
was set to zero or a negative value, and the input image is of
any integer type, then binSize
will be computed to be an integer power of two, and such that there
are no more than 256 bins in the histogram.
Any illegal values in the configuration will silently be replaced with the default values.
Constructors exist to set different subsets of the configuration; write upper bound and bin size
as a floating point number so the right constructor can be selected (they differ in the location
of the integer value). For example, note the difference between the following constructor calls,
where 10
indicates 10 bins, 10.0
indicates the upper bound, and 1.0
indicates the bin size:
dip::Histogram::Configuration conf1( 0.0, 10.0, 1.0 ); dip::Histogram::Configuration conf1( 0.0, 10.0, 10 ); dip::Histogram::Configuration conf2( 0.0, 10, 1.0 );
An additional constructor takes a dip::DataType
, and selects appropriate values for an image of the
given data type:
- For 8-bit images, the histogram has 256 bins, one for each possible input value.
- For other integer-valued images, the histogram has up to 256 bins, stretching from the lowest value in the image to the highest, and with bin size a power of two. This is the simplest way of correctly handling data from 10-bit, 12-bit and 16-bit sensors that can put data in the lower or the upper bits of the 16-bit words, and will handle other integer data correctly as well.
- For floating-point images, the histogram always has 256 bins, stretching from the lowest value in the image to the highest.
Constructors, destructors, assignment and conversion operators
- Configuration() defaulted noexcept
- Default-constructed configuration defines 256 bins in the range [0,256].
- Configuration(dip::dfloat lowerBound, dip::dfloat upperBound, dip::dfloat binSize)
- A constructor takes a lower and upper bounds, and the bin size. The number of bins are computed.
- Configuration(dip::dfloat lowerBound, dip::dfloat upperBound, dip::uint nBins = 256)
- A constructor takes a lower and upper bounds, and the number of bins. The bin size is computed.
- Configuration(dip::dfloat lowerBound, dip::dfloat upperBound, int nBins)
- A constructor takes a lower and upper bounds, and the number of bins. The bin size is computed.
- Configuration(dip::dfloat lowerBound, dip::uint nBins, dip::dfloat binSize)
- A constructor takes a lower bound, the number of bins and the bin size. The upper bound is computed.
- Configuration(dip::dfloat lowerBound, int nBins, dip::dfloat binSize)
- A constructor takes a lower bound, the number of bins and the bin size. The upper bound is computed.
- Configuration(dip::DataType dataType) explicit
- A constructor takes an image data type, yielding a default histogram configuration for that data type.
Enums
- enum class Mode: uint8{ COMPUTE_BINSIZE, COMPUTE_BINS, COMPUTE_LOWER, COMPUTE_UPPER }
- Which of the four values to compute based on the other three
Functions
- auto IsOutOfRange(dip::dfloat value) const -> bool
- Returns true if the value should not be included in the histogram.
- auto FindBin(dip::dfloat value) const -> dip::sint
- Returns the bin that the value belongs in, assuming
!IsOutOfRange(value)
.
Variables
- dip::dfloat lowerBound
- Lower bound for this dimension, corresponds to the lower bound of the first bin.
- dip::dfloat upperBound
- Upper bound for this dimension, corresponds to the upper bound of the last bin.
- dip::uint nBins
- Number of bins for this dimension.
- dip::dfloat binSize
- Size of each bin for this dimension.
- dip::Histogram::Configuration::Mode mode
- The given value is ignored and replaced by the computed value.
- bool lowerIsPercentile
- If set,
lowerBound
is replaced by the given percentile pixel value. - bool upperIsPercentile
- If set,
upperBound
is replaced by the given percentile pixel value. - bool excludeOutOfBoundValues
- If set, pixels outside of the histogram bounds are not counted.