You are here: Start » Program Examples » Mounts (Segmentation)

Mounts (Segmentation)

Aim

This example shows the difference between Edge-based segmentation and Grayscale-based segmentation and how to get outer contours of blobs.

Input

An image of several mounts. There are also damaged mounts.

Output

An array of contours corresponding to the individual undamaged mount.

Solution (AVS)

  1. Add EnumerateImages filter to get load an image of some disk directory.

  2. Add SegmentImage_Edges filter to segment the image into blobs using image edges as their borders.

  3. Blobs of the undamaged mounts have similar area, therefore set the inMinArea to 1800 and the inMaxArea to 3000, this causes in elimination of damaged mounts.

  4. Add SegmentImage_Gray filter to segment the image into blobs examining difference between values of neighbouring pixels.

  5. Set inMaxDifference to 100.

  6. Set inDifferenceMeasure to Mean.

  7. Specify the range of area of the undamaged mount. Set inMinArea to 2050 and inMaxArea to 3000.

  8. Create a Step macrofilter DetectContour. Create the macrofilter's inputs of types Image and Region.

  9. To close mount's holes, add DilateRegion filter and connect its input with the macrofilter input.

  10. Add DetectEdges_AsPaths filter to extract the edges of the mount. Connect its input inRoi with an output of DilateRegion filter.

  11. Add RegionMassCenter filter to compute a Mass Center point of the region.

  12. To obtain an outer path of the mount, add SelectOuterPaths and connect its inputs with outEdges and outMassCenter.

  13. Add GetArrayElement filter and extract the element with inIndex 0.

Macrofilter Main

Macrofilter DetectContour

Used Filters

Icon Name Description
SegmentImage_Edges Detection of objects of undefined shape, but characterized by good contrast to the background and fairly uniform internal brightness.
DetectEdges_AsPaths Consistent detection of contours of variable or unpredictable shape, e.g. screw thread outline or a custom piece of textile.
GetArrayElement Extracts a single element from an array at the specified index.
SelectOuterPaths Selects paths which do not obstruct visibility of other paths from a point.
DilateRegion Making the region thicker or filling-in small holes within it.
RegionMassCenter Computes a point with coordinates equal to the average coordinates of the region's pixels.
LoadImage Loads a single image from a file.

Further Readings

  • 1D Edge Detection - The article explaining how edge detection filters work.
  • Blob Analysis - Article presents detailed information about the Blob Analysis technique.