To demonstrate formula basics, here some characteristics of measured shapes are computed using user-defined formulas, such as Aspect Ratio of rectangles, Circular shape computations such as circularity or ellipticity, or grating metrics such as duty cycle or fill fraction.
Note: ProSEM 2.3.0 or higher is required for these examples.
In this first example, a formula is created to compute the Aspect Ratio of measured rectangles.
1) A measurement of a rectangle is setup, stored, and then that stored measurement is selected in the tree in the Images panel.
2) In the Variables panel, the “Create New Variable…” button is clicked. In the dialog:
3) Optional: the new formula can be tested using the “Evaluate” button. If the variable is successfully setup, the value displayed will be the Aspect Ratio of the selected measurement.
4) The OK button is clicked to complete the creation of the new formula variable.
This formula will be evaluated for all measurements in the project, including measurements already stored and all measurements stored after the variable is created. The values of any defined variables for the currently selected measurement are shown in the table in the Variables panel.
In addition, each variable defined will appear as a new column in each data table, so in this case, the value of Aspect Ratio will be calculated for all rectangles measured in the project.
In this example, the Eccentricity, also sometimes called Ellipticity, of ellipses and circles is computed, and the Object Browser and Snippet Gallery are introduced.
To compute the Eccentricity of measured Ellipses and Circles, the formula to be used is:
Where a is the semimajor axis, or half the length of the major axis, and b is semiminor axis.
But how does one know the property names within ProSEM for these measured values? The Object Browser is displayed on the right side of the Edit Variables dialog when a Formula is being edited, and contains all of the properties of the selected measurement, as well as the group and the image containing the selected measurement.
For this example, a multi-line formula will be used, to increase the readability of the formula. So first a and b will be defined as variables, and then the full formula will be computed using those variables.
For example, to compute the Eccentricity of a measured ellipse:
1) An ellipse measurement is setup, stored, and then the stored measurement selected n the Images tree.
2) In the Variables panel, a new variable is created. In the Create New Variable dialog:
The complete formula contents for the Eccentricity in this example are:
a = MajorDiameter / 2;
b = MinorDiameter / 2;
sqrt(1- (pow(b,2) / pow(a,2)))
This could also be written on a single line as:
sqrt(1- (pow((MinorDiameter/2),2) / pow((MajorDiameter/2),2)))
The formulas in this example demonstrate some basic elements of using Formulas in ProSEM. See other examples on this site for more advanced examples.