SMIL  1.0.4
Quick start with smilPython

Generalities

Most Smil features are available under Python, thanks to Swig as a module names smilPython.

Your first program

Type the following lines in your prefered text editor (copy and paste works fine) and name it, e.g., first-smil.py.

1 # import smilPython module
2 import smilPython as sp
3 
4 # define which structuring element to use
5 se = sp.SquSE()
6 
7 # get your first image
8 # try replacing the URL by some image stored in your computer.
9 imIn = sp.Image("https://smil.cmm.minesparis.psl.eu/images/lena.png")
10 imIn.show("Lena original")
11 
12 # declare two images for results
13 imA = sp.Image(imIn)
14 imA.show("erode")
15 
16 imB = sp.Image(imIn)
17 imB.show("dilate")
18 
19 # erosion and dilation
20 r = sp.erode(imIn, imA, se())
21 r = sp.dilate(imIn, imB, se())
22 
23 input("Hit enter to continue")
24 
25 # now let's do some filtering with a SE of size 2
26 r = sp.open(imIn, imA, se(2))
27 imA.setName("open")
28 r = sp.close(imIn, imB, se(2))
29 imB.setName("close")
30 
31 input("Hit enter to continue")

Run it and try to modify it.

Note
  • near all Smil functions return a value which means :
    • 1 - if the function executed with no error
    • 0 or any other value - an error occured. Usually there will be some message to explain the error.
  • it's a good practice to verify the returned value and stop processing on errors and handle it.

Some rules

  • TBD