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. In Workspace Explorer open workspace Examples and in Film strip window select NailsScrewsAndNuts dataset. Drag the Image channel to the ACQUIRE section.

  2. Add the ExtractBlobs_Intensity filter to extract each object from the background. Connect the ReadFilmstrip output to inImage of the current one.

  3. Set inThresholdParams.Threshold to 200 to separate the darker parts from the brighter background.

  4. Set the inSplittingParams.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 the outBlobs from the previous filter to the inRegions of the current one.

  6. Set the 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 the 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
ExtractBlobs_Intensity Segments an image into blobs by thresholding using a single value.
ClassifyRegions Use this filter when you have an array of regions and you want to select some of them for further processing.

Further Readings

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