# computeHeightFloat

MainPage

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

Signature: height = MaxTreeAlpha2.computeHeightFloat()

Input:

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

# C++ Aux Function

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

# Python Implementation

``` 1 import numpy as np
2
3 def computeHeightFloat(self):
4     """
5     This method returns the height attribute of the max-tree nodes.
6     """
7     parent = self.node_array2[0,:].astype(np.int32)
8     level  = self.node_array2[2,:].astype(np.float)
9     height = np.where(self.node_array2[1,:] == 0, 1e-20, 0).astype(np.float)
10     delta = (level - level[parent]).astype(np.float)
11     self.compute_height_float_aux(parent,delta,height)
12     return height
```

# Example

``` 1 from iamxt.max_tree_alpha2 import MaxTreeAlpha2
2 import numpy as np
3 from iamxt.generate_graph import generateGraph
4
5
8 Bc = np.array([[1,1,1],[1,1,1],[1,1,1]], dtype = bool)
9 print "\n2D structuring Element Bc:\n", Bc.astype(int)
10
11
12 mxt = MaxTreeAlpha2(img,Bc)
13 dx = mxt.node_array[7,:] - mxt.node_array[6,:] + 1
14 dy = mxt.node_array[10,:] - mxt.node_array[9,:] + 1
15 # Aspect ratio
16 temp = np.concatenate((dx.reshape(1,-1),dy.reshape(1,-1)), axis = 0)
17 den = temp.max(axis = 0)
18 num = temp.min(axis = 0)
19 attr = (1.0*num/den)
20 g= mxt.generateGraph(nodes_attr = attr)
21 mmgraphviz(g, title='Max-tree node:level[ar]')
22
23
24
25 mxt.build2ndMaxTree(attr)
26 graph = generateGraph(mxt.node_array2[0,:],mxt.node_array2[2,:])
27 mmgraphviz(graph,"Pixel oriented 2nd max-tree")
28 print mxt.computeHeightFloat()
```
```2D structuring Element Bc:
[[1 1 1]
[1 1 1]
[1 1 1]]
[  3.34883721e-01   6.46258503e-02   2.17525499e-01   1.00000000e-20
1.00000000e-20   9.34115980e-02   3.07343433e-02   1.00000000e-20
1.00000000e-20]
```