Attribute Profile

MainPage || iamxt

Rome

 1 from scipy.io import loadmat, savemat
 2 import iamxt
 3 import numpy as np
 4 import ia636
 5 from iamxt.extrema_attribute import extrema2attribute
 6 
 7 img = adreadgray('/awmedia/www/media/Attachments/iamxt-tutorial/sample_images/rome.png')
 8 img_labels = adreadgray('/awmedia/www/media/Attachments/iamxt-tutorial/sample_images/rome.png')
 9 adshow(img,"Original image")
10 adshow(img_labels,"Label image")
11 
12 H,W = img.shape
13 
14 
15 data_max = img.max()
16 data_min = img.min()
17 max_value = data_max
18 
19 print "Data:"
20 print "Shape:"
21 print img.shape
22 print "Max value:", data_max
23 print "Min value", data_min
24 
25 
26 areas = [25,100,500,1000,5000,10000,20000,50000,100000,150000]
27 print "Thresholds:"
28 print areas
29 
30 #Connectivity-4
31 Bc = np.zeros((3,3), dtype = bool)
32 Bc[1,:] = True
33 Bc[:,1] = True
34 ap = np.zeros((H,W,2*len(areas)+1))
Data:
Shape:
(972, 1188)
Max value: 255
Min value 0
Thresholds:
[25, 100, 500, 1000, 5000, 10000, 20000, 50000, 100000, 150000]

Original image

Label image

Min-tree profile

 1 data_neg = (max_value - img)
 2 
 3 mxt = iamxt.MaxTreeAlpha(data_neg,Bc)
 4 
 5 i = len(areas) - 1
 6 
 7 for ii in areas:
 8     mxt.areaOpen(ii)
 9     ao = max_value - mxt.getImage()
10     adshow(ao,"Area: %d" %ii)
11     ap[:,:,i] = ao
12     i-=1
13 
14 i = len(areas)
15 adshow(img,"Original")
16 
17 ap[:,:,i] = img
18 i +=1

Area: 25

Area: 100

Area: 500

Area: 1000

Area: 5000

Area: 10000

Area: 20000

Area: 50000

Area: 100000

Area: 150000

Original

Max-tree profile

1 mxt = iamxt.MaxTreeAlpha(img,Bc)
2 
3 for ii in areas:
4     mxt.areaOpen(ii)
5     ao = mxt.getImage()
6     temp = (ao*1.0/max_value*255).astype(np.uint8)
7     adshow(temp,"Area: %d" %ii)
8     ap[:,:,i] = ao
9     i+=1

Area: 25

Area: 100

Area: 500

Area: 1000

Area: 5000

Area: 10000

Area: 20000

Area: 50000

Area: 100000

Area: 150000

 1 img = adreadgray('/awmedia/www/media/Attachments/iamxt-tutorial/sample_images/rome.png')
 2 nextrema =  [512, 256, 128, 64, 32, 16, 8, 4, 2, 1]
 3 
 4 mxt = iamxt.MaxTreeAlpha(img,Bc)
 5 
 6 for n in nextrema:
 7     area = mxt.node_array[3,:]
 8     Aext = mxt.computeExtinctionValues(area,"area")
 9     Hx = mxt.computeHeight()
10     mxt.extinctionFilter(Hx,n)