| 1 |
.. _ref-to-2d-peak-detection: |
| 2 |
|
| 3 |
2D Peak Detection |
| 4 |
================= |
| 5 |
|
| 6 |
DataLab provides a "2D Peak Detection" feature which is based on a |
| 7 |
minimum-maximum filter algorithm. |
| 8 |
|
| 9 |
.. figure:: /images/2d_peak_detection/peak2d_app_param.png |
| 10 |
|
| 11 |
2D peak detection parameters. |
| 12 |
|
| 13 |
How to use the feature: |
| 14 |
- Create or open an image in DataLab workspace |
| 15 |
- Select "2d peak detection" in "Analysis" menu |
| 16 |
- Enter parameters "Neighborhoods size" and "Relative threhold" |
| 17 |
- Optionally, enable "Create regions of interest" to automatically create |
| 18 |
ROIs around each detected peak: |
| 19 |
|
| 20 |
* Choose ROI geometry: "Rectangle" or "Circle" |
| 21 |
* ROI size is automatically calculated based on the minimum distance |
| 22 |
between detected peaks (to avoid overlap) |
| 23 |
* This feature requires at least 2 detected peaks |
| 24 |
* Created ROIs can be useful for subsequent processing on each peak area |
| 25 |
(e.g., contour detection, measurements, etc.) |
| 26 |
|
| 27 |
.. figure:: /images/2d_peak_detection/peak2d_app_results.png |
| 28 |
|
| 29 |
2d peak detection results (see test "peak2d_app.py") |
| 30 |
|
| 31 |
Results are shown in a table: |
| 32 |
- Each row is associated to a detected peak |
| 33 |
- First column shows the ROI index (0 if no ROI is defined on input image) |
| 34 |
- Second and third columns show peak coordinates |
| 35 |
|
| 36 |
.. figure:: /images/2d_peak_detection/peak2d_app_zoom.png |
| 37 |
|
| 38 |
Example of 2D peak detection. |
| 39 |
|
| 40 |
The 2d peak detection algorithm works in the following way: |
| 41 |
- First, the minimum and maximum filtered images are computed |
| 42 |
using a sliding window algorithm with a user-defined size |
| 43 |
(implementation based on `scipy.ndimage.minimum_filter <https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.minimum_filter.html>`_ |
| 44 |
and `scipy.ndimage.maximum_filter <https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.maximum_filter.html>`_) |
| 45 |
- Then, the difference between the maximum and minimum filtered |
| 46 |
images is clipped at a user-defined threshold |
| 47 |
- Resulting image features are labeled using `scipy.ndimage.label <https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.label.html>`_ |
| 48 |
- Peak coordinates are then obtained from labels center |
| 49 |
- Duplicates are eventually removed |
| 50 |
|
| 51 |
The 2d peak detection parameters are the following: |
| 52 |
- "Neighborhoods size": size of the sliding window (see above) |
| 53 |
- "Relative threshold": detection threshold |
| 54 |
- "Create regions of interest": if enabled, automatically creates ROIs around |
| 55 |
each detected peak (requires at least 2 peaks) |
| 56 |
- "ROI geometry": shape of the ROIs ("Rectangle" or "Circle") |
| 57 |
|
| 58 |
Feature is based on ``get_2d_peaks_coords`` function from ``sigima.tools`` module: |
| 59 |
|
| 60 |
.. literalinclude:: ../../../../Sigima/sigima/tools/image/detection.py |
| 61 |
:pyobject: get_2d_peaks_coords |