You are here: Start » Tutorial Exercises » Sorting Blobs (sorting)

Sorting Blobs (sorting)

Aim

Create an application that extracts blobs and sorts them by ascending area. Also find the smallest and the biggest blob.

Input

An image that contains several objects with different shapes and sizes.

Images are stored in the sorting directory.

Output

  1. An array of all blobs sorted by ascending area.
  2. The smallest blob.
  3. The biggest blob.

Hints

In the first step, blobs must be extracted from the image. In this case ThresholdToRegion can be used.

For the main part of the solution consider the following filters: SortRegions, GetMinimumRegion, GetMaximumRegion.

Labeling connections is explained in this article.

Solution (AVS)

  1. Load an image using LoadImage filter.

  2. Add the ThresholdToRegion filter to extract objects from the background. Set inMaxValue to 250.0 and set inMinValue to Auto.

  3. Split the extracted region into separate objects using the SplitRegionIntoBlobs filter. To remove all graphical noises set the value of inMinBlobArea to 500. This option removes all smaller elements like dust, scraps, etc.

  4. Add GetMaximumRegion to find the largest blob. By default elements are sorted by their area. Check other region's features available in inFeature.

  5. Add GetMinimumRegion to find the smallest blob.

  6. Add SortRegions to sort blobs by area.

  7. Use three separate data preview windows to visualize the results.

  8. Use the "Display indexes" option in the top toolbar on the data preview window with the results of the SortRegions array to see the order of the elements.

Macrofilter Main performs sorting and selection operations on the array of regions.

Further Readings

  • Blob Analysis - Article presents detailed information about the Blob Analysis technique.