Scikit-image
from skimage.draw import line
img = np.zeros((10, 10), dtype=np.uint8)
rows_ix, columns_ix = line(2, 3, 6, 7)
img[rows_ix, columns_ix] = 1
from skimage.measure import label
label(arr, connectivity=1) # up, down, left and right check
labelled_img = label(img == 0)
labels, counts = np.unique(labelled_img, return_counts=True)
from skimage.morphology import skeletonize, thin
from skimage.util import invert
 from skimage.feature import peak_local_max