You are here: Start » Tutorial Exercises » Count Nails (nails)

Count Nails (nails)

Aim

Devise an algorithm that counts the nails present among various objects in an image.

Input

A single image with different objects present.

The input image is stored in the nails directory.

Output

An Integer value with number of found nails.

Expected value: 5

Hints

The backlight source makes objects very contrastive. Objects can be separated from the background very easily using the basic ThresholdToRegion filter.

Objects are physically separated and that makes it possible to split them into separate blobs using the SplitRegionIntoBlobs filter.

Regions can be classified using the ready-to-use ClassifyRegions tool which can be found in Toolbox, Region Analysis, Region Logic group.

Aurora Vision Studio also provides separate filters that can be used to classify blobs which can be found in Toolbox, Region Analysis, Region Feature group.

These filters can be very useful to preform classification using different regions' features.

Labeling connections is explained in this article.

Solution (AVS)

  1. Add LoadImage filter to the project and select the input image path. It is also possible to drag an image file from outside of Aurora Vision Studio window.

  2. To extract the objects from the image background add the ThresholdToRegion filter and set its inMaxValue to 200. Uncheck optional value in input inMinValue to set it to its default value.

  3. To separate each object use SplitRegionIntoBlobs. Result of this operation is presented in the picture below. Each blob is displayed with a different color:

  4. Experiment with different region features by adding multiple filters from the Region Features category.

  5. Three different region features are presented in the picture below: RegionCircularity, RegionArea and RegionDiameter:

    To show array indexes turn this option on in the top toolbar:

    In this case the most useful feature is provided by the RegionDiameter filter and this value is used in further nails classification.

  6. Add ClassifyRegions filter to the project, select DiameterLength option at inFeature input and choose appropriate values of inMinimum and inMaximum parameters.

  7. Expand outAccepted output and show Count value in a new preview window.

Macrofilter Main counts nails among the other objects.

Further Readings

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