I am working on the centerline extraction, I have tried skeletonize, RivGraph and several other methods but could not get a good centerline. First the line on the ends are not following the center and it is also shorter than the mask itself.
Here is the code that I have tried:
# Thresholding the mask values to binary mask[mask < 200] = 0 mask[mask > 200] = 255 # Convert the grayscale image to binary image img = img_as_ubyte(mask) # Perform thinning thinned = skeletonize(img, method= 'lee') # Get the x, y coordinates of non-zero (white) pixels y, x = np.nonzero(thinned)
I = imageio.v2.imread("mask.jpg") Imask = np.zeros((I.shape, I.shape), dtype=bool) Imask[I[:,:] != 255] = True coords, widths = ru.mask_to_centerline(Imask, 'ew') plt.imshow(Imask) plt.plot(coords[:,0], coords[:,1])
Could anybody give me some hint?