# Automatic Classification of Web Images as UML Static Diagrams Using Machine Learning Techniques
## 5 Classification Functions in the Hyperspace of Graphical Characteristics  
Suppose we classify images by their graphical characteristics based on a single variable or metric, for example the number straight lines (NSL) present in the image. We can then formulate a simple rule to transform the metric into a classification, such as \"if NSL \(\leq\) 10 then Negative, else Positive\". The rule can be easily refined to account for more classifications, using more intervals in the value of the metric, such as \"if NSL \(\leq\) 10 then Negative, else if NSL \(\leq\) 16 then Dubious, else Positive\" (see Figure 7). For simplicity, since the argument is easily generalizable to any number of classifications, we will assume in the rest of the paper that the number of levels is only two: Negative or Positive. Figure 6: Automatic exclusion of contained rectangles: the three rectangles in red do not satisfy the rule for growing IDs of their segments, therefore they are discarded by the automaton. Now, suppose we want to combine two different metrics to assign a classification, such as number of rectangles (NR) and number of gray tones (NG). We can represent both variables on the X-Y plane, where each point is an image and the point color is the classification. The simplest way to classify the cloud of points is by a linear combination of the variables, i.e., the traditional method of weighted average of metrics: \"if (a*NR + b*NG) \(\leq\) L, then Negative, else Positive\", where a, b and L are convenient values. When the cloud of points is naturally split into two regions separated by a straight line, the values of a, b and L can be easily obtained with simple mathematical methods (see Figure 8). The method generalizes to any number of dimensions (metrics) that define a hyperspace of graphical characteristics split in two regions by a hyperplane. However, this simplicity is not usually found when the variables present a more complex relationship with the classification, which can be very difficult to estimate a priori (see Figure 9). In these situations, a more convenient yet simple way to combine the metrics is by means of a rectangular region: the classification is Positive inside the region, otherwise it is Negative (or vice versa). Note that the region could be open in one or more sides: \"if NR between [10, -] and NG between [2, 40] then Positive, else Negative\". The method is also rather simple and generalizes to hyper-rectangular regions in the hyperspace of graphical characteristics. The most common case in the combination of metrics, however, is not so simple, and the cloud of points is not easily discriminated by a single (hyper-) rectangle. In these situations, we can still generalize the procedure to a combination of regions that can be better adjusted to the cloud of points (see Figure 10), such as: \"if NR between [10, 20] and NG between [2, 40] then Positive, else if NR between [20, -] and NG between [2, 15] then Positive, else Negative\". Note, the regions could be overlapping (requiring that they do not overlap could produce a worse adjustment of the rule, or a more complex rule with more rectangles). Figure 8: Combination of two arbitrary metrics using a straight line to discriminate an image in the simplest case (white: Positive, black: Negative). Figure 7: A simple rule to transform a metric such as the number of straight lines (NSL) into an image classification as static diagram. Summing up, the discrimination of regions by means of hyperplanes (Figure 8) is generally very inadequate, and the use of simple rectangular regions (Figure 9) is still insufficient. Instead, a combination of rectangular regions (Figure 10) is a versatile method when the different metrics employed present complex relationships manifested in the clustering of points. The higher the number of regions, the better the adjustment of the discriminating rule to the dataset (avoiding of course an excessive number of regions, which would compromise generality).