| 1 |
.. _ref-to-contour-detection: |
| 2 |
|
| 3 |
Contour Detection |
| 4 |
================= |
| 5 |
|
| 6 |
DataLab provides a "Contour Detection" feature which is based on |
| 7 |
`the marching cubes algorithm <https://courses.cs.duke.edu/fall01/cps124/resources/p163-lorensen.pdf>`_. |
| 8 |
|
| 9 |
.. figure:: /images/contour_detection/contour_app_param.png |
| 10 |
|
| 11 |
Contour detection parameters. |
| 12 |
|
| 13 |
How to use the feature: |
| 14 |
- Create or open an image in DataLab workspace |
| 15 |
- Eventually create a ROI around the target area |
| 16 |
- Select "Contour detection" in "Analysis" menu |
| 17 |
- Enter parameter "Shape" ("Ellipse", "Circle" or "Polygon") |
| 18 |
- Optionally, enable "Create regions of interest" to automatically create |
| 19 |
ROIs around each detected contour: |
| 20 |
|
| 21 |
* Choose ROI geometry: "Rectangle" or "Circle" |
| 22 |
* ROI size is automatically calculated based on the minimum distance |
| 23 |
between detected contours (to avoid overlap) |
| 24 |
* This feature requires at least 2 detected contours |
| 25 |
* Created ROIs can be useful for subsequent processing on each contour area |
| 26 |
|
| 27 |
.. figure:: /images/contour_detection/contour_app_results.png |
| 28 |
|
| 29 |
Contour detection results (see test "contour_app.py") |
| 30 |
|
| 31 |
Results are shown in a table: |
| 32 |
- Each row is associated to a contour |
| 33 |
- First column shows the ROI index (0 if no ROI is defined on input image) |
| 34 |
- Other columns show contour coordinates: |
| 35 |
4 columns for circles (coordinates of diameter), |
| 36 |
8 columns for ellipses (coordinates of diameters) |
| 37 |
|
| 38 |
.. figure:: /images/contour_detection/contour_app.png |
| 39 |
|
| 40 |
Example of contour detection. |
| 41 |
|
| 42 |
The contour detection algorithm works in the following way: |
| 43 |
- First, iso-valued contours are computed |
| 44 |
(implementation based on `skimage.measure.find_contours.find_contours <https://scikit-image.org/docs/0.8.0/api/skimage.measure.find_contours.html#find-contours>`_) |
| 45 |
- Then, each contour is fitted to the closest ellipse (or circle) |
| 46 |
|
| 47 |
Feature is based on ``get_contour_shapes`` function from ``sigima.tools`` module: |
| 48 |
|
| 49 |
.. literalinclude:: ../../../../Sigima/sigima/tools/image/detection.py |
| 50 |
:pyobject: get_contour_shapes |