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
Image with its inspection result (OK or not OK) and a rectangle indicating the border between chocolate and waffle area.
Hints
Waffle can be located by thresholding to a region. To check whether a chocolate 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.
Solution (FIS)
- Add filter EnumerateImages to program.
- To threshold an image, use ThresholdToRegion. Set inMaxValue to 200.
- Add filter ErodeRegion and set inRadiusX to 20. Connect outRegion from a previous filter with inRegion of the current one.
- To bound the region, use RegionBoundingRectangle_OrNil filter.
- To create a rectangle region, use CreateRectangleRegion and set inFrameWidth to 656 and 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 ThresholdToRegion again, set inMaxValue to 120, connect inImage with outImage output from the EnumerateImages filter and connect inRoi with outRegion from the CreateRectangleRegion filter.
- To determine the area of chocolate within reduced region, right-click on outRegion output, find Property Outputs and choose Area. This selected output should appear in the filter as outRegion.Area.
- To check if the region corresponding to the chocolate has the area in specified range, use TestIntegerInRange filter and connect outRegion.Area with inValue input of the current filter. Set inMaximum to 600.
- Now create a new Step macrofilter, name it DrawResults and connect the outputs from the previous filters to it: outImage from the EnumerateImages filter, outBoundingRectangle from RegionBoundingRectangle filter and outIsInRange from the TestIntegerInRange filter.
- In DrawResults macrofilter, add ChooseByPredicate and connect inConditions macrofilter input with inCondition of the current filter.
- Write OK in inObjectIfTrue input.
- Write NOK: Damaged waffle in inObjectIfFalse input.
- Add DrawStrings_TwoColors filter and connect inImage macrofilter input with inImage input of the current filter.
- Connect outObject with inStrings input.
- Connect inConditions macrofilter input with inConditions of the current filter.
- Add DrawRectangles_SingleColor filter and connect outImage from the previous filter with inImage of the current filter. Connect inRectangle macrofilter input with the inRectangles input of the current filter.
- Connect outImage to the macrofilter output.
Macrofilter Main
Macrofilter DrawResults
Used Filters
Icon | Name | Description |
---|---|---|
![]() |
ChooseByPredicate | E.g. to choose GREEN color to visualize correct objects or RED to visualize defective ones. |
![]() |
EnumerateImages | Emulates image acquisition with images stored on disk. |
![]() |
CreateRectangleRegion | Creates a region corresponding to a given rectangle. |
![]() |
RegionBoundingRectangle_OrNil | Computes the smallest rectangle containing a region; returns NIL if the region is empty. |
![]() |
TestIntegerInRange | Checks whether an integers is in the specified range. |
![]() |
DrawStrings_TwoColors | Draws strings (text) on an image with two colors, depending on the status of each string (usually: green or red for pass/fail status). |
![]() |
ThresholdToRegion | Extraction of a region of objects that can be defined by a salient brightness. |
![]() |
ErodeRegion | Making the region thinner or removing small parts. |
![]() |
DrawRectangles_SingleColor | Draws rectangles on an image with a single color. |
Further Readings
- Blob Analysis - Article presents detailed information about the Blob Analysis technique.