Abstract: - In this paper, a new method for edge detection based on Support Vector Machines (SVM) is presented. This method improves our previous work in ...
A New and Improved Edge Detector Using the Support Vector Machines H. GÓMEZ-MORENO, S. MALDONADO-BASCÓN, F. LÓPEZ-FERRERAS, P. GIL-JIMÉNEZ Departamento de Teoría de la Señal y Comunicaciones Universidad de Alcalá Crta. Madrid-Barcelona km 33,600. D.P. 28871 Alcalá de Henares-Madrid SPAIN
Abstract: - In this paper, a new method for edge detection based on Support Vector Machines (SVM) is presented. This method improves our previous work in edge detection with SVM by reducing the execution time and upgrading the visual quality. Our work shows that a new training technique with a reduced set of vectors maintains the edge detection quality and then reduces the number of needed support vectors. Also, we show that in this task the use of a transformation is not necessary and the linear SVM can be used. The increased speed allows the increment of the window size when exploring the images and then the quality of the edge detection is improved. Key-Words: - Edge detection, Support Vector Machines, Image processing, Learning methods, Segmentation.
1 Introduction
2 SVM Classification
The edge detection methods play an important role in the extraction of relevant information from images. This task is commonly accepted as the first step in an automatic vision system. The classical methods search for several ways to perform an approximation to the local gradient and they mark the edges by searching the maximum along the direction of the gradient. The Sobel, Prewitt or Roberts filters are some of these approximations [1] that use a mask that is convolved with the image in order to compute the gradient. Other approaches are based in a previously smoothing action in order to improve the edge detection and to reduce the effect of noise (basically Gaussian noise), this is the case of Canny algorithm [2]. In [3] we presented a new edge detection technique that does not try to approximate the gradient but classify the pixels between "edge" or "no edge" using the SVM. This is a classification tool that is based on the Statistical Learning Theory and uses only a few training examples to generalize and extract the information needed for the classification. The training was performed using a few own-created images that represents a clearly defined edges with the edges location known. The main disadvantage of this method is the amount of time needed for the execution compared with the classical methods. Then, our goal in this new work is to improve the SVM edge detector both in execution speed and, if possible, in edge detection performance.
The SVM gives us a simple way to obtain good classification results with a reduced knowledge of the problem. The principles of SVM have been developed by Vapnik [4] and have been presented in several works. In the decision problem we have a number of vectors divided into two sets, and we must find the optimal decision frontier to divide the sets. This optimal election will be the one that maximizes the distance from the frontier to the data. In the two dimensional case, the frontier will be a line, in a multidimensional space the frontier will be an hyperplane. The decision function that we are searching for has the next form, l
f ( x ) = ∑ α i yi xi ⋅ x + b .
(1)
i =1
The y values that appear into this expression are +1 for positive classification training vectors and –1 for the negative training vectors. Also, the inner product is performed between each training input and the vector that must be classified. Thus, we need a set of training data (x,y) in order to find the classification function. The α values are the Lagrange multipliers obtained in the minimization process and the l value will be the number of vectors that in the training process contribute to form the decision frontier. These vectors are those with a value not equal to zero and are known as support vectors. When the data are not linearly separable this scheme can not be used directly. To avoid this problem, the SVM can map the input data into a high
dimensional feature space. The SVM constructs an optimal hyperplane in the high dimensional space and then returns to the original space transforming this hyperplane in a non-linear decision frontier. The nonlinear expression for the classification function is given in (2) where K is the kernel that performs the non-linear mapping. l
f ( x ) = ∑ α i yi K ( xi , x ) + b
(2)
i =1
The choice of this non-linear mapping function or kernel is very important in the performance of the SVM. One kernel used in our previous work is the
(a) {25,25,25,0,0,0,0,0,0}
radial basis function. This function has the expression given in (3).
(
K (x , y ) = exp − γ (x − y )
2
)
(3) The γ parameter in (3) must be chosen to reflect the degree of generalization that is applied to the data used. Also, when the input data is not normalized, this parameter performs a normalization task. When some data into the sets can not be separated, the SVM can include a penalty term (C) in the minimization, that makes more or less important the misclassification. The greater is this parameter the more important is the misclassification error.
(b)
(c)
{25,0,0,25,0,0,25,0,0}
{75,75,75,75,75,75,75,75,75}
Fig. 1. Example of training vectors for edge detection
3 Edge Detection In this section we present a new way to detect edges by using the SVM classification. The decision needed in this case is between "the pixel is part of an edge" or "the pixel is not part of an edge". In order to obtain this decision we must extract the information from the images since the entire image is not useful as the input to the SVM. The solution is to form a vector with the pixels in a window around every one into the image. The window size may be changed to improve the detection. In the case of a 3x3 window a nine components vector is calculated at each pixel except for the border of the image. The formed vectors are used as inputs to the SVM in the training process and when it is applied to the images.
3.1 Training The main difference between the new approach and the one presented in [3] is the way elected to obtain the training vectors. Since our goal is to reduce the execution time, one important idea is to reduce the number on support vectors while maintaining the performance. Then, instead of the use of an image and extract the training vectors from it we prefer to form directly the training vectors. One example of these vectors used to train the SVM is shown in Fig. 1. The only training used is horizontal, vertical and no edge and we expect that the other edges will be generalized.
A value that must be set in the training process is the difference between dark and bright zones, since this parameter controls the sensitivity of the edge detector. A little difference makes the detector more sensible and a greater one reduces this sensitivity. In the examples of Fig. 1 the difference is fixed to 25 in a scale between 0 and 255. When we train the SVM to detect the horizontal edges, the vectors like the one in Fig. 1-a are marked with a +1 label and the 1-b and 1-c are marked with –1. The process is similar with vertical detection but changing 1-b with 1-a. Obviously, the training vectors are not only those in Fig. 1 but several of them obtained changing the gray values in dark and bright zones while maintaining the difference. It is important note that if we apply the obtained training with the vectors like in Fig. 1 the detected edges are not all in image but only those that present a change from bright to dark zones. Thus, we must use other vectors with dark and bright zones interchanged. This way we can detect "left" and "right" vertical edges and "up" and "down" horizontal ones. This distinction is important when we want to obtain the direction of the edges in order to perform the maximum detection.
3.2 Detection Method If we apply the trained SVM (1-2) to an image, a value for each pixel into the image is obtained. This value must be a value positive or negative. We can
use the sign of these values to say when a pixel is an edge or not but, this way, a lost of information is produced. It is better to use the values obtained and say that there is a gradual change between “no edge” and “edge”. Thus, the value obtained indicates a measure of being an edge or not. In Fig. 2 an example of the detection is presented. The data obtained have been scaled to 0-255 gray values to improve the visualization. The horizontal
and vertical images are the result of combining the "up" and "down" horizontal detection and the "left" and "right" vertical detection. After the process above we must decide the pixels that are considered as edges. These pixels will be those that are local maximum in the direction of the edges. It is also interesting to perform a threshold over the edge image to reduce the isolated points and the false edge detection.
Fig. 2. Horizontal and vertical edges detection example
Fig. 3. Edge detection example
4 Results In this section some results obtained with the algorithm proposed are presented. These results have been obtained by using the LIBSVM [5] as implementation for the SVM. The programs have been written in C++ and compiled using the Visual C++ 6.0 compiler. The computer used has a Pentium III processor with 128 Mbytes RAM. The first important result is that the number of training examples is reduced with this new technique and then the number of support vectors is reduced too. In our previous work the images used to train were 32x64 sized and then the number of vectors in the training process was 2084 and the obtained support vectors was approximately 70. With the new technique the number of training vectors may be elected by changing the difference between dark and bright zones but the maximum number used was 75 (with a difference of 10) and the number of support
vector obtained was near 20 using a gaussian kernel like (3). Another important fact is that we realized that the use of a transformation does not improve the edge detection and then the use of a linear SVM is possible. The reduction of support vectors and the use of a linear SVM improve the execution speed. The time needed in the edge detection for an image of 256x256 is below 1 second and with an image of 512x512 is below 4 seconds. In Fig. 3 an example of edge detection is presented. The images were obtained by using training examples with a difference between dark and bright zones of 15 and by using a linear SVM. The size of the window used was 3x3. The number of support vectors was 6. The left image was obtained by no thresholding and the right image with a threshold of 30 % of the maximum value.
(a)
(c)
(b)
(d)
Fig. 4. Comparison of edge detection. (a) Canny edge detector. (b) 3x3 SVM edge detector (c) 5x5 SVM edge detector (d) 7x7 SVM edge detector
(a)
(b)
(c)
(d)
Fig. 5. Comparison of edge detection. (a) Canny edge detector. (b) 3x3 SVM edge detector (c) 5x5 SVM edge detector (d) 7x7 SVM edge detector
We can see how the thresholding improves the edge detection since isolated points and reduced edges are avoided. The reduction in the execution time allows the change in the window size and now sizes of 5x5 or 7x7 can be used with no critical time increment. Also, this new windows improve the edge detection when compared with other edge detectors. Fig. 4 and 5 show a comparison between the Canny edge detector and the detector proposed here. The image "house" (256x256) used in Fig. 4 presents a complex texture in the walls due to bricks. Thus, the parameters of the Canny detector have been set trying to reduce the false edge detection of this bricks. Fig. 4-a shows the result of Canny algorithm with sigma 1.1, low threshold 0 and high threshold 80%. Fig. 4-b,c and d show results with the SVM edge detector with 3x3, 5x5 and 7x7 window sizes. The thresholds are set to 50%, 30% and 20% respectively. We can see how the performance of the method proposed is similar or better compared with the Canny edge detector (considered as an standard comparison). There are less false edge detections and the details are well preserved. The image "lena" (512x512) in Fig. 5 is used since it represents a standard in image processing. Fig. 5-a shows the result of Canny algorithm with sigma 1.1, low threshold 0 and high threshold 80%. Fig. 5-b,c and d show results with the SVM edge detector with 3x3, 5x5 and 7x7 window sizes. The thresholds are set to 60%, 50% and 30% respectively. In this case the image obtained using the 3x3 window presents a lot of details including spurious edges and we think that is not good enough for image segmentation. However, the images obtained with 5x5 and 7x7 windows are similar in quality to the one obtained with the Canny detector but maintaining a high degree of details preservation.
5 Conclusion This work presents a new edge detector that use the SVM to perform the pixel classification between edge and no edge. This new detector reduces the execution time compared with our prior implementation by reducing the number of support vectors and by using a linear SVM. Also the window size can be changed with a reduced time increment and the results obtained with larger window sizes may be compared to those from Canny algorithm considered as a standard comparison. We think that the use of SVM allows the flexibility of the edge detection by adding information to the training images. For example, we can add gaussian noise to the images in order to improve the edge detection in noisy images. This is our new goal for future work.
References: [1] Jain, A.K., Fundamentals of Digital Image Processing, Prentice Hall, Englewood Cliffs, NJ, 1989 [2] Canny, J.F., A computational Approach to Edge Detection, IEEE Trans. On Pattern Analysis and Machine Intelligence, Vol. 8, 1986, pp. 679-698. [3] Gómez-Moreno, H., Maldonado-Bascón, S., López-Ferreras, F., Edge detection in noisy images by using the support vector machines. IWANN, Lecture Notes on Computer Science, Vol. 2084. Springer-Verlag, Heidelberg, 2001, pp. 685-692. [4] Vapnik, V., The Nature of Statistical Learning Theory, Springer-Verlag, New York, 1995. [5] Chih-Chung Chang and Chih-Jen Lin, LIBSVM : a library for support vector machines, 2001. Software available at http://www.csie.ntu.edu.tw/~cjlin/libsvm