extinctionFilter

MainPage

Description: This method implements the extinction filter. It prunes all nodes not in the path of the n most relevant maxima to the root.

Signature: MaxTreeAlpha.extinctionFilter(ext,n)

Input:
  • ext, 1d-array int32. Extinction values array.
  • n, int. Number of maxima to be preserved.

Output:

C++ Aux Function

OK
OK [C/C++ extension is up-to-date]

Python Aux Function

Python Implementation

 1 import numpy as np
 2 
 3 def extinctionFilter(self,ext,n):
 4     """
 5     This method implements the Extinction Filter. It keeps the n most
 6     relevant extrema according to the extinction values ext.
 7     """
 8 
 9     ii = (np.argsort(ext)[::-1][:n]).astype(np.int32)
10     to_remove = np.ones((self.node_array.shape[1],),dtype = np.int32)
11     self.extinction_filter_aux(to_remove,ii,self.node_array[0,:])
12     self.prune(to_remove.astype(bool))
13     return self

Example

 1 from max_tree_alpha import MaxTreeAlpha
 2 import numpy as np
 3 
 4 img = np.array([[100, 100, 100, 0,   0,   0,   0,   0],\
 5                 [150, 150, 150, 150, 150, 150, 150, 150],\
 6                 [150, 160, 190, 150, 200, 200, 229, 150], \
 7                 [150, 185, 255, 150, 200, 230, 200, 150],\
 8                 [150, 180, 200, 150, 215, 229, 200, 150],\
 9                 [150, 150, 150, 150, 150, 150, 150, 150],\
10                 [50,  50,  0,   0,   0,   0,   0,   0]], dtype = np.uint8)
11 
12 
13 Bc = np.array([[0,1,0],\
14                [1,1,1],\
15                [0,1,0]], dtype = bool)
16 
17 
18 mxt = MaxTreeAlpha(img,Bc)
19 
20 g= mxt.generateGraph()
21 mmgraphviz(g, title='Max-tree')
22 V = mxt.computeVolume()
23 Vext = mxt.computeExtinctionValues(V,"volume")
24 mxt.extinctionFilter(Vext,2)
25 g= mxt.generateGraph()
26 mmgraphviz(g, title='Max-tree after the extinction filter with n = 2')
/media/_xsb/iamxt/max_tree_extinction_filter/GRVIZ75794_001.png

Max-tree

/media/_xsb/iamxt/max_tree_extinction_filter/GRVIZ75794_002.png

Max-tree after the extinction filter with n = 2