dip::Measurement::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.

Contents

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::Measurement table.

Functions

auto FirstObject() const -> dip::Measurement::IteratorFeature::Iterator
Iterator to the first object for this feature
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 IsAtEnd() const -> bool
True if done iterating (do not call other methods if this is true!)
auto FeatureName() const -> dip::String const&
Name of the feature
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).
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 NumberOfObjects() const -> dip::uint
Number of objects
auto Data() const -> dip::Measurement::ValueType*
A raw pointer to the data of the feature. All values for one object are contiguous.
auto Stride() const -> dip::sint
The stride to use to access the next row of data (next object).
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 a IteratorFeature.
auto AsScalarImage(dip::uint value = 0) const -> dip::Image
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.

Operators

auto operator[](dip::uint objectID) const -> dip::Measurement::IteratorFeature::Iterator
Iterator to the given object for this feature
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 bool() const -> bool explicit
True if the iterator is valid and can be used

Function documentation

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.