# Dealing with Low Quality Images in Railway Obstacle Detection System
## 5 Comparative Analysis of Proposed and Existing Methods
### Results and Discussion  
For quantitative evaluation, we implemented the proposed algorithm and compared the obtained results with several other state-of-the-art BD algorithms. In order to make a fair comparison regarding complexity and time-consuming issues, we chose several algorithms both from the edge-based and the frequency-based groups, described in Section 3, and ran them under identical conditions as the proposed algorithm (equipment, programming language, database, etc.). All the algorithms were implemented in Python with the usage of different functions from the OpenCV library. Finally, the performances of several different BD approaches were evaluated, calculating the overall accuracy, precision, recall values, and F-measure as  
\[ \begin{array}{l}A_{cc}=\frac{TB+TNB}{TI},\\ P_{re}=\frac{TB}{TB+FB},\\ R_{cc}=\frac{TB}{TB+FB},\\ F=2\times\frac{P_{re}\times R_{ac}}{P_{re}+R_{cc}},\end{array}  \tag{12}\]  
where \(TB\) (true blur) represents the number of correctly identified blurred images, \(FB\) (false blur) is the number of non-blur images incorrectly identified as blurred, \(TNB\) (true non-blur)  
Figure 6: Selected examples of images in our railway dataset. means the number of correctly identified non-blur images, _TI_ is the total number of images, and _TBI_ represents the total number of blurred images in the testing dataset. As can be seen from the previous subsection, the evaluation dataset has _TI_ = 872 and _TBI_ = 252. The proposed improved Laplacian edge detection algorithm for blur assessment started by transferring all the images into the grayscale form with a unique resolution of 1024 \(\times\) 768 pixels followed by noise reduction, as already described in Section 4. The next step was to manually classify all the images into four groups (DayBlur, DayNotBlur, NightBlur, NightNotBlur), so we could calculate the day and night threshold values to be used for the separation of the images:  
\[ \begin{array}{l}D_{T}=\frac{1}{2}\left(\frac{D_{T}^{b}}{D_{T}^{b}}+\frac{D_{ T}^{ab}}{D^{ab}}\right),\\ N_{T}=\frac{1}{2}\left(\frac{N_{T}^{b}}{N_{T}^{b}}+\frac{N_{T}^{ab}}{N_{T}^{ab}} \right),\end{array}  \tag{13}\]  
where the symbols have the following meanings: _D_--day, _N_--night, _T_--threshold, _b_--blur, _nb_--non blur, _c_--count, and _s_--sum. A detailed explanation of these parameters is given in Figure 4. The values obtained from our training database (1308 images) are \(D_{T}\) = 87.80 and \(N_{T}\) = 74.12. With these threshold values, we obtain the results from the testing phase, presented in Table 1 (_Proposed algorithm_ column). Based on the algorithm from [50], the first algorithm for comparison belongs to the group of frequency-based algorithms and it is described in detail in [51]. A fast Fourier transform is applied to the image using the default _matplotlib_ and _NumPy_ functions. After that, the mean value in the transformed image is taken and scaled with respect to the size of the image to compensate for the rippling effect. This value is then used to threshold the image, with higher values indicating non-blurred images and lower values indicating blurred images. The obtained results are presented in Table 1 (_FFT method_ column). The second algorithm for comparison is part of the edge-based algorithm group, and it was designed using the Laplace operator [39; 52]. We used the same Laplace kernel as in (10), calculated the variance by using the existing function in OpenCV, and compared it to a predetermined threshold, which was set to 80 for fair comparison with the results of our improved method. As can be seen from the obtained results in Table 1 (_Laplacian method_ column), this algorithm in its definition is very similar to the proposed improved algorithm, but unlike it, the results obtained are highly susceptible to noise and depend on the user's intuition when deciding on a threshold value. In addition, we implemented an algorithm based on the Canny operator [37].