Visit ComfyUI Online for ready-to-use ComfyUI environment
Compute pixel distances to nearest zero in binary images for spatial analysis in image processing tasks.
The DistanceTransform
node is designed to compute the distance to the nearest zero pixel for each pixel of a binary image. This node is particularly useful in image processing tasks where you need to analyze the spatial relationships within binary images, such as object detection, shape analysis, and morphological operations. By transforming the binary image into a distance map, you can easily identify the proximity of each pixel to the nearest object boundary, which can be beneficial for various image analysis and manipulation tasks.
This parameter expects a binary image where the foreground pixels are non-zero, and the background pixels are zero. The binary image serves as the input for the distance transformation process. The quality and accuracy of the distance transform depend on the clarity and correctness of this binary image.
This parameter specifies the type of distance to be used in the transformation. The available options are DIST_L2
, DIST_L1
, and DIST_C
. DIST_L2
computes the Euclidean distance, DIST_L1
computes the Manhattan distance, and DIST_C
computes the Chebyshev distance. The default value is DIST_L2
. Choosing the appropriate distance type can affect the resulting distance map and should be selected based on the specific requirements of your task.
This parameter determines the size of the mask used in the distance transform. The available options are DIST_MASK_3
, DIST_MASK_5
, and DIST_MASK_PRECISE
. DIST_MASK_3
uses a 3x3 mask, DIST_MASK_5
uses a 5x5 mask, and DIST_MASK_PRECISE
provides a more precise calculation. The default value is DIST_MASK_3
. The mask size can influence the accuracy and computational cost of the distance transform, with larger masks generally providing more precise results at the cost of increased computation time.
The output is an image where each pixel value represents the distance to the nearest zero pixel in the input binary image. This distance map can be used for further image processing tasks, such as identifying object boundaries, performing morphological operations, or analyzing the spatial distribution of objects within the image.
distance_type
options to see which one best suits your specific application, as each type measures distance differently.DIST_MASK_PRECISE
for applications requiring high accuracy, but be aware that it may increase computation time compared to DIST_MASK_3
or DIST_MASK_5
.distance_type
is not one of the supported options (DIST_L2
, DIST_L1
, DIST_C
).distance_type
from the available options.mask_size
is not one of the supported options (DIST_MASK_3
, DIST_MASK_5
, DIST_MASK_PRECISE
).mask_size
from the available options.© Copyright 2024 RunComfy. All Rights Reserved.