Morphological Transformations

This function block applies morphological operations (erode, dilate, open, close, gradient, tophat, blackhat) on input images. Use it to clean noise, close gaps, extract shapes, or emphasize edges by selecting operation type, kernel shape and size, and iteration count.

πŸ“₯ Inputs

Image Any This input socket accepts the image to be processed (color or grayscale).

(mentioned as an input socket)

πŸ“€ Outputs

Image Any The transformed image after the selected morphological operation is applied.

(mentioned as an output socket)

πŸ•ΉοΈ Controls

Morph Type Select the morphological operation to apply (Erode, Dilate, Open, Close, Gradient, TopHat, BlackHat).

Morph Shape Choose the structuring element shape used by the operation (Rectangle, Cross, Ellipse).

Kernel Size Adjust the kernel size that determines the local neighborhood for the operation. Larger kernels produce stronger effects.

Iterations (shown when Erode or Dilate is selected) Set how many times the operation is repeated to intensify the effect.

🎯 Features

  • Quick selection of common morphological operations with visual control over strength and footprint.

  • Adaptive UI: the Iterations control appears only for erosion/dilation to keep the interface simple.

  • Works with both color and grayscale images.

πŸ“ Usage Instructions

  1. Connect an image-producing block to the Image Any input.

  2. Choose the desired Morph Type depending on your goal (e.g., use MORPH_OPEN to remove small objects, MORPH_CLOSE to close small holes).

  3. Select Morph Shape to better match object geometry (elliptical kernels for round features, rectangular for box-like).

  4. Adjust Kernel Size to control the spatial extent of the operation.

  5. If using MORPH_ERODE or MORPH_DILATE, set Iterations to repeat the operation for stronger results.

  6. Inspect the transformed image from the Image Any output.

πŸ“Š Evaluation

When evaluated, the block processes the connected input image and outputs a modified image showing the selected morphological effect. The output updates whenever inputs or control settings change.

πŸ’‘ Tips and Tricks

  • For noisy inputs, run Denoising or Blur before this block to reduce false small structures and make morphological results more stable.

  • To convert a grayscale image into a clean binary form before morphology, combine with Image Threshold or Image Adaptive Threshold.

  • To focus processing on a smaller area and speed up results, crop upstream using Image ROI Select then apply morphology only to the ROI.

  • After morphological cleanup, use shape-analysis blocks such as Find Contour, Approximate Contour, Minimum Rectangle, or Hull Convex to extract geometry and measurements more reliably.

  • Visualize results with Show Image or annotate with drawing blocks like Draw Rectangle or Draw Result On Image to produce clear feedback for operators.

  • Use Apply Mask to preserve only important regions while applying morphological operations to the masked area.

πŸ› οΈ Troubleshooting

  • If the effect looks too weak, increase Kernel Size or the number of Iterations (for Erode/Dilate).

  • If useful details disappear, try a smaller Kernel Size or switch kernel Morph Shape to better match object form.

  • If artifacts remain after morphology, apply a stronger denoising step or refine thresholding before running this block.

  • If performance is slow on large images, use Image Resizer or crop with Image ROI Select before the block.

Last updated