I have an image and I want to get the pixels that cross through its medial axis. I tried to use skeletonize and medial axis methods in order to get them but both methods return one dimensional line which is shorter than the corresponding object.
Here's the code with a sample image:-
>>> import skimage.filter
>>> import skimage.morphology
>>> import numpy as np
>>> import scipy.misc
>>> im=scipy.misc.imread('img.jpg')
>>> thr=skimage.filter.threshold_otsu(im)
>>> im=im > thr # Threshold the image
>>> im_sk=skimage.morphology.skeletonize(im)
>>> mask=np.where(im_sk==1) # pixels of skeleton
>>> im[mask]= 0 # this will color the skeleton with black
Original >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Result
or_im http://imageshack.us/a/img23/9035/testwus.jpg sk_im http://imageshack.us/a/img585/1910/imgskx.jpg
As you can see the black line isn't connected to the tip of the shape.
(1) How can I get a fully connected one dimensional medial axis line that represents the length of the shapes in the image.
(2) How can I get the pixels that are perpendicular to the medial axis (as I want to draw perpendicular lines from one side to another crossing the medial axis of the shape)
- I need any python library that can do this stuff.
Thanks