# Evaluation and Recognition of Handwritten Chinese Characters Based on Similarities
## 1 Introduction
### Cosine Similarity  
Cosine similarity [35] is a measure for evaluating the difference between two different vectors. It can be calculated by Formula (3):  
\[\cos\theta=\frac{\text{A-B}}{\|\text{A}\|\|\text{B}\|}=\frac{\sum_{\text{i=1}} ^{\text{n}}\text{A}_{\text{i}}\times\text{B}_{\text{i}}}{\sqrt{\sum_{\text{i=1 }}^{\text{n}}\left(\text{A}_{\text{i}}\right)^{2}}\times\sqrt{\sum_{\text{i=1 }}^{\text{n}}\left(\text{B}_{\text{i}}\right)^{2}}} \tag{3}\]  
Here, both A and B are the eigenvectors, \(\text{A}_{\text{i}}\) and \(\text{B}_{\text{i}}\) are the elements of the vectors of A and B, and \(\theta\) is the angle of A and B in the vector space.  
To calculate the cosine similarity, we needed to extract the eigenvectors from the digital images in advance and four different ways were adopted here.  
Figure 5: Graphical illustration of relationships between two features.  
Figure 6: Schematic illustration of pixel coincidence degree method for Chinese Character “\(\boxed\)” (means “same”).  
In the first way, after image preprocessing and skeleton extraction, column and row eigenvectors were obtained by simply summing up pixels in each column and row.  
\[\begin{split}\text{P}_{1}(\text{g}_{1},\text{g}_{2})=\frac{\text{P} _{2}(\text{g}_{1},\text{g}_{2})}{\text{R}},\\ \text{R}=\left\{\begin{aligned} &\text{N}(\text{N}-1),\theta=0^{\circ} \text{or}\theta=90^{\circ}\\ &(\text{N}-1)^{2},\theta=45^{\circ}\text{or}\theta=135^{\circ} \end{aligned}\right.\end{split} \tag{4}\]  
In the second way, the gray co-occurrence matrix was used to extract texture parameters as eigenvectors, which were calculated by Formula (4). Specifically, P is the probability of pixel pairs, R is the normalization factor, N is the size of the Chinese character images, and \(\theta\) is the scanning angle of the pixel pairs. After image preprocessing, the image was transformed and compressed to a grayscale image. The texture features included energy, contrast, entropy, mean, variance, and other features, which could reflect the slow change or periodicity of the image surface. When calculating the co-occurrence matrix, we could choose a pixel pair with a horizontal orientation, a vertical orientation, a 45-degree downward slope, or a 45-degree upward slope [36; 37; 38].  
In the third way, after image preprocessing and skeleton extraction, the Chinese character images were divided into 24 regions as shown in Figure 7. The sum of the pixel values in each region was calculated as one element of the eigenvector and arranged in the order shown in Figure 7b.  
In the fourth way, a pre-processed binary image (size: 100 pixels \(\times\) 100 pixels) was divided into 100 regions as shown in Figure 8a and the sum of the pixel values was calculated in each region. To compress the number of pixels to 100, the sum of pixels was calculated in each region. If the sum was less than 50, the whole region was set to 0; if otherwise, it was set to 1. Then, these treated pixels were used as eigenvector elements arranged in the order shown in Figure 8b.  
Figure 8: (**a**) The Chinese character “\(\mathbb{H}^{\prime}\) (means “handle”) to be processed. (**b**) Schematic illustration of 100-area segmentation.  
Figure 7: (**a**) The Chinese character “\(\mathbb{H}^{\prime}\) (means “handle”) to be processed. (**b**) Schematic illustration of 24-area segmentation.