#include "diplib/measurement.h"
IteratorFeature class
An iterator to visit all features (column groups) in the dip::Measurement table. Can also
be seen as a view over a specific feature.
The iterator can be indexed with an object ID to access the table cell that contains the feature’s
values for that object. It is also possible to iterate over all objects. See dip::Measurement for
examples of using this class.
The dip::Measurement::IteratorFeature::Subset method selects a subset of the values of the current feature. This does not invalidate
the iterator: incrementing it will select the next feature in the same way it would have if Subset
hadn’t been called. When indexing a subset feature using an object ID, the resulting table cell is
the same subset of the cell, as one would expect. Thus, subsetting can be used to look at only one
value of a feature as if that feature had produced only one value. For example:
dip::Measurement msr = measureTool.Measure( label, grey, {"Feret"}, {} ); auto featureValues = msr[ "Feret" ]; featureValues.Subset( 1 ); // Select the "FeretMin" column only
A series of functions (see Measurement) take a FeatureInformation object as input and produce
statistics for the first value of the feature. Use Subset to select which value these functions
operate on.
Comparison operators can be used to compare a feature value (again the first value) against a constant,
selecting objects that satisfy the comparison. The output is a dip::LabelMap, which records which
objects were selected. The dip::LabelMap can be used to modify a dip::Measurement object or
a labeled image.
Classes
- class Iterator
- An iterator to visit all objects (rows) within a feature (column group) of the
dip::Measurementtable. more...
Functions
- auto AsImage() const -> dip::Image
- Returns an image that encapsulates the data in this feature for all objects.
The image doesn’t own the data, the measurement must keep existing for as long as this image is used.
The image’s sizes are
NumberOfValues()xNumberOfObjects(). This function is intended to simplify the implementation of some of the functions that can be applied to aIteratorFeature. - auto AsScalarImage(dip::uint value = 0) const -> dip::Image
- Identical to
dip::Measurement::IteratorFeature::AsImage, but returns a 1D image with thevalueelement of this feature.valuemust be smaller thandip::Measurement::IteratorFeature::NumberOfValues, and defaults to the first value in the set. This function is intended to simplify the implementation of some of the functions that can be applied to aIteratorFeature. - auto Data() const -> dip::Measurement::ValueType*
- A raw pointer to the data of the feature. All values for one object are contiguous.
- auto FeatureName() const -> dip::String const&
- Name of the feature
- auto FirstObject() const -> dip::Measurement::IteratorFeature::Iterator
- Iterator to the first object for this feature
- auto IsAtEnd() const -> bool
- True if done iterating (do not call other methods if this is true!)
- auto NumberOfObjects() const -> dip::uint
- Number of objects
- auto NumberOfValues() const -> dip::uint
- Number of values
- auto ObjectExists(dip::uint objectID) const -> bool
- True if the object ID is available in
this. - auto ObjectIndex(dip::uint objectID) const -> dip::uint
- Finds the index for the given object ID
- auto ObjectIndices() const -> dip::ObjectIdToIndexMap const&
- Returns the map that links object IDs to row indices.
- auto Objects() const -> dip::UnsignedArray const&
- Returns a list of object IDs
- auto Stride() const -> dip::sint
- The stride to use to access the next row of data (next object).
- auto Subset(dip::uint first, dip::uint number = 1) -> dip::Measurement::IteratorFeature&
- Selects a subset of values from the current feature. This does not invalidate the iterator.
- auto Values() const -> dip::Feature::ValueInformationArray
- Returns an array with names and units for each of the values for the feature. (Note: data are copied to output array, this is not a trivial function).
Operators
- auto operator bool() const -> bool explicit
- True if the iterator is valid and can be used
- auto operator++() -> dip::Measurement::IteratorFeature&
- Pre-increment, to access the next feature
- auto operator++(int ) -> dip::Measurement::IteratorFeature
- Post-increment, to access the next feature
- auto operator[](dip::uint objectID) const -> dip::Measurement::IteratorFeature::Iterator
- Iterator to the given object for this feature
Function documentation
dip::Measurement::IteratorFeature::Iterator FirstObject( ) const
Iterator to the first object for this feature
dip::Measurement::IteratorFeature& Subset( dip::uint first, dip::uint number = 1)
Selects a subset of values from the current feature. This does not invalidate the iterator.
bool IsAtEnd( ) const
True if done iterating (do not call other methods if this is true!)
dip::String const& FeatureName( ) const
Name of the feature
dip::Feature::ValueInformationArray Values( ) const
Returns an array with names and units for each of the values for the feature. (Note: data are copied to output array, this is not a trivial function).
dip::uint NumberOfValues( ) const
Number of values
bool ObjectExists( dip::uint objectID) const
True if the object ID is available in this.
dip::uint ObjectIndex( dip::uint objectID) const
Finds the index for the given object ID
dip::ObjectIdToIndexMap const& ObjectIndices( ) const
Returns the map that links object IDs to row indices.
dip::UnsignedArray const& Objects( ) const
Returns a list of object IDs
dip::uint NumberOfObjects( ) const
Number of objects
dip::Measurement::ValueType* Data( ) const
A raw pointer to the data of the feature. All values for one object are contiguous.
dip::Image AsImage( ) const
Returns an image that encapsulates the data in this feature for all objects.
The image doesn’t own the data, the measurement must keep existing for as long as this image is used.
The image’s sizes are NumberOfValues()xNumberOfObjects(). This function is intended to simplify
the implementation of some of the functions that can be applied to a IteratorFeature.
dip::Image AsScalarImage( dip::uint value = 0) const
Identical to dip::Measurement::IteratorFeature::AsImage, but returns a 1D image with the value element of this feature.
value must be smaller than dip::Measurement::IteratorFeature::NumberOfValues, and defaults to the first value in the set.
This function is intended to simplify the implementation of some of the functions that can be
applied to a IteratorFeature.
dip::Measurement::IteratorFeature::Iterator operator[]( dip::uint objectID) const
Iterator to the given object for this feature
dip::Measurement::IteratorFeature& operator++( )
Pre-increment, to access the next feature
dip::Measurement::IteratorFeature operator++( int )
Post-increment, to access the next feature
bool operator bool( ) const explicit
True if the iterator is valid and can be used
dip::Measurement::ValueType
dip:: Minimum(
dip::Measurement::IteratorFeature const& featureValues)
Returns the smallest feature value in the first column of featureValues.
The input featureValues is a view over a specific feature in a dip::Measurement object. Only the
first value of the feature is used. For features with multiple values, select a value using the
dip::Measurement::IteratorFeature::Subset method, or pick a column in the dip::Measurement object
directly using dip::Measurement::FeatureValuesView.
dip::Measurement::ValueType
dip:: Maximum(
dip::Measurement::IteratorFeature const& featureValues)
Returns the largest feature value in the first column of featureValues.
The input featureValues is a view over a specific feature in a dip::Measurement object. Only the
first value of the feature is used. For features with multiple values, select a value using the
dip::Measurement::IteratorFeature::Subset method, or pick a column in the dip::Measurement object
directly using dip::Measurement::FeatureValuesView.
dip::Measurement::ValueType
dip:: Percentile(
dip::Measurement::IteratorFeature const& featureValues, dip::dfloat percentile)
Returns the percentile feature value in the first column of featureValues.
Percentiles are always one of the values in the set. The nearest value to a given partition is used, rather than interpolate as classically done.
The input featureValues is a view over a specific feature in a dip::Measurement object. Only the
first value of the feature is used. For features with multiple values, select a value using the
dip::Measurement::IteratorFeature::Subset method, or pick a column in the dip::Measurement object
directly using dip::Measurement::FeatureValuesView.
dip::dfloat
dip:: Median(
dip::Measurement::IteratorFeature const& featureValues)
Returns the median feature value in the first column of featureValues.
The input featureValues is a view over a specific feature in a dip::Measurement object. Only the
first value of the feature is used. For features with multiple values, select a value using the
dip::Measurement::IteratorFeature::Subset method, or pick a column in the dip::Measurement object
directly using dip::Measurement::FeatureValuesView.
dip::dfloat
dip:: Mean(
dip::Measurement::IteratorFeature const& featureValues)
Returns the mean feature value in the first column of featureValues.
The input featureValues is a view over a specific feature in a dip::Measurement object. Only the
first value of the feature is used. For features with multiple values, select a value using the
dip::Measurement::IteratorFeature::Subset method, or pick a column in the dip::Measurement object
directly using dip::Measurement::FeatureValuesView.
dip::MinMaxAccumulator
dip:: MaximumAndMinimum(
dip::Measurement::IteratorFeature const& featureValues)
Returns the maximum and minimum feature values in the first column of featureValues.
The input featureValues is a view over a specific feature in a dip::Measurement object. Only the
first value of the feature is used. For features with multiple values, select a value using the
dip::Measurement::IteratorFeature::Subset method, or pick a column in the dip::Measurement object
directly using dip::Measurement::FeatureValuesView.
dip::QuartilesResult
dip:: Quartiles(
dip::Measurement::IteratorFeature const& featu)
Computes the minimum, lower quartile (25th percentile), median (50th percentile), upper quartile (75th percentile), and maximum.
Percentiles are always one of the values in the set. The nearest value to a given partition is used, rather than interpolate as classically done.
The input featureValues is a view over a specific feature in a dip::Measurement object. Only the
first value of the feature is used. For features with multiple values, select a value using the
dip::Measurement::IteratorFeature::Subset method, or pick a column in the dip::Measurement object
directly using dip::Measurement::FeatureValuesView.
dip::StatisticsAccumulator
dip:: SampleStatistics(
dip::Measurement::IteratorFeature const& featureValues)
Returns the first four central moments of the feature values in the first column of featureValues.
The input featureValues is a view over a specific feature in a dip::Measurement object. Only the
first value of the feature is used. For features with multiple values, select a value using the
dip::Measurement::IteratorFeature::Subset method, or pick a column in the dip::Measurement object
directly using dip::Measurement::FeatureValuesView.
dip::uint
dip:: ObjectMinimum(
dip::Measurement::IteratorFeature const& featureValues)
Returns the object ID with the smallest feature value in the first column of featureValues.
Same as dip::Minimum, but returns the Object ID instead of
the feature value.
dip::uint
dip:: ObjectMaximum(
dip::Measurement::IteratorFeature const& featureValues)
Returns the object ID with the largest feature value in the first column of featureValues.
Same as dip::Maximum, but returns the Object ID instead of
the feature value.
dip::LabelMap
dip:: operator==(
dip::Measurement::IteratorFeature const& featureValues, dip::Measurement::ValueType value)
Selects objects where the first element of featureValues is equal to value.
dip::LabelMap
dip:: operator!=(
dip::Measurement::IteratorFeature const& featureValues, dip::Measurement::ValueType value)
Selects objects where the first element of featureValues is unequal to value.
dip::LabelMap
dip:: operator>(
dip::Measurement::IteratorFeature const& featureValues, dip::Measurement::ValueType value)
Selects objects where the first element of featureValues is greater than value.
dip::LabelMap
dip:: operator>=(
dip::Measurement::IteratorFeature const& featureValues, dip::Measurement::ValueType value)
Selects objects where the first element of featureValues is not smaller than value.
dip::LabelMap
dip:: operator<(
dip::Measurement::IteratorFeature const& featureValues, dip::Measurement::ValueType value)
Selects objects where the first element of featureValues is smaller than value.
dip::LabelMap
dip:: operator<=(
dip::Measurement::IteratorFeature const& featureValues, dip::Measurement::ValueType value)
Selects objects where the first element of featureValues is not greater than value.