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
Iterationscontrol appears only for erosion/dilation to keep the interface simple.Works with both color and grayscale images.
π Usage Instructions
Connect an image-producing block to the
Image Anyinput.Choose the desired
Morph Typedepending on your goal (e.g., useMORPH_OPENto remove small objects,MORPH_CLOSEto close small holes).Select
Morph Shapeto better match object geometry (elliptical kernels for round features, rectangular for box-like).Adjust
Kernel Sizeto control the spatial extent of the operation.If using
MORPH_ERODEorMORPH_DILATE, setIterationsto repeat the operation for stronger results.Inspect the transformed image from the
Image Anyoutput.
π 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
DenoisingorBlurbefore 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 ThresholdorImage Adaptive Threshold.To focus processing on a smaller area and speed up results, crop upstream using
Image ROI Selectthen apply morphology only to the ROI.After morphological cleanup, use shape-analysis blocks such as
Find Contour,Approximate Contour,Minimum Rectangle, orHull Convexto extract geometry and measurements more reliably.Visualize results with
Show Imageor annotate with drawing blocks likeDraw RectangleorDraw Result On Imageto produce clear feedback for operators.Use
Apply Maskto preserve only important regions while applying morphological operations to the masked area.
π οΈ Troubleshooting
If the effect looks too weak, increase
Kernel Sizeor the number ofIterations(for Erode/Dilate).If useful details disappear, try a smaller
Kernel Sizeor switch kernelMorph Shapeto 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 Resizeror crop withImage ROI Selectbefore the block.
Last updated