mmsT

MainPage

Description: This method implements the MMS-T filter.

Signature: MaxTreeAlpha. mmsT( t = 0.5)

Input:
  • t, float. Threshold value. It must be between 0 and 1.

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 mmsT(self, t = 0.5):
 4     if not self._sb_updated:
 5         self.getSubBranches()  # List of sub-branches
 6     to_keep = np.zeros(self._cum_sb_hist.size, dtype = np.int32)
 7 
 8     new_h = np.zeros(self._cum_sb_hist.size, dtype = np.int32)
 9     h = self.node_array[2,:]
10     parent = self.node_array[0,:]
11     nlevels =  (h - h[parent]).astype(np.int32)
12     nlevels[0] = 1
13 
14     self.mms_t_aux(t, nlevels, h, to_keep, new_h,self._sb,self._cum_sb_hist )
15     h[to_keep] = new_h
16     bool_tokeep = np.zeros(self.node_array.shape[1],dtype = bool)
17     bool_tokeep[to_keep] = True
18     self.contractDR(bool_tokeep)
19     return

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 mxt.mmsT()
23 g= mxt.generateGraph()
24 mmgraphviz(g, title='Max-tree after the MMS-T filter with t = 0.5')
/media/_xsb/iamxt/max_tree_mms_t/GRVIZ94100_001.png

Max-tree

/media/_xsb/iamxt/max_tree_mms_t/GRVIZ94100_002.png

Max-tree after the MMS-T filter with t = 0.5