Formulas 1 - Basic Shape Analysis
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.
- Basics of using formulas
Measurement Example 1: Aspect Ratio
In this first example, a formula is created to compute the Aspect Ratio of measured rectangles.
- A measurement of a rectangle is setup, stored, and then that stored measurement is selected in the tree in the Images panel.
- In the Variables panel, the “Create New Variable…” button is clicked. In the dialog:
- The variable type is set to: “Formula”
- The variable name is defined as: AspectRatio
- The formula is defined as: Height / Width
- 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.
- 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.
- It isn’t strictly necessary to select a measurement before creating a variable, but in order to test the formula using the Evaluate button, a measurement must have been selected before editing the variable, so that ProSEM knows which measurement to compute the formula for. A measurement must also be selected in order to use the context portion of the Context Browser, covered a few sections below.
- The Display Precision field specifies how many decimal places to display for this variable.
- To edit an existing variable, double-click on the variable entry in the table in the Variables panel, or right-click on the name and choose “Edit Variable”
- When an element is selected in the Images tree which does not have the necessary properties to compute the formula, "Error" is displayed instead of a value. For example, for this formula, for a Feature Type of "Lines & Spaces", the AspectRatio is displayed as "Error", because there is no Height or Width property defined for a Line measurement. It is possible to have other information displayed; that will be demonstrated in later example.
Measurement Example 2: Eccentricity, More Shape Computations, using the Object Browser and Snippet Gallery
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:
- An ellipse measurement is setup, stored, and then the stored measurement selected n the Images tree.
- In the Variables panel, a new variable is created. In the Create New Variable dialog:
- The variable type is set to: “Formula”
- The variable name is defined as: Eccentricity
- The formula for a, the semimajor axis, is defined by typing in a =
- Then in the object browser, the Context branch is opened, and the property MajorDiameter is drag-and-dropped into the formula
- The formula is completed by typing in: / 2 ;
- The formula for b is then created in the same way, but using the MinorDiameter property
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.