# import smilPython
import smilPython as sp
import numpy as np
# functions using matplotlib to display images on jupyter notebooks
from smilPlot import *
# Load an image
im1 = sp.Image("http://smil.cmm.mines-paristech.fr/images/balls.png")
# Create the skeleton using a thinning with a combination of the 4 rotations of the composite SE sL1 and sL2
im2 = sp.Image(im1)
sp.fullThin(im1, sp.HMT_sL1(4) | sp.HMT_sL2(4), im2)
smilPlot([im1, im2], title = ["im1", "im2"])
# Detect line junctions
im3 = sp.Image(im1)
sp.hitOrMiss(im2, sp.HMT_sLineJunc(8), im3)
# Detect line ends
im4 = sp.Image(im1)
sp.hitOrMiss(im2, sp.HMT_sLineEnd(8), im4)
# Modify results for display...
sp.dilate(im3, im3, sp.hSE())
sp.dilate(im4, im4, sp.hSE())
sp.inf(im3, 1, im3)
sp.inf(im4, 3, im4)
sp.sup(im3, im4, im4)
im2.getViewer().drawOverlay(im4)
smilPlot([im3, im4], title = ["im3", "im4"], label = [True, True])