Max-tree signature

MainPage || iamxt

 1 import numpy as np
 2 import iamxt
 3 import ia870
 4 import ia636
 5 
 6 img = adreadgray('/awmedia/www/media/Attachments/iamxt/MainPage/monalisa.jpg')
 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
11 bin_img = ia870.iadil(bin_img,ia870.iasedisk(5))
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]
30 gradient = area[0:-1]- area[1:]
31 indexes = np.argsort(gradient)
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]]))

Mona Lisa image with a regional maxima highlighted

Node 81144, area 244024

Node 82019, area 27550

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 import ia870
 4 import ia636
 5 
 6 img = adreadgray('/awmedia/www/media/Attachments/iamxt-tutorial/interactive_maxtree01/MRI_coronal.png')
 7 adshow(img, "Coronal brain image")
 8 
 9 x,y = 120,110 # Hand picked regional maximum
10 bin_img = np.zeros(img.shape,dtype = bool)
11 bin_img[x,y] = True
12 bin_img = ia870.iadil(bin_img,ia870.iasedisk(5))
13 img2 = ia870.iagshow(img,bin_img)
14 adshow(img2,'image with a regional maxima highlighted')
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]
30 gradient = area[0:-1]- area[1:]
31 indexes = np.argsort(gradient)
32 max1 = indexes[-2]
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]]))

Coronal brain image

image with a regional maxima highlighted

Node 1251, area 7562

Node 1293, area 5206

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 
4 img = adreadgray('/awmedia/www/media/Attachments/iamxt-tutorial/interactive_maxtree01/MRI_sagittal.png')
5 adshow(img, "Sagittal brain image")

Sagittal brain image