<a id="easygauge-measure-fit"></a>

# Measurement and Fitting Parameters

<a id="easygauge-finding-sample-points"></a>

## Finding Sample Points

All the gauges and [`ESamplePath`](../../../doxygen_cpp/classeVision_1_1ESamplePath.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1ESamplePath.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ESamplePath.html) contain all the point measurement parameters, with default values that detect reasonably contrasted edges:

- **Transition strength**: [`SetThreshold`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a185e9cc49dccd3773d21e6dee807562d) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a9e30f8e604bf1713eacad5aeb4c0ae97) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a52e3ddd2f2148df40776ece885d77ee0), [`SetMinAmplitude`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a02cc4c1a2bb74b7bc391eda6a3f05f16) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a070930eaa83a8b025656051d398222d6) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a04643eb5d33b92bd84f5b9dbf497ad96) and [`SetMinArea`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a628258955773334dce4d35178776c2e3) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a6667ef228e55f1d15284a4983ccd2cd2) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#aac021719bbd9f1a11a2a439cd57d71a5).
- **Transition type**:  [`SetTransitionType`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a4928445b5def3195d04ab248e2db5ec3) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a347bd2f0467284f265cd27798d218fd4) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a1d2bafdf28aa1c96a15ff665794b7244)
- **Transition choice**: [`SetTransitionChoice`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a7e122f57948b56f44164aa6a3038c192) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#ad4a20a6e2f9f324ed51ef72b5f6654a7) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#ac984f97f8425d1e38e2581e3922b7086) and [`SetTransitionIndex`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a74f05fd0a12a15b7dffdb1e322753b2f) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#af638cb91bfe6f669f32c7d8d83b3dff7) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#ab4945e8fa75c9c25eab2f33a1c7adb37).
- **Local filtering** for noise immunity: [`SetThickness`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a08490f398c01c9fcc1e6b56ea622f05e) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a8f7b6e322198dfdda118d58eea446e37) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a1fb6127d5857ffdf8b87ff59eb766fa6) and [`GetSmoothing`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#ab508543043a4bf3e61c10ca332fedaa8) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#ac13eafc7ed3273beee7dcbcaf78c60e2) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a9cb6c8e1468de33ed0e764860eecf81c).
  - Sampling area (rectangular by default) for **transverse filtering** [`SetRectangularSamplingArea`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#ae01ba2fc95ef592c805c14d0a9700cba) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#ab4baca8f0f0f17e35138a28bba3c26dd) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a5907f80b91606e01d30b289a85440e68).

<a id="easygauge-transitions-parameters-strength"></a>

### Transition Strength

The [`threshold`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a185e9cc49dccd3773d21e6dee807562d) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a9e30f8e604bf1713eacad5aeb4c0ae97) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a52e3ddd2f2148df40776ece885d77ee0) level is very important:

- Too high and significant transitions can be missed.
- Too low and noise can cause false transitions.

To resolve this dilemma, the **EasyGauge** transition selection mechanism can reject low contrast or false edges:

- The **transition strength** is measured by the peak amplitude and the area.
- Every edge measurement determine the peak amplitude and the area.
  - The peak amplitude is the difference between the peak value and the threshold.
  - The peak area is the area under the peak curve and the horizontal line at the threshold value.
- If either value falls below the [`minimum amplitude`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a02cc4c1a2bb74b7bc391eda6a3f05f16) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a070930eaa83a8b025656051d398222d6) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a04643eb5d33b92bd84f5b9dbf497ad96) or the [`minimum area`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a628258955773334dce4d35178776c2e3) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a6667ef228e55f1d15284a4983ccd2cd2) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#aac021719bbd9f1a11a2a439cd57d71a5), the peak is disregarded and no point is assumed at that location.

![](assets/images/easygauge/17813.webp)![](assets/images/easygauge/17814.webp)

<a id="easygauge-transitions-parameters-selection-type"></a>

### Transition Type

Select the type of transition to find with [`SetTransitionType`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a4928445b5def3195d04ab248e2db5ec3) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a347bd2f0467284f265cd27798d218fd4) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a1d2bafdf28aa1c96a15ff665794b7244):

- Simple edges:
  - White to Black ([`Wb`](../../../doxygen_cpp/namespaceeVision.html#a503eb9d53e76fdabfeec1a6049ce63faa1e92879f7233cddf64ae58f60a841f65) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#a6c6c76fcc0cfe176b06aa486c594fe71) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ETransitionType.html#ad3d78ab737556dc4369cb384a5b92d9d))
  - Black to White ([`Bw`](../../../doxygen_cpp/namespaceeVision.html#a503eb9d53e76fdabfeec1a6049ce63faa09442b9e58afed0973aeddab0dd4af1f) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#a6c6c76fcc0cfe176b06aa486c594fe71) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ETransitionType.html#a3dfdfdce8087e55eb23da95fbc45a975))
  - indifferent polarities ([`BwOrWb`](../../../doxygen_cpp/namespaceeVision.html#a503eb9d53e76fdabfeec1a6049ce63faa51af95d4719e4dd61a78828c727f6796) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#a6c6c76fcc0cfe176b06aa486c594fe71) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ETransitionType.html#afc7190abe61996f230c94032f6e70337))

  ![](assets/images/easygauge/pointlocationblacktowhite.webp)![](assets/images/easygauge/pointlocationwhitetoblack.webp)![](assets/images/easygauge/pointlocationindifferent.webp)
- Complex edges:
  - Black to white to black ([`Bwb`](../../../doxygen_cpp/namespaceeVision.html#a503eb9d53e76fdabfeec1a6049ce63faa856a6d6f63eae15e3c4b370ce87470d5) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#a6c6c76fcc0cfe176b06aa486c594fe71) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ETransitionType.html#a05bed095d891ac091f8df552d9cb215d))
  - White to black to white ([`Wbw`](../../../doxygen_cpp/namespaceeVision.html#a503eb9d53e76fdabfeec1a6049ce63faa5751815ca7c369c6a244ee7593cd5ad9) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#a6c6c76fcc0cfe176b06aa486c594fe71) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ETransitionType.html#af3048797bf02c51bb5e5a576d72136d8))

  ![image](assets/images/easygauge/pointlocationbwb.webp)

  #### HINT
  You cannot normally detect transitions using the default threshold value (20) as BWB or WBW transitions base the peak analysis on the gray level profile along the sample path and not its first derivative.

<a id="easygauge-transitions-parameters-selection-choice"></a>

### Selecting the Most Relevant Transition

There can be multiple transitions that match the transition detection parameters. The parameter [`SetTransitionChoice`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a7e122f57948b56f44164aa6a3038c192) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#a6f6ea8698bdeb6b9b55195dd5009f2cf) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ETransitionChoice.html) can be used to select the single most relevant transition. With point gauges, this parameter can have the value [`ETransitionChoice_All`](../../../doxygen_cpp/namespaceeVision.html#acd7f1f07a61c7557c8640005e32b48f8) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#a6f6ea8698bdeb6b9b55195dd5009f2cf) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1ETransitionChoice.html), which will return all the transitions matching the other parameter of the detection.

![](assets/images/easygauge/17815.webp)![](assets/images/easygauge/17816.webp)

You can select the single most relevant transition based on 4 criteria:

| ![Best area](assets/images/easygauge/17817.webp)   | ![Best amplitude](assets/images/easygauge/17818.webp)     |
|----------------------------------------------------|-----------------------------------------------------------|
| ![Closest](assets/images/easygauge/17819.webp)     | ![3rd from the start](assets/images/easygauge/17820.webp) |

#### NOTE
When several peaks have the same value (same area, same amplitude…), the last peak is selected.

<a id="easygauge-transitions-parameters-filtering"></a>

### Filtering noise

Filtering the image locally can reduce the noise effects.

There are 2 types of filtering:

* The **transverse (lengthwise) filtering** averages several parallel lines when sampling the image.
  - The [`thickness`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a08490f398c01c9fcc1e6b56ea622f05e) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a8f7b6e322198dfdda118d58eea446e37) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a1fb6127d5857ffdf8b87ff59eb766fa6) determines the number of parallel lines.

    ![Thick point gauge for filtering](assets/images/easygauge/17823.webp)
  - The parallel lines can be contained in a parallelogram or a rectangle ([`SetRectangularSamplingArea`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#ae01ba2fc95ef592c805c14d0a9700cba) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#ab4baca8f0f0f17e35138a28bba3c26dd) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a5907f80b91606e01d30b289a85440e68)).

    ![Best area](assets/images/easygauge/17824.webp)    ![Best amplitude](assets/images/easygauge/17825.webp)
* The **longitudinal (crosswise) uniform filtering** can also be applied to the resulting profile curve ([`SetSmoothing`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#afa38e86d24691d38f8e2b57c57936718) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#ac13eafc7ed3273beee7dcbcaf78c60e2) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a9cb6c8e1468de33ed0e764860eecf81c))

<a id="easygauge-configuring-sample-paths"></a>

## Configuring Sample Paths

* Use [`SetSamplingStep`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a271a782827fb6a0bbedd089e35704d3f) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a18c5afeb682b35834c4f56bef2d28823) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#ab2d850791d0d8fc44c79c9de79fd8258) to set the **spacing between the paths**.
  - Use [`GetNumSamples`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#aaf4540259ba164d14fe45fc86918f3ed) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#ac337e4244ee3ab86e4f5f3063dbcb1ae) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a980c9da035ffa49fe45712d8111f0424) to get the number of paths that are sampled.
* Use [`SetTolerance`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a2010988f5449f0c629d00af67817db03) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a99f6c19c11f551581aec80a247bb5d10) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a9ffa14ce2d0fcba75140eb28d6d7e5c0) to set the length of these paths that is the half-length of the line segment. The **tolerance** is how far to look for edge crossings around the nominal shape.

  #### NOTE
  Note that the [`EPointGauge`](../../../doxygen_cpp/classeVision_1_1EPointGauge.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EPointGauge.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EPointGauge.html) has no tolerance because it consists in the measurement of edge-crossing on its nominal line.

![Point gauge](assets/images/easygauge/measurement_concepts.jpg)

<a id="easygauge-fit-shape"></a>

## Fitting Parameters

* **[Outlier rejection](principles.html.md#easygauge-principles-complex-shapes)** parameters:
  * The [`number of iterations`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a2acdae6bb39d4fe00cd9b1cfb320bcc3) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a5aee3ba88c0ed7c889850e979fe35765) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#ab6e4130fa7398cea886c89f4d6060408) in the algorithm.
  * The [`threshold`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#af4a610377ecc31fc2676ea773e3aad51) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#ada249ceb11f155ce18e6278a98451991) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a6b2e3106aefba5e527a3949c00aa8846) used to tag a sample point as an outlier.
* **Skip ranges**:
  - The skip ranges define the exclusion ranges for the paths. The sample point indexes in the skip ranges are not taken into account to fit the model.

    #### NOTE
    The skip ranges apply to all gauge models but the polygon gauge.
  - Use [`AddSkipRange`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#aa24e6fe906f717ffac0e73f9faeb5213) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a32a44d421132f8cba02a998990dbd2b0) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#ab020d1dc4c47b8ff825ae507f559a95c) to define several skip ranges.
  - Use [`RemoveSkipRange`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a961d0135da9203abc953db20c15e5155) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a98f6626a8dcf2dc343264f1e38d01087) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a3aaa25672bca8719382867bba720a410), [`RemoveAllSkipRanges`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a797541d91b8c0125960b8001f791f0ab) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a88b5cacd95a0fc0142107c56871c91d6) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a84de91962cbb067f0042189ced8bbbbf) and [`GetSkipRange`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#a18b1baa37972ee68aba05cfe9c2ba2c4) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a2a7af900125b5d3d73df9cc60233212b) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a12a47015d4826bfc243eb4df8ca107f6) to manage the skip ranges.
  - Use the attribute [`EDrawingMode_PointsInSkipRange`](../../../doxygen_cpp/namespaceeVision.html#a46a5eff0a429fb8f7157564a9c7e620c) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#a22d98bfe7b35ea321e8d60e62e838438) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EDrawingMode.html) with the method [`Draw`](../../../doxygen_cpp/classeVision_1_1EBaseGauge.html#aa8af0a9d89d6dbe0fcd676102f8876e0) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EBaseGauge.html#a238794f6aaf4c6af7759ed8549e8380a) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBaseGauge.html#a50c184a719e5c05380fa1ab57b54a157) to display the skipped points.
