# An Efficient Retrieval Technique for Trademarks Based on the Fuzzy Inference System
## 4 Similarity Measurement
### Local Similarity Measurement
#### 4.2.1 Node Similarity Measurement
Here we demonstrate the three fuzzy IF-THEN rules in our rule base as the following: \[\begin{array}{ll}R^{1}:&\text{ \  
is declared with only two levels, and if a node has any children, the node and its children will be separated as a subtree. Accordingly, the tree may be separated into several subtrees. On the other hand, the five local features (Section 3.2) are assigned to the corresponding node. For achieving high discrimination, the weighting coefficients are assigned to different tree levels. This provides the distinguishing features for the different tree levels. In this study, the designed weighting of the weighting subtree parent level will be set as \(w_{parent}^{st}=0.5\), and the weighting of the child level is designed as \(w_{child}^{st}=0.5/n\); \(n\) represents the amount of children, \(st\) represents the index of the subtrees, and the sum of the weighting coefficients equals 1. Since the root node represents the background of the retrieved image, it does not calculate the local feature. Therefore, the weighting value will be set to 0 and the weighting of the child level is designed as \(w_{child}^{st}=1.0/n\). An example shows how to separate the subtrees and design the weighting of the separated subtree; it is shown in Figure 6. In this case, two weighting subtrees, Figure 6b,c, can be separated from the example tree. The weighting of each subtree level in each subtree can be calculated as 0.5, 0.1667, 0.5, and 0.25, respectively.  
After the concept of the weighting strategy is given, the two sets of weighting subtrees in the two different trees, \(\text{ST}^{q}\) and \(\text{ST}^{r}\), are extracted, and the similarity between the two trees, \(\text{T}^{q}\) and \(\text{T}^{r}\), can be further estimated.  
During the similarity estimation between \(\text{T}^{q}\) and \(\text{T}^{r}\), the cross-matching strategy is used to obtain the maximum similarity between the two weighting subtree sets. Further, in the similarity estimation of the two weighting subtrees, we estimate the similarity from the subtrees at the same level. This means that the similarities of the two weighting subtrees are individually estimated by their parent level and child level. The part of similarity in the child level is calculated from the child nodes, and therefore the number of child nodes may cause an unmatched problem in the two different weighting subtrees. An example with a different count of child nodes is given in Figure 7. It shows that the two subtrees in the sets of \(\text{ST}^{q}\) and \(\text{ST}^{r}\), respectively, have a different number of child nodes (\(n\
eq m\)) in Figure 7a,b. \(n\) and \(m\) represent the amount of the children of subtrees \(st^{q}\) and \(st^{r}\), respectively.  
Figure 6: An example illustrating the weighting subtree generation. (**a**) A tree; (**b**) weighting subtree 1; (**c**) weighting subtree 2; (**d**) weighting subtree 3.  
For estimating the similarity in the child level with the unmatched problem, the Hungarian algorithm is employed to solve this problem. The Hungarian algorithm [21] is an optimal method to solve the assignment problem with minimum cost in polynomial time, and it works on a dissimilarity matrix. The elements of the matrix \(\Phi\) in the similarity version are similarity coefficients estimated from the pair nodes in the child level. Since the computation of the Hungarian algorithm is based on the dissimilarity matrix, each element of the matrix in the similarity version is subtracted from an upper bound value to obtain the dissimilarity version of the matrix. The upper bound value is chosen as the maximum value of the matrix \(\Phi\) in the similarity version.  
After the two sets of weighting subtrees, ST\({}^{q}\) and ST\({}^{r}\), are obtained from the two trees, further the local similarity coefficient between two trees, \(T^{q}\) and \(T^{r}\), can be estimated. The processes of the local similarity measurement are introduced below. First, we estimate the similarity of pairs of subtrees, \(s_{ij}^{st}\), in the two sets, which is defined as:  
\[s_{ij}^{st}=w_{parent}^{st}\_\_nodefunc(O_{1,1}^{q},O_{1,1}^{r})+\phi \tag{23}\]  
where \(i\in\{1,2,\ldots,st^{q}\},j\in\{1,2,\ldots,st^{r}\}\), \(st^{q}\) and \(st^{r}\) are the total number of subtrees in ST\({}^{q}\) and ST\({}^{r}\).