Max-tree signature

``` 1 import numpy as np
2 import iamxt
3 import ia870
4 import ia636
5
7
8 x,y = 168,305 # Hand picked regional maximum
9 bin_img = np.zeros(img.shape,dtype = bool)
10 bin_img[x,y] = True
12 img2 = ia870.iagshow(img,bin_img)
13 adshow(img2,'Mona Lisa image with a regional maxima highlighted')
14
15
16 # Max-tree construction
17 Bc = np.ones((3,3), dtype = bool)
18 mxt = iamxt.MaxTreeAlpha(img,Bc)
19 node = mxt.node_index[x,y]
20
21 # Area signature
22 A = mxt.node_array[3,:]
23 levels,signature =  mxt.getSignature(A, node)
24 adshow(ia636.iaplot(signature, levels,xlabel = 'Gray-level',ylabel = 'Area'))
25
26
27 #Getting the nodes before and after the largest drop
28 anc = mxt.getAncestors(int(node))[::-1]
29 area = A[anc]
32 max1 = indexes[-1]
33 anc_max1 = [anc[max1],anc[max1+1]]
34
35
36 adshow(mxt.recConnectedComponent(anc_max1[0]),"Node %d, area %d" %(anc_max1[0],A[anc_max1[0]]))
37 adshow(mxt.recConnectedComponent(anc_max1[1]),"Node %d, area %d" %(anc_max1[1],A[anc_max1[1]]))
```

Do it yourself! #1

Try to segment the brain from the skull using area signature analysis.

``` 1 import numpy as np
2 import iamxt
3
6 x,y = 134,157 # Hand picked regional maximum
7 bin_img = np.zeros(img.shape,dtype = bool)
8 bin_img[x,y] = True
10 img2 = ia870.iagshow(img,bin_img)
11 adshow(img2,'Mona Lisa image with a regional maxima highlighted')
12
13 # Max-tree construction
14 Bc = np.ones((3,3), dtype = bool)
15 mxt = iamxt.MaxTreeAlpha(img,Bc)
16 node = mxt.node_index[x,y]
17
18 # Area signature
19 A = mxt.node_array[3,:]
20 levels,signature =  mxt.getSignature(A, node)
21 adshow(ia636.iaplot(signature, levels,xlabel = 'Gray-level',ylabel = 'Area'))
22
23
24 #Getting the nodes before and after the largest drop
25 anc = mxt.getAncestors(int(node))[::-1]
26 area = A[anc]
29
30 for max1 in indexes[-5:]:
31     anc_max1 = [anc[max1],anc[max1+1]]
32     # precisa usar for
33     adshow(mxt.recConnectedComponent(anc_max1[0]),"Node %d, area %d" %(anc_max1[0],A[anc_max1[0]]))
34     adshow(mxt.recConnectedComponent(anc_max1[1]),"Node %d, area %d" %(anc_max1[1],A[anc_max1[1]]))
```

Do it yourself! #2

Try to segment the brain from the skull using area signature analysis.

```1 import numpy as np
2 import iamxt
3