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 the OpenImage and the CloseImage filters. Then use the ThresholdToRegion_Relative filter to identifies pixels representing the gaps.

Solution (AVS)

  1. In Workspace Explorer open workspace Examples and in Film strip window select PatternCutting dataset. Drag the Image channel to the ACQUIRE section.

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

  3. Add the OpenImage filter and connect its input to the 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 the inRadiusX inputs of both CloseImage and OpenImage filters.

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

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

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

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

    • Connect its inImage1 input to the outImage of the OpenImage filter, which is responsible for filling gaps in the horizontal lines.
    • Connect its inImage2 input to the outImage of the OpenImage filter, which is responsible for filling gaps in the vertical lines.
  10. The last step is to extract a region representing the gaps. This can be achieved using ThresholdToRegion_Relative filter.

  11. Connect the inImage to the output of the ReadFilmstrip filter.

  12. Connect the inBaseImage to the output of the MinimumImage.

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

Macrofilter Main

Used Filters

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

Further Readings