Introduction
Measure formula are string representation of classical equations composed of elementary items :
- operators
- functions
- operands (constant or variable values)
Usage of such a formula is classically associated to two stages :
- a preprocessing stage which ensure formula syntax validity and extraction of elementary items constituting formula.
- some evaluation stages were variable values are set with respect to concrete situations.
Management of measure formula is ensured by ipsdk::shape::analysis::FormulaManager.
Result type
For convenience, formula result types are restricted to two values types :
- ipsdk::ipReal64 for arithmetical cases (ipsdk::shape::analysis::eMsrFormulaResultType::eMFRT_Arithmetic case)
Example :
- ipsdk::ipBool for logical cases (ipsdk::shape::analysis::eMsrFormulaResultType::eMFRT_Logic case)
Example :
- Note
- Order of operations respect standard operator precedence rules.
- See also
- https://en.wikipedia.org/wiki/Order_of_operations
- Note
- Parenthesis can be freely used
Formula operators
This section regroups information about used formula operators. Formula operators are described by ipsdk::shape::analysis::eMsrFormulaOperatorType enumerate.
These operators allow all classical equation combinations such as :
- Note
- Associated result type will depends on operators combination.
Formula functions
This section describes formula functions available with IPSDK measure formula framework.
- Note
- Formula function name are not case sensitive
Formula arithmetic functions
Formula unary arithmetical functions
Formula unary arithmetical functions are described by ipsdk::shape::analysis::eMsrFormulaUnaryArithmeticFunctionType enumerate.
These functions allow introduction of unary arithmetic functions into equations such as :
- Note
- These functions are associated to a ipsdk::shape::analysis::eMsrFormulaResultType::eMFRT_Arithmetic result type.
Function operand must be associated to a ipsdk::ipReal64 type.
Formula binary arithmetical functions
Formula binary arithmetical functions are described by ipsdk::shape::analysis::eMsrFormulaBinaryArithmeticFunctionType enumerate.
These functions allow introduction of binary arithmetic functions into equations such as :
- Note
- These functions are associated to a ipsdk::shape::analysis::eMsrFormulaResultType::eMFRT_Arithmetic result type.
Function operands must be associated to a ipsdk::ipReal64 type.
Formula generic arithmetical functions
Formula generic arithmetical functions are described by ipsdk::shape::analysis::eMsrFormulaGenericArithmeticFunctionType enumerate.
These functions allow introduction of arithmetic functions using variable arguments list into equations such as :
These functions can be used with one or more operands.
- Note
- These functions are associated to a ipsdk::shape::analysis::eMsrFormulaResultType::eMFRT_Arithmetic result type.
Function operand must be associated to a ipsdk::ipReal64 type.
Formula coupled arithmetical functions
Formula coupled arithmetical functions are described by ipsdk::shape::analysis::eMsrFormulaCoupledArithmeticFunctionType enumerate.
These functions allow introduction of arithmetic functions using coupled variable arguments list into equations such as :
or
These functions can be used with one or more operands.
- Note
- These functions are associated to a ipsdk::shape::analysis::eMsrFormulaResultType::eMFRT_Arithmetic result type.
Function operand must be associated to a ipsdk::ipReal64 type.
Formula ternary logical functions
Formula ternary logical functions are described by ipsdk::shape::analysis::eMsrFormulaTernaryLogicFunctionType enumerate.
At this time a single function is available in this group
:
or
Function evaluation returns :
if
is evaluated to
boolean value
if
is evaluated to
boolean value
- Note
- Associated operands types must respect following rules :
- predicateValue must be associated to a ipsdk::ipBool value.
- successValue and failureValue must be associated to same value type.
This function can then alternativelly be associated to a ipsdk::shape::analysis::eMsrFormulaResultType::eMFRT_Arithmetic or a ipsdk::shape::analysis::eMsrFormulaResultType::eMFRT_Logic result type in function of
(and so
) value type.
Formula operands
This section regroups information about used formula operands. Formula operands can be represented in following forms :
- classical numerical values such as
.
- classical logical symbols :
or
(logical symbols are not case sensitive)
- predefined numerical symbols :
,
) (numerical symbols are not case sensitive)
- predefined image constant values
- variables which are simply other measure values
Formula color indexes
This section describes color indexes as they can be used with some predefined image constant values and with variables.
Color indexes syntax must respect following the rules (in the following
is an image constant value or a variable) :
- Warning
- Used color indexes must respect image color geometry.
Formula image constant operands
Formula image constant operands are described by ipsdk::shape::analysis::eMsrFormulaReserved enumerate. These constants will be replaced in equation by value extracted from used image informations.
These constants can be introduced into equations as follows :
Special constants
and
, which allows to retrieve minimum and maximum grey level values for a given image plan can be associated (if image color geometry allows it) to a color plan index :
- Note
- These constants are associated to a ipsdk::shape::analysis::eMsrFormulaResultType::eMFRT_Arithmetic result type.
Formula variable operands
Formula variable operands are associated to other measures. These variable names (which are not case sensitive) can refer to :
- a measure default name.
List of available measures (default names) can be retrieved interrogating ipsdk::shape::analysis::MeasureInfoFactory singleton to query registred measure defaults names collection.
Example :
In this case, Area2dMsr and Perimeter2dMsr will be used with their respective default parametrization. These measures will be automatically added to used ipsdk::shape::analysis::MeasureInfoSet object list of processed measures if not already included.
- an existing measure name retrieved from used ipsdk::shape::analysis::MeasureInfoSet object.
Example :
(in case where ipsdk::shape::analysis::MeasureInfoSet object already contains a measure named
)
As described in Formula color indexes, formula variable can be associated to a color plan index. It can also be associated to a second index which will represent the array index in case of measures associated to a collection results type (ipsdk::shape::analysis::eMsrResultType::eMRT_Coll).
Array indexes syntax must respect following rule :
with
an unsigned integer and can be cumulated with color indexes :
or
. Array indexes must be valid regards to measure result array size.
- Warning
- Formula variable measures can't be associated to custom results type (ipsdk::shape::analysis::eMsrResultType::eMRT_Custom)
- Note
- These variables are associated to a ipsdk::shape::analysis::eMsrFormulaResultType::eMFRT_Arithmetic result type.