# Automatic Classification of Web Images as UML Static Diagrams Using Machine Learning Techniques
## 4 Analysis of Graphical Characteristics of Diagrammatic Images
\begin{table}
\begin{tabular}{l c c c c c} \hline \hline
**Algorithm** & \begin{tabular}{c} **Precision for** \\ **Positives** \\ \end{tabular} & \begin{tabular}{c} **Recall for Positives** \\ **(Sensitivity)** \\ \end{tabular} & \begin{tabular}{c} **Precision for** \\ **Negatives** \\ \end{tabular} & \begin{tabular}{c} **Recall for Negatives** \\ **(Specificity)** \\ \end{tabular} & **Accuracy** \\ \hline \begin{tabular}{c} Support Vector \\ Machine \\ \end{tabular} & 0.894 & _0.924_ & 0.921 & _0.890_ & 90.7\% \\ \hline \begin{tabular}{c} Random Forest \\ \end{tabular} & 0.909 & _0.959_ & _0.957_ & _0.904_ & 93.2\% \\ \hline \begin{tabular}{c} J48 Decision \\ Tree \\ \end{tabular} & 0.903 & _0.925_ & 0.923 & _0.901_ & 91.3\% \\ \hline \begin{tabular}{c} Logistic \\ Regression \\ \end{tabular} & **0.913** & _0.902_ & 0.903 & _0.914_ & 90.8\% \\ \hline \
\begin{tabular}{c} REP-Tree \\ \end{tabular} & 0.903 & _0.920_ & 0.918 & _0.901_ & 91.1\% \\ \hline
\begin{tabular}{c} Decision Table \\ \end{tabular} & 0.897 & _0.919_ & 0.917 & _0.895_ & 90.7\% \\ \hline \hline \end{tabular}  
* Reminder: Precision for positives is the ratio of true positive detections to all positive detections (the complement is the ratio of false positive detections). Recall is the ratio of true positive detections to all existing positives in the dataset (the complement is the ratio of false negative detections). The corresponding calculations can be performed also on the ratio of true negative detections, as shown in the table. Sensitivity is the recall of positives and Specificity is the recall of negatives. Accuracy (or percentage of agreement) is the ratio of true positives plus true negatives to all existing instances.  
\end{table} 
Table 2: Results obtained by [PERSON] et al. [25] with six different algorithms: precision, recall and accuracy in classifying images as UML static diagrams1. Their best results in boldface. The authors report only sensitivity and specificity (in italics). We backward-computed the rest of values to better compare with our own results. ability to detect occluded shapes and the ease of representing a figure with a one-pixel thick edge. N being the number of points (i.e., black or significant pixels) in the image, this method has an order of complexity O(N\({}^{2}\)) when N random pairs of pixels are searched for straight lines, and an order of complexity O(N\({}^{3}\)) when all possible pairs are exhaustively searched for. Our own algorithm takes advantage of the fact that UML class diagrams contain a majority of vertical and horizontal lines. This enables us to achieve a linear order of complexity O(N), which is manifested in the fact that our average processing time is seven times lower than other methods that use standard libraries such as OpenCV and Magick++ (see Section 9), which are based on the Hough transform. In the rest of this section, we explain in detail the procedure to identify straight lines and rectangles in a computationally efficient way. The first step is to identify the pixels that belong to a vertical or horizontal straight line (a'segment') that is part of a relationship polyline or a rectangle border. The basic image processing procedure is described with greater detail by [PERSON] et al. [31]. We then identify segments consisting of series of horizontally or vertically contiguous black pixels, allowing for short discontinuities in dashed lines. Each detected segment receives a unique identifier within the diagram. Four cyclically connected segments form a rectangle, which also receives a unique identifier.