# Profile

[Code Snippets](../../../resources/code_snippets/general_purpose/easyimage/vector_operations/profilesampling.html.md)

## Profile Sampling

A **profile** is a series of pixel values sampled along a line, a path or a contour in an image.

* [`EasyImage::ImageToLineSegment`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#ab8e2649e4d8dd3b75ff7dc505f9c56c6) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a52f016f49cfa6000d2805b389edd5261) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#ace747397f1e30069e8372de9a92b8d87) copies the pixel values along a given line segment (arbitrarily oriented and wholly contained within the image) to a vector. The vector length is adjusted automatically. This function supports flexible masks.
* A **`path`** ([`EPathVector`](../../../doxygen_cpp/classeVision_1_1EPathVector.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EPathVector.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EPathVector.html)) is a series of `pixel coordinates` ([`EPath`](../../../doxygen_cpp/structeVision_1_1EPath.html) [<sub>.NET</sub>](../../../doxygen_cs/structeVision_1_1EPath.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EPath.html)) stored in a vector.<br />
  \\\\
  [`EasyImage::ImageToPath`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a7a20aeb4668c584c840d456070caa420) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a7f15e8d5dfe5662eccbcd2b748e0a55d) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a82e44732dfb13bcf1bad6d9d1affbfb6) copies the corresponding pixel values to the vector. This function supports flexible masks.
* A **contour** is a closed or not (connected) path, forming the boundary of an object.<br />
  \\\\
  [`EasyImage::Contour`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a0eb23581d3189f1ef3bf0798dafec519) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a8d01d6f459364a648491aafdfc7c40bf) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a866c657ad002337a641ac0fd85dcd89d) follows the contour of an object, and stores its constituent pixels values inside a profile vector.

## Profile Analysis

The profile can be processed to find peaks or transitions:

* A transition corresponds to an object edge (black to white or white to black). It can be detected by taking the first **derivative** of the signal (which transforms transitions (edges) into peaks) and looking for peaks in it.<br />
  \\\\
  [`EasyImage::ProfileDerivative`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a11ef7791fac5f521f5b9030ec61e39ad) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a9bda3ec76d9bedc181289d754bebb47b) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#aaff974b86ac73527e3b3e07ee1eef5be) computes the first derivative of a profile extracted from a gray-level image.<br />
  \\\\
  The [`EBW8`](../../../doxygen_cpp/structeVision_1_1EBW8.html) [<sub>.NET</sub>](../../../doxygen_cs/structeVision_1_1EBW8.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EBW8.html) data type only handles unsigned values, so the derivative is shifted up by 128. Values under [above] 128 correspond to negative [positive] derivative (decreasing [increasing] slope).
* A **`peak`** ([`EPeak`](../../../doxygen_cpp/structeVision_1_1EPeak.html) [<sub>.NET</sub>](../../../doxygen_cs/structeVision_1_1EPeak.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EPeak.html)) is the portion of the signal that is above [or below] a given threshold - the maximum or minimum of the signal. This may correspond to the crossing of a white or black line or thin feature. It is defined by its:
  * [`EPeak::Amplitude`](../../../doxygen_cpp/structeVision_1_1EPeak.html#accb1a13b88a01d8134777b327112b3b3) [<sub>.NET</sub>](../../../doxygen_cs/structeVision_1_1EPeak.html#a1f3f8bcea44f70446f02fc342d96e313) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EPeak.html#ac3dcfc230cb51444db4c4bb54362e59e): difference between the threshold value and the max [or min] signal value.
  * [`EasyImage::Area`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a5dadff178a68c2bafbe2bf71963a95a0) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#aa71b163c50a75b6fdf9829053d6c478d): surface between the signal curve and the horizontal line at the given threshold.

[`EasyImage::GetProfilePeaks`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a01debb6d734a5ae9b66f735fc19f0355) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#ac1f8a19b6f0d8e498a91c2ab55cd8713) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a9f9c442ab86ec8f3fe187c4676bc2a4f) detects max and min peaks in a gray-level profile. To eliminate false peaks due to noise, two selection criteria are used. The result is stored in a `peaks vector` ([`EPeakVector`](../../../doxygen_cpp/classeVision_1_1EPeakVector.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EPeakVector.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EPeakVector.html)).

## Profile Insertion Into an Image

[`EasyImage::LineSegmentToImage`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a08a5e9d112faeebdbab238d25d73f7b5) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a799f72e48c9c5afab402bf90cb1002c4) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#ac91b3d7f6a674439cf6190de281032e6) copies the pixel values from a vector or constant to the pixels of a given line segment (arbitrarily oriented and wholly contained within the image).

[`EasyImage::PathToImage`](../../../doxygen_cpp/classeVision_1_1EasyImage.html#a0a5261ba7c7db1797f3b1776e40e4d95) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyImage.html#a635d12a8cecfb87423bba54b05dd1991) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyImage.html#a133924b9557d3d5eb367740bbe7d1f66) copies the pixel values from a vector or a constant to the pixels of a given path.
