ImageDev

CustomMeasurement

This class allows the creation of a new label analysis measurement, based on a user-defined formula.

A custom measurement is defined by a string formula that can invoke other measurements. It can be used by most of the individual analysis algorithms. It must have a unique name.

The formula defining a custom measurement must be written in accordance with the custom formula syntax. The validity of the formula can be verified with the checkMeasurementFormula method.

Notes
See also

AnalysisMsr::Ptr analysis = std::make_shared< AnalysisMsr >();
// Create a circularity factor between 0 and 1
std::string circularityFormula = "1.0/" + NativeMeasurements::inverseCircularity2d->name();
if ( checkMeasurementFormula( circularityFormula ) )
{
    const auto* customMeasurementInfo =
        AnalysisMsr::registerCustomMeasurement( "Circularity", circularityFormula, "This is my circularity factor." );
    auto circularity = analysis->select( customMeasurementInfo );
}
else
    std::cerr << "Invalid formula: " << circularityFormula << std::endl;