'How to save skeleton of an image as svg?

I have obtained the skeleton of an image. Like this

im = imread('testimage.png',as_gray=True)

t = threshold_otsu(im)

r = skeletonize(im>threshold_otsu(im))*255

*Code copied from SO

Now I want the skeleton as an svg file.

I think I can try plotting it using pyplot and then use the savefig() method. But I am a beginner. Does someone has a good way of going about this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source