# Towards Automatic License Plate Recognition in Challenging Conditions
## 3 Methodology
### The LP Localization  
The detected vehicle, confined by a bounding box that is obtained in the last step of Algorithm 1, is nursed to the LP localization module that aims to detect the LP. Our developed LP localization method has a few interconnected steps. The LP localization method processes the RGB image and transforms it into the HSV components as shown in Equations (1)-(3). \[H=\cos^{-1}\left[\frac{\frac{1}{2}[(R-G)+(R-B)]}{\sqrt[2]{(R-G)^{2}+(R-B)(G-B)} }\right] \tag{1}\]  
\[S=1-\frac{3}{R+G+B}[\min(R,G,B)] \tag{2}\]  
\[V=\frac{1}{3}(R+G+B) \tag{3}\]  
where \(H\) denotes hue, \(S\) represents saturation, and \(V\) stands for the value components of the transformed image. Our general observation is that an LP in actuality may have diversity and huge color variations. Considering this fact, in Algorithm 2, we introduce colors segmentation from lines 5-13 on each of the HSV components. During our simulations, we empirically vary the \(HT_{low}\) value from 0.02 to 0.40 and \(HT_{high}\) from 0.409 to 0.620. Similarly, for the saturation and value channels, their relevant low and high thresholds are \(ST_{low}\), \(ST_{high}\), \(VT_{low}\), and \(VT_{high}\), respectively, as indicated in lines 8-11 of Algorithm 2. For \(ST_{low}\), the values are changed from 0.370 to 0.500, whereas for \(ST_{high}\), they are changed from 0.909 to 1.10. For the V channel in the HSV image, the \(VT_{low}\) is set to 0.750 and the \(VT_{high}\) is kept at 1.0. After these thresholds are set, the mask images are obtained for each of the \(H\), \(S\), and \(V\) channels. For the H channel, the \(H_{mask}\) is set to 1 when the \(H_{Image}\) obtained is greater than or equal to the low threshold and less than or equal to the high threshold. A similar mechanism is applied to obtain the masks of the \(S\) and \(V\) channels. Consequently, a blob image \((A)\) is attained, which is indicated in line (11), which is analyzed by using morphological operations to enhance LP blobs in a sample space \((z)\). Here, dilation \((\oplus)\) is applied using Equation (4), which enlarges the features and adds pixel layers across the regions of associated elements. \[A\oplus B=\left\{z\middle|\left(B\right)z\bigcap A\
eq\phi\right. \tag{4}\]  
where \(B\) indicates a structuring element through which the blob image is dilated. Meanwhile, the closing \((\bullet)\) operation is applied using Equation (5), in which the license plate blob image is first dilated by structuring element \(B\) and then eroded by \(B\). The closing operation results in the smoothing of the contour and filling of the holes in the license plate blob. \[A\bullet B=(A\oplus B)\ominus B \tag{5}\]  
When the luminance is unsatisfactory, in Algorithm 2, we suggest illumination rectification as shown in lines 17-21. We use the PCA on the detected input vehicle image to fix the dimming of the image. By applying the PCA, we extract the Luminance and Chrominance channels of the RGB-colored vehicle image. In our work, only the luminance channel is processed further due to the fact that it contains a large amount of energy. After the mean of the luminance vector is calculated, we empirically estimate the low and upper limits of the threshold as shown in lines 19-21 in Algorithm 2. From lines 20-21, the luminance is adjusted to finally obtain the output image \((X^{\prime})\) with a much better luminance that can be handled later by the developed license plate detection module. We empirically estimate the low and upper limits of the threshold as shown in line (20) in Algorithm 2. We set the value of \(threshold_{low}\) to 0.25 and \(threshold_{high}\) to 0.95. From lines 21-22, the luminance is adjusted to obtain the final neat and clean enhanced output image \((X^{\prime})\). Once the improved luminance image is obtained, the dimensions of the extracted regions are examined to locate the existence of a possible license plate. We analyze the dimensions of the license plate through its spatial area and aspect ratio.