The simplest possible example

This example deals with:

  • A small (4x4) numpy array,
  • A predefined neighbourhood (N4),
  • One call to a watershed algorithm (immersion)

Goals:

  • Check if toolbox is working
  • Show how to call the watershed functions
  • Show how to order data on the numpy array
 1 from ipdp.common import N4
 2 import watershed as ws
 3 
 4 i = array([[8,6,6,6],[0,3,7,5],[1,4,0,2],[2,4,6,9]])
 5 w = ws.immersion(i, N4)
 6 
 7 print "Input Image:"
 8 print i
 9 print "Output Image:"
10 print w
Input Image:
[[8 6 6 6]
 [0 3 7 5]
 [1 4 0 2]
 [2 4 6 9]]
Output Image:
[[1 1 0 2]
 [1 1 0 2]
 [1 1 2 2]
 [1 1 0 2]]

Simplest possible example

Toolbox