You are here: Start » Program Examples » Nails, Screws and Nuts

Nails, Screws and Nuts

Aim

The aim of the program is to distinguish nails from screws and nuts.

Input

The image of the parts.

Output

Detected nails and their dimensions.

Hints

In this example the easiest way to achieve the goal is to use Blob Analysis technique.

Labeling connections is explained in this article.

Solution (AVS)

  1. Add the LoadImage filter.
  2. Add the ExtractBlobs_Intensity filter to extract each object from the background. Connect outImage output from a previous filter to inImage of the current one.
  3. Click on the filter and uncheck the inThresholdParams.MinIntensity parameter. Set inThresholdParams.MaxIntensity to 200 to separate the darker parts from the brighter background.
  4. Set the inBlobSplittingParams.MinArea parameter to 10 to find only these parts of required area and to make sure any noise is removed.
  5. Add the ClassifyRegions filter. Connect outBlobs from the previous filter to inRegions of the current one.
  6. Set inFeature to Elongation since it is one of the most distinctive features of nails. Please note that screws are not as long as nails, so set inMinimum to 10 to reject regions corresponding to screws.
  7. If you display the outBlobs output on the preview window and outValues on another one, please note that you can click on the button marked below to toggle displaying indexes next to the image arrayed elements and relate parts' indexes with their corresponding values of elongation:

Macrofilter Main

Used Filters

Icon Name Description
LoadImage Loads a single image from a file.
ClassifyRegions Use this filter when you have an array of regions and you want to select some of them for further processing.
ExtractBlobs_Intensity Segments an image into blobs by thresholding.

Further Readings

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