Distance Transformation
This function block converts a binary or grayscale image into a continuous distance map where brighter pixels represent larger distances from foreground (white) regions. It is useful for segmentation refinement, shape analysis and preparing images for contour or watershed-based processing.
π₯ Inputs
ImageGray This block expects a binary or single-channel grayscale image as input.
π€ Outputs
ImageGray Outputs a single-channel grayscale image where pixel values represent computed distance values (normalized for visualization and subsequent processing).
πΉοΈ Controls
Transormation Type A dropdown that lets you choose the distance metric used for the transformation. Options correspond to commonly used distance measures (for example, Euclidean, Manhattan, and Chessboard styles). Select the one that best fits your measurement/segmentation needs.
π¨ Features
Produces a continuous distance map from a binary/grayscale input to reveal how far each background pixel is from the nearest foreground pixel.
Normalized output suitable for visualization and for feeding into later processing blocks.
Simple dropdown control to switch between distance metric types to adapt behavior for different shapes and layouts.
βοΈ Running mechanism
When the block runs it reads the provided grayscale/binary image, computes a distance value for each pixel using the selected distance metric, normalizes the result for easy viewing, and outputs the resulting grayscale distance map. Use a valid binary foreground/background input for best results.
π Usage instructions
Provide a clean binary or well-thresholded grayscale image to the
ImageGrayinput.Choose the desired
Transormation Typefrom the dropdown.Use the resulting
ImageGrayoutput as visualization or feed it into other analysis blocks.
π‘ Tips and Tricks
Preprocess with
Image ThresholdorImage Adaptive Thresholdto obtain a clean binary foreground before using this block.Use
Blurto reduce small noise before thresholding β this often produces smoother distance maps.After distance transformation, combine with
Watershed AlgorithmorImage Skeletonizeto perform object separation or extract medial axes.Use
Find Contour,Approximate Contour,Minimum RectangleorMinimum Circleon the cleaned/segmented result to obtain geometric measurements or bounding shapes.Limit analysis to a region of interest by using
Image ROI SelectorGet ROIbefore feeding the image into this block.Visualize outputs with
Show Imageand store important results withImage LoggerorImage Write.
π οΈ Troubleshooting
If the output looks noisy or scattered, ensure the input is a well-defined binary mask; consider using
Morphological Transformationsto remove small artifacts.If very large values or unexpected scaling appear, re-check upstream preprocessing steps (thresholding and noise removal) and use the visualization via
Show Imageto inspect intermediate results.For poor separation of touching objects, try changing the
Transormation Typeor follow the distance transform withWatershed Algorithmto improve segmentation.
Last updated
Was this helpful?