getSignature()

MainPage

Description: This method computes the signature of a node. The signature may be either of area or volume, and it takes in consideration the max-tree composite nodes.

Signature: levels, signature = MaxTreeAlpha.getSignature(attrib, start, end = 0, cte = 0)

Input:
  • attrib: 1d-array int32. Array containing either the area or volume attribute of the max-tree nodes.
  • start: str. Start node of which the signature will be computed.
  • end: str. End node of the signature, default value is 0 (the root).
  • cte: int. 0 for area signature and 1 for volume signature.
Output:
  • levels: 1d-array, int32. Array containing the gray-levels values of the signature
  • signature: 1d-array, int32. Array containing the signature.

C++ Aux Function

OK
OK [C/C++ extension is up-to-date]

Python Aux Function

Python Implementation

 1 import numpy as np
 2 
 3 def getSignature(self,attrib, start, end = 0, cte = 0):
 4     """
 5     This method returns a tuple containing the gray-levels and the
 6     attribute signature. Composite nodes are considered.
 7     cte:
 8     0 -> shape signature
 9     1 -> volume signature
10     """
11     par = self.node_array[0,:]
12     h = self.node_array[2,:]
13     area = self.node_array[3,:]
14     attrib = attrib.astype(np.int32)
15     signature = self.get_signature_aux(par, h, area, attrib, int(start), int(end), int(cte))
16     levels = np.arange(h[end], h[start] + 1, dtype = np.int32)
17     return levels, signature

Example

 1 from max_tree_alpha import MaxTreeAlpha
 2 import numpy as np
 3 import ia870
 4 import ia636
 5 
 6 img = adreadgray(find_attachment_file('iamxt/MainPage/monalisa.jpg'))
 7 Bc = np.ones((3,3), dtype = bool)
 8 mxt = MaxTreeAlpha(img,Bc)
 9 
10 A = mxt.node_array[3,:]
11 ext = mxt.computeExtinctionValues(A,"area")
12 leaf = argsort(ext)[::-1][4] # Manually selected, 3rd highest extinction value
13 leaf_cc = mxt.recConnectedComponent(leaf)
14 leaf_cc = ia870.iadil(leaf_cc,ia870.iasedisk(5))
15 img2 = ia870.iagshow(img,leaf_cc)
16 adshow(img2,'(a) Mona Lisa image. Regional maxima highligthted by a red dot.')
17 levels,signature =  mxt.getSignature(A, leaf)
18 adshow(ia636.iaplot(signature, levels,xlabel = 'Gray-level',ylabel = 'Area'), "(b) Area signature")

(a) Mona Lisa image. Regional maxima highligthted by a red dot.

(b) Area signature