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_labels.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

Max-tree profile

Do it yourself

 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 
 7 for n in nextrema:
 8     #area = mxt.node_array[3,:]
 9     #Aext = mxt.computeExtinctionValues(area,"area")
10     V = mxt.computeVolume()
11     Vext = mxt.computeExtinctionValues(V,"volume")
12     mxt.extinctionFilter(Vext,n)
13     aef = mxt.getImage()
14     adshow(aef,"Nextrema %d" %n)

Nextrema 512

Nextrema 256

Nextrema 128

Nextrema 64

Nextrema 32

Nextrema 16

Nextrema 8

Nextrema 4

Nextrema 2

Nextrema 1