The following steps provide a basic methodology for using the MIL Measurement module:
Allocate an edge, stripe, or circle marker buffer. For a multiple-occurrence marker, set the number of occurrences of the edge or stripe.
You can also allocate a point marker buffer or a multiple-point marker buffer. Points are not found, they are explicitly set and typically used as a reference marker.
In the marker buffer, specify the search region for the marker and set the marker's essential characteristics.
Optionally, set a score characteristic for an edge, stripe, or circle marker. Note that preprocessing operations (such as filtering) can cause the location of edges to shift slightly. If precise edge location and measurement are crucial to your application, keep preprocessing operations to a minimum.
Grab or load a target image.
Optionally, preprocess it to improve its quality.
Find the marker (defined in the marker buffer) in the target image and calculate measurements. Note that marker results are stored in the marker buffer, but they are stored separately.
Read the results and, if necessary, annotate an image (for example, the original target image) with them. You can also draw the specified chacteristics of the requested marker (rather than the marker characteristics found in the target image).
Free all your allocated objects, using MmeasFree().
In general, the first two steps are performed once, while steps 3 to 5 are repeated as required. Note that you can avoid the first two steps by saving an initialized marker buffer on disk and restoring it when needed, using MmeasSaveMarker(), MmeasRestoreMarker(), or MmeasStream(). Saving a marker buffer stores all of the marker settings, but does not save any found marker results.
You can also use MmeasCalculate() to take measurements between two markers. For more information, see the Measurements between two markers section later in this chapter.