You are here: Start » Tutorial Exercises » Detecting Chocolate Coverage (detect_chocolate)

Detecting Chocolate Coverage (detect_chocolate)

Aim

Prepare an algorithm that calculates the fraction of a wafer's area that is covered with chocolate.

Input

A set of images of a single chocolate wafer.

The input image is stored in the detect_chocolate directory.

Output

The region not covered with chocolate layer and the percentage of this area.

Hints

This exercise shows how to use a chain of Blob Analysis techniques.

The solution should consist of the following steps:

  1. Extracting the wafer region.
  2. Extracting the chocolate covered region.
  3. Calculating the ratio of the area not covered with chocolate.

The best way to calculate the coverage ratio is to use a formula.

Labeling connections is explained in this article.

Solution (AVS)

  1. Add EnumerateImages filter to ACQUIRE section to get images from the directory.

  2. Find the wafer using ThresholdToRegion filter (PROCESS section) with parameters: inMaxValue set to 250 and inMinValue set to Auto. These values allow the program to get the bar from a contrasting background (backlight).

  3. As you can see, the chocolate is the darkest part of the image in the selected region. To extract this part of the bar, use ThresholdToRegion filter with inRoi reduced to the previously found region. This filter should select only the dark part of the bar. Set inMinValue to Auto and inMaxValue to 102.

  4. Next, add two RegionArea filters to calculate the area of each region.

  5. To calculate the coverage ratio, create a formula with inputs created from the RegionArea outputs.

  6. Present the results in a Preview window.

Main macrofilter finds the uncovered layer of chocolate using the Blob Analysis technique.

Additional Tasks

  • Create an algorithm that will automatically calculate the color of chocolate and it will use it to detect the not covered parts of the wafer.

Further Readings

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