clone

MainPage

Description: This method returns a hard copy of the Max-Tree object.

Signature: tree_copy = MorphTreeAlpha.clone()

Input:

Output:
  • tree_copy, copy of the MorphTreeAlpha object.

Python Implementation

1 import copy
2 
3 def clone(self):
4     """
5     This method returns a hard copy of the Max-Tree object.
6     """
7     mxt = copy.deepcopy(self)
8     return mxt

Example

 1 from morph_tree_alpha import MorphTreeAlpha
 2 import numpy as np
 3 
 4 np.set_printoptions(precision=4)
 5 
 6 img = np.array([[100, 100, 100, 0,   0,   0,   0,   0],\
 7                 [150, 150, 150, 150, 150, 150, 150, 150],\
 8                 [150, 160, 190, 150, 200, 200, 229, 150], \
 9                 [150, 185, 255, 150, 200, 230, 200, 150],\
10                 [150, 180, 200, 150, 215, 229, 200, 150],\
11                 [150, 150, 150, 150, 150, 150, 150, 150],\
12                 [50,  50,  0,   0,   0,   0,   0,   0]], dtype = np.uint8)
13 
14 
15 Bc = np.array([[0,1,0],\
16                [1,1,1],\
17                [0,1,0]], dtype = bool)
18 
19 
20 morph_tree = MorphTreeAlpha(img,Bc)
21 
22 morph_tree_copy = morph_tree.clone()
23 
24 print "morph_tree.node_array = morph_tree_copy.node_array:"
25 print np.all(morph_tree_copy.node_array == morph_tree.node_array)
26 
27 
28 print "morph_tree.node_index = morph_tree_copy.node_index:"
29 print np.all(morph_tree_copy.node_index == morph_tree.node_index)
morph_tree.node_array = morph_tree_copy.node_array:
True
morph_tree.node_index = morph_tree_copy.node_index:
True