I have a set of black and white images as shown below like Figure 1 and I want to have them with much smaller lines like Figure 2, even though no lines are missing as much as possible. I also tried morphological methods and algorithms like Canny with Python, but I did not get the result I wanted.
I think you are looking for skeletonization, see skimage.skeletonize
, example here :
import skimage.morphology
import skimage.io
import skimage.util
import matplotlib.pyplot as plt
img = skimage.io.imread('shoes.png')
image = skimage.util.invert(img)
image = image >125
skel = skimage.morphology.skeletonize(image)
plt.imshow(skel)