mmsMSER

MainPage

Description: This method implements the MMS-MSER filter.

Signature: MaxTreeAlpha.mmsMSER(stability_measure)

Input:
  • stability_measure, 1d-array, float. Array with the MSER stability measures of the max-tree nodes.

Output:

C++ Aux Function

OK
1 void mms_mser_aux_c(int DIM1, double *INPLACE_ARRAY1, int DIM1, int *INPLACE_ARRAY1,
2                     int DIM1, int *INPLACE_ARRAY1, int DIM1, int *INPLACE_ARRAY1);
OK [C/C++ extension is up-to-date]

Python Aux Function

 1 import numpy as np
 2 
 3 def mms_mser_aux_py(stability_measure, to_keep, sb,cum_sb_hist):
 4     nsb = cum_sb_hist.size -1
 5     j = 0
 6     for i in xrange(nsb-1):
 7         sb_temp = sb[cum_sb_hist[i]:cum_sb_hist[i+1]]
 8         index = np.argmin(stability_measure[sb_temp])
 9         to_keep[j] = sb_temp[index]
10         j+= 1
11     return

Python Implementation

 1 import numpy as np
 2 
 3 def mmsMSER(self,stability_measure):
 4     if not self._sb_updated:
 5         self.getSubBranches()  # List of sub-branches
 6 
 7     to_keep = np.zeros(self._cum_sb_hist.size, dtype = np.int32)
 8     self.mms_mser_aux(stability_measure, to_keep, self._sb,self._cum_sb_hist)
 9     bool_tokeep = np.zeros(self.node_array.shape[1],dtype = bool)
10     bool_tokeep[to_keep] = True
11     self.contractDR(bool_tokeep)
12     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 sm = mxt.computeStabilityMeasure()
23 mxt.mmsMSER(sm)
24 g= mxt.generateGraph()
25 mmgraphviz(g, title='Max-tree after the MMS-MSER filter')
/media/_xsb/iamxt/max_tree_mms_mser/GRVIZ96563_001.png

Max-tree

/media/_xsb/iamxt/max_tree_mms_mser/GRVIZ96563_002.png

Max-tree after the MMS-MSER filter