Class: MaxTreeAlpha2

MainPage

 1 from max_tree_alpha import MaxTreeAlpha
 2 from max_tree2_c_01 import build2ndMaxTree, union_find2_aux_c, canonicalize2_aux_c, computeNodeArray_2nd_tree_aux_c
 3 from max_tree2_compute_extinction_values import compute_extinction_values2_aux_c, computeExtinctionValues2
 4 from max_tree2_extinction_filter import extinctionFilter2, extinction_filter2_aux_c
 5 from max_tree2_compute_height_float import computeHeightFloat, compute_height_float_aux_c
 6 
 7 class MaxTreeAlpha2(MaxTreeAlpha):
 8   """
 9   This class class is an improvement on the MaxTreeAlpha class. It has methods
10   to compute the max-tree of a given max-tree using a user defined attribute. This
11   allows the computation of non-increasing attributes extinction values.
12   **Input:**
13   img -> uint8 image, may be either 2D or 3D. When working with 1D signals use
14   a 2D array with the shape 1xW.
15   Bc -> Boolean array corresponding to the connectivity to be used during the
16   tree construction. The convention is that coordinates (0,0) or (0,0,0) are
17   in the center of the array.
18   """
19 
20   #Main methods
21   build2ndMaxTree = build2ndMaxTree
22   computeExtinctionValues2 = computeExtinctionValues2
23   extinctionFilter2 = extinctionFilter2
24   computeHeightFloat = computeHeightFloat
25   def __init__(self, img, Bc, implementation = 'c'):
26     MaxTreeAlpha.__init__(self,img, Bc,implementation = implementation)
27     self.node_array2 = []
28     self.node_index2 = []
29 
30 
31     #Auxilioary methods
32     self.union_find2_aux = union_find2_aux_c
33     self.canonicalize2_aux = canonicalize2_aux_c
34     self.compute_extinction_values2_aux = compute_extinction_values2_aux_c
35     self.extinction_filter2_aux = extinction_filter2_aux_c
36     self.computeNodeArray_2nd_tree_aux = computeNodeArray_2nd_tree_aux_c
37     self.compute_height_float_aux = compute_height_float_aux_c

Example

 1 from iamxt.max_tree_alpha2 import MaxTreeAlpha2
 2 import numpy as np
 3 from iamxt.generate_graph import generateGraph
 4 
 5 img = np.array([[9,10, 3, 3, 3, 5, 8],
 6                 [2, 0, 4, 0, 0, 0, 7],
 7                 [8, 0, 5, 0, 6, 0, 9],
 8                 [9, 0, 6, 0, 8, 4, 2]],dtype = np.uint8)
 9 
10 print "2D test image:\n", img
11 
12 Bc = np.array([[1,1,1],[1,1,1],[1,1,1]], dtype = bool)
13 print "\n2D structuring Element Bc:\n", Bc.astype(int)
14 
15 
16 mxt = MaxTreeAlpha2(img,Bc)
17 attr = mxt.computeNodeGrayVar()
18 g= mxt.generateGraph(nodes_attr = attr)
19 mmgraphviz(g, title='Max-tree node:level[var]')
20 
21 
22 
23 mxt.build2ndMaxTree(attr.max() - attr)
24 print mxt.node_array2
25 graph = generateGraph(mxt.node_array2[0,:],attr)
26 mmgraphviz(graph,"Pixel oriented 2nd max-tree")
27 ext = mxt.computeExtinctionValues2(attr)
28 print "ext:"
29 print ext
2D test image:
[[ 9 10  3  3  3  5  8]
 [ 2  0  4  0  0  0  7]
 [ 8  0  5  0  6  0  9]
 [ 9  0  6  0  8  4  2]]

2D structuring Element Bc:
[[1 1 1]
 [1 1 1]
 [1 1 1]]
[[  0.           0.           1.           1.           3.           3.
    3.           6.           7.           7.           8.           9.
   10.          10.           5.           4.           2.        ]
 [  1.           2.           1.           3.           1.           1.
    1.           2.           1.           1.           2.           0.
    0.           0.           0.           0.           0.        ]
 [  0.           5.33756501  11.64158163   6.53158163  11.64158163
   11.64158163   6.5582483    9.11607143   9.70408163  10.89158163
   11.22491497  11.89158163  11.89158163  11.89158163  11.89158163
   11.89158163  11.89158163]]
ext:
[ 0.          0.          0.          0.          0.          0.          0.
  0.          0.          0.          0.          2.1875      0.          0.25
  6.55401662  2.7755102   0.25      ]
/media/_xsb/iamxt/max_tree_alpha2/GRVIZ96716_001.png

Max-tree node:level[var]

/media/_xsb/iamxt/max_tree_alpha2/GRVIZ96716_002.png

Pixel oriented 2nd max-tree

[–] Comments
Rubén Macias at 2016-05-24 09:10h
 0
Hola buena tarde Profesor Roberto Souza, mi nombre es Rubén Macias Igari soy estudiante de maestría en el CIDETEC IPN en México y espero no molestarle con las dudas que tengo, gracias por su apreciado tiempo. Ya instale el paquete iamxt completo, solo que tengo unos problemas con adshow y adread, ¿con que funciones puedo sustituir a "adshow y adread"? y otra pregunta, ¿seria tan amable de compartirme su paquete ""MaxTreeAlpha2" (under development, this class is not stable and is not available in the GitHub distribution yet)" que aun no esta disponible para el publico por favor? asi podria verificar el funcionamiento de este ejemplo y saber como trabaja la funcion ""extrema2attribute" - Computes the relationship between the number of extrema and the attribute (height, area, volume) used in the attribute filter". Que es donde tengo el problema en el codigo, en la linea 20 tengo este error ""from iamxt.extrema_attribute import extrema2attribute ImportError: No module named extrema_attribute"" muchas gracias por su valioso tiempo.- saludos cordiales.- Rubén