You are here: Start » Program Examples » Waffles
Waffles
Aim:
The aim of the program is to separate waffles with a proper amount of chocolate from the damaged ones.
Input:
Several images of waffles. The amount of chocolate on the waffles is variable.
Output:
An image with its inspection result (OK or NOT OK) and a rectangle indicating the border between the chocolate and waffle area.
Hints:
Waffles can be located by thresholding to a region. To check whether the chocolate has spilled out of the border area, a region of interest has to be reduced by performing a morphological erosion on the region corresponding to the waffle.
Labeling connections is explained in this article.
Solution (AVS):
- In Workspace Explorer, open the workspace Examples, and in the Filmstrip window, select the Waffles dataset. Drag the Image channel to the ACQUIRE section.
- To threshold an image, use the ThresholdToRegion. Set the inMaxValue to 200.
- Add the ErodeRegion filter and set the inRadiusX to 20. Connect the outRegion from a previous filter with inRegion of the current one.
- To bound the region, use the RegionBoundingRectangle_OrNil filter.
- To create a rectangle region, use the CreateRectangleRegion and set the inFrameWidth to 656 and the inFrameHeight to 492. Connect the outBoundingRectangle from a previous filter with the inRectangle input.
- If you want to threshold the image just in area of the waffle, use the ThresholdToRegion again, set the inMaxValue to 120, connect the inImage with the ReadFilmstrip output and connect the inRoi with the outRegion from the CreateRectangleRegion filter.
- To determine the area of chocolate within reduced region, right-click on the outRegion output, find Property Outputs and choose Area. This selected output should appear in the filter as the outRegion.Area.
- To check if the region corresponding to the chocolate has the area in a specified range, use the TestIntegerInRange filter and connect the outRegion.Area with the inValue input of the current filter. Set the inMaximum to 600.
-
Now create a formula with two outputs:
-
Add the DrawStrings_MultiColor filter and connect the ReadFilmstrip output with the inImage input of the current filter.
- Connect the ResultStrings with the inStrings input.
- Connect the ResultColorID filter output with the the inColorIds of the current filter.
- Add the DrawRectangles_SingleColor filter and connect the outImage from the previous filter with the inImage of the current filter. Connect the outBoundingRectangle with the inRectangles input of the current filter.
- Use the outImage as a preview.
Macrofilter Main
Used Filters
Icon | Name | Description |
---|---|---|
![]() |
CreateRectangleRegion | Creates a region corresponding to a given rectangle. |
![]() |
DrawRectangles_SingleColor | Draws rectangles on an image with a single color. |
![]() |
DrawStrings_MultiColor | Draws strings (text) on an image with multiple colors. |
![]() |
ErodeRegion | Making the region thinner or removing small parts. |
![]() |
RegionBoundingRectangle_OrNil | Computes the smallest rectangle containing a region; returns NIL if the region is empty. |
![]() |
ThresholdToRegion | Extraction of a region of objects that can be defined by a salient brightness. |
Further Readings
- Blob Analysis - Article presents detailed information about the Blob Analysis technique.