This function labels connected components in a binary image while allowing
for a specified maximum gap between pixels to still be considered part of
the same object.
Usage
image_label(img, max_gap =0)
Arguments
img
A binary image matrix where 1 represents foreground pixels and
0 represents background pixels.
max_gap
An integer specifying the maximum allowable gap (in pixels)
between connected components to be considered as part of the same object.
Default is 1.
Value
An object of class image, where each
connected component is assigned a unique integer label.