computeVolume

MainPage

Description: This method computes the volume attribute of the max-tree nodes.

Signature: volume = MaxTreeAlpha.computeVolume()

Input:

Output:
  • volume: 1d-array, int32. Array containing the volume attribute of the max-tree nodes.

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 computeVolume(self):
 4     """
 5     This method returns the volume attribute of the max-tree nodes.
 6     """
 7     parent = self.node_array[0,:]
 8     level  = self.node_array[2,:]
 9     area   = self.node_array[3,:]
10     volume = area.copy()
11     delta = (level - level[parent]).astype(np.int32)
12     self.compute_volume_aux(parent,delta,area,volume)
13     return volume

Example

 1 from max_tree_alpha import MaxTreeAlpha
 2 import numpy as np
 3 
 4 
 5 img = np.array([[9,10, 3, 3, 3, 5, 8],
 6                 [2, 0, 4, 0, 0, 0, 7],
 7                 [8, 0, 5, 0, 6, 0, 9],
 8                 [9, 0, 6, 0, 8, 4, 2]],dtype = np.uint8)
 9 
10 Bc = np.ones((3,3), dtype = bool)
11 
12 
13 mxt = MaxTreeAlpha(img,Bc)
14 volume = mxt.computeVolume()
15 
16 g= mxt.generateGraph(nodes_attr = volume)
17 mmgraphviz(g, title='Max-tree (node:h [volume])')
/media/_xsb/iamxt/max_tree_compute_volume/GRVIZ93998_001.png

Max-tree (node:h [volume])