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

  1. Provide a clean binary or well-thresholded grayscale image to the ImageGray input.

  2. Choose the desired Transormation Type from the dropdown.

  3. Use the resulting ImageGray output as visualization or feed it into other analysis blocks.

πŸ’‘ Tips and Tricks

  • Preprocess with Image Threshold or Image Adaptive Threshold to obtain a clean binary foreground before using this block.

  • Use Blur to reduce small noise before thresholding β€” this often produces smoother distance maps.

  • After distance transformation, combine with Watershed Algorithm or Image Skeletonize to perform object separation or extract medial axes.

  • Use Find Contour, Approximate Contour, Minimum Rectangle or Minimum Circle on the cleaned/segmented result to obtain geometric measurements or bounding shapes.

  • Limit analysis to a region of interest by using Image ROI Select or Get ROI before feeding the image into this block.

  • Visualize outputs with Show Image and store important results with Image Logger or Image Write.

πŸ› οΈ Troubleshooting

  • If the output looks noisy or scattered, ensure the input is a well-defined binary mask; consider using Morphological Transformations to 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 Image to inspect intermediate results.

  • For poor separation of touching objects, try changing the Transormation Type or follow the distance transform with Watershed Algorithm to improve segmentation.

Last updated

Was this helpful?