You are here: Start » Program Examples » Pattern Cutting

Pattern Cutting

Aim

The task is to detect the gaps in the grid pattern and fill them.

Input

An image with the grid pattern.

Output

Region representing the gaps in the input pattern.

Hints

To detect the gaps, at the beginning fill them using OpenImage and CloseImage filters. Then use ThresholdToRegion_Relative filter to identifies pixels representing the gaps.

Solution (AVS)

  1. Add LoadImage filter to get load image of pattern.

  2. To detect horizontal lines add CloseImage filter and set its input inRadiusY to 0.

  3. Add OpenImage filter and connect its input to outImage. Set its input inRadiusY to 0.

  4. To obtain an image with continuous horizontal lines, create a global parameter MaxGapLength of type Integer by clicking Create New Global Parameter... Set its value to 20.

  5. Connect the created global parameter to inRadiusX inputs of both CloseImage and OpenImage filters.

  6. Add another CloseImage filter and connect its input with the loaded image. Set inRadiusX to 0.

  7. Add OpenImage filter and connect its input to outImage. Set inRadiusX to 0.

  8. Connect the global parameter MaxGapLength to inRadiusY input ports of both CloseImage and OpenImage filters.

  9. To compose horizontal and vertical lines add MinimumImage filter.

  10. The last step is to extract a region representing the gaps. This can be achieved using ThresholdToRegion_Relative filter.

  11. Connect inImage to the output of LoadImage filter.

  12. Connect inBaseImage to the output of MinimumImage.

  13. Set inMinRelativeValue to 30. Drag the output outRegion and put it to the Data Preview Window to display the result.

Macrofilter Main

Used Filters

Icon Name Description
CloseImage E.g. removal of the "pepper" component of salt-and-pepper noise.
LoadImage Loads a single image from a file.
ThresholdToRegion_Relative Thresholds an image with a different threshold value for each pixel (inBaseImage(x, y) + inValue).
OpenImage E.g. removal of the "salt" component of salt-and-pepper noise.
MinimumImage Creates an image from the lower pixel values of each corresponding pair.

Further Readings