License Number Plate Recognition using Template Matching and Bounding Box Method

Recognition of vehicle number plates is very important in the field of transportation security systems. Template matching is one of the most popular techniques used for number plate recognition. This algorithm works by evaluating the image pattern that will be recognized and then comparing it with the image pattern in the template. A number plate is an object in an image that has many characters which usually consists of numbers and letters. Character recognition cannot be done simultaneously in an image. A number plate object in the image needs to be done early processing, normalization, and segmentation to recognize the character. While to separate each character, a bounding box algorithm is used. This technique is relatively simple and has fast computing. So this study examines a combination of template matching and bounding box methods to detect Indonesian car license plates. Based on the tests that have been done, the accuracy reaches 80%.


Introduction
Recognition of vehicle number plates is very important in the field of transportation security systems. Researchers have used different techniques and methods for the introduction and recognition of vehicle number plates, citing various journals, books, and paper conferences, by gathering relevant information in their fields from previous research. A simple and widely used method for recognizing patterns can use the template matching algorithm [1]. Template matching is done by evaluating the image pattern to be compared with the existing image on the template. All of these applications are input that is used in the form of digital images that contain writing and characters that have a meaning, which is currently called Optical Character Recognition (OCR) [2] [3]. Template matching is applied to the number of research license plate detection [4] [5] [6]. In the research [4], using a fairly simple technique, the input image is called conversion to grayscale, then edge detection is done by the sobel method, then it is dilated, segmented, deleted the connected object, so that the number plate area is obtained. Next, the area is bounding box on each number plate character. Bounding box functions to mark the object area that has been detected. Each character is then carried out a process of correlation with the template so as to produce a recognizing process. Based on the results of the experiment, the level of recognition accuracy was 93.33%. This result is certainly very satisfying because the method is very simple and can be applied to a complete vehicle image. In the research [6] using the template matching and structured elements method combined with the matching process with the vehicle number database. The input image used is also more specific because the image of the vehicle has been cropped and only contains vehicle number plate objects, but only produces an accuracy of 92%. In research [5] the method used is more sophisticated because it is combined with one method of artificial intelligence, namely the neural network. The matching process 2 uses a normalized cross-correlation and with image input in the form of a pure number plate that does not stick to the vehicle. The accuracy is very high at 98%, this may be quite reasonable because the possibility of noise obtained when image capture is more minimal because the input image has been cut and focused on the number plate only. All of the above studies actually use four main processes, namely preprocessing, segmentation, bounding box and recognizing using template matching. But because the data used is different, the study cannot be compared. The number plate format also determines accuracy, problems such as differentiating letters O and numbers 0 are one of the problems that are often faced when using the template matching method. In addition, if the image taken directly on a moving vehicle will certainly be a more difficult problem. In this study, testing the method in research [4] by implementing the method on vehicle license plates in Indonesia.

Methodology
In general, the steps carried out by the template matching method are based on the OCR process consisting of preprocessing, segmentation, normalization, feature extraction, recognition. A general description of the OCR process is shown in Figure 1.

Preprocessing
Preprocessing is the first step in the OCR process. Some of the processes in the preprocessing stage include, grayscaling, median filtering, image resizing, dilation, erosion and fill [2] [3] [7] [8]. The preprocessing step used in this study begins with changing the RGB image into a gray image. This stage is used to simplify the process of detecting the edge area of a number plate object, because in the RGB image there will be a lot of detected edges that actually don't want to be detected [9] [10]. Then the median filtering function is to reduce noise that is still present in the image, and so that the image appears smoother [11]. Furthermore, a resizing image is used to adjust the image size, because by default the image size is too large, it needs to be reduced to speed up the computing process. The dilation process has a function to strengthen the edge area of the image so that objects are easily detected [12]. There is also an erosion process that is used to erode the noise that occurs in the image after several previous processes. The last process is filled; fill is used to fill the area surrounded by the edge area that is still connected.

Segmentation
Segmentation is grouping pixels of objects into regions that represent an object. In this study segmentation functions to cut every character on the number plate into pieces of the image (letters and numbers) [3] [13] [14]. In this study, the segmentation process by categorizing all characters in the form of letters and numbers into character pieces. In this process, characters must be segmented correctly, if they fail, the character cannot be recognized. Identifying characters will be assigned a different special label to distinguish each other from each character. Segmentation is an important part of detecting license plates.

Normalization
Normalization is the process of changing input images which aims to equalize the image in the template data. The normalization process used in this study is the image size equation. When the pattern matching process uses the template matching algorithm, the size of the input image must be adjusted to the size of the image in the template data [14].

Recognition
Recognition is the last process carried out after the input image has been processed and obtained by the object. Then each character object is matched. The matching process is done with the normalized correlation function [3] [14]. In this study two-dimensional correlation coefficient using formula (1) was carried out.
Where T is the template image, O is the image of the object, m and n are the image sizes that must be the same, ܶ ത is the mean of T, and ܱ ത is the mean of O.

Experiment and Results
In this study a program was designed that was able to recognize OCR-based car number plates that used template matching and bounding boxes, where the steps were detailed in the methodology section. The input image in the form of a car image will be used as input program, the image is then processed by detecting the contour of the object in the form of a number plate on the image to get the location of the number plate and then the plate will be separated from the background. It is in this number plate image that the extraction process of character objects is carried out then identified by using the template matching method. Figure 2 shows the image used in this study. Furthermore, the recognizing process begins with the process of converting colors from the RGB color space to grayscale. Based on one of the image samples shown above, the conversion process is shown in Figure 3. The conversion process is done using the Matlab application with the rgb2gray () function. Figure 3. RGB to Grayscale process The next step is to reduce noise in the image by applying a median filter that makes the image appear smooth. The process aims to obtain the edge of the actual image. If the process is not applied, the fine lines will be detected as the edges of the object. The results of the filtering process are shown in Figure  4. The next process is the resizing process, which aims to speed up the calculation process. The pixel size is changed to 400 * 400, followed by a dilation process which serves to strengthen the edge area of the image. The results of this process are shown in Figure 5.

Figure 5. Image after Resize and Dilation
The next process is convolution to the image, where the image will be brightened by the edges, can be seen in this process the edge of the plate becomes brighter, the results are shown in figure 6. The adjustment process is then carried out by changing the scale of the image from the scale of intensity between 0 to 255 to between 0 to 1, which makes the image brighter and clearer than the image in the previous process, the results are shown in Figure 7.  The next process is the subtract process in the image which is a gradient morphology which is used to increase the intensity of the edges to be thicker and clearer, the results are shown in Figure 9. Then fill in the letters and numbers on the number plate which initially only detected the edges of the contours of the object. This is done to request that the object not be cut off, the results are shown in Figure 10. The next process is carried out with a morphological process that aims to isolate the character, which will then proceed to the erosion process. Morphological results are shown in Figure 11.  Figure 11. Image after Morphology The last process before object detection is the erosion process, this process aims to erode the noise that occurs due to the previous preprocessing process. The results of the erosion process are shown in Figure 12.

Figure 12. Image after Erosion
Bwareaopen is a function used at the final stage of character recognition of fan letter characters on a number plate, which removes images that are less than 100 pixels. Then the number plate will be segmented into character pieces inside the number plate, where the results are shown in figure 13. Figure 13. Image after Cropping While the detailed segmentation process is as follows: 1. Use the labeling function with the 8-connectivity rule. Labeling is used to group each pixel that is interconnected according to the 8-connectivity rule. Each connected component that is not connected to each other in an image will be labeled differently. 2. Use a function to hold coordinates on each pixel that has been labeled based on rows and columns 3. After all pixel coordinates are accommodated, crop pixels with labels vary. The pixel coordinates used in the crop consist of 4 pixels, the top pixel, the lowest pixel, the pixel pixel and the left pixel from each label. All segmented images are then resized to 24x42 pixels to match the size with the template data. The final step of the image will be recognized by the maching template method and the results will be saved to .txt. The segmentation image will be compared with template data (A-Z, 9-0) to find the highest correlation value using equation (1). The template used in this study is shown in Figure 14.