# Particle Swarm Optimisation in Practice: Multiple Applications in a Digital Microscope System
## 7 Conclusions  
We have shown some software components of a digital inspection microscope for testing medical devices. The underlying theme is the use of PSO as an algorithm in many different tasks. We have shown that such a heuristic algorithm provides good results for all of them. The first task sees the use of the PSO algorithm to improve upon the original calibration system for the height from focus. Originally this was performed with a poor measurement method, resulting in noisy data and required shipping the microscope back to factory. In the new approach, the PSO is used to optimally fit a polynomial to these noisy data automatically, thus creating a smoother calibrating model. This method has been shown to significantly increase the accuracy of the system. It is important to take sufficient samples for this method to work. When trying to replace PSO with more complex algorithms, i.e., the CMA-ES, we noted only a marginal difference in the results, which is not significant enough to use this computationally more expensive algorithm. The method used shows the viability of calibrating a system for this and other measurements prior to having optimised measurement methods, and releasing those systems to customers and correcting the noisy calibration data once the measurements are optimised. The second important task is the so-called matching of images for image stitching. Here, we improve a conventional template matching algorithm using PSO. Results show that the newly proposed approach is most accurate when the object has a low variance in features as this results in an ideal search space. When there are many features, the search space results in a very small area. If no particle explores this area, then the matching fails; however, when there are many features, standard interest point matching can be used. The PSO matching time takes approximately 365 ms and the matching function was 100% accurate on every run of experiments 1 and 2 in Section 4.3 with maximum dropout (25%) and noise (10%). With PSO-supported 2D point cloud matching, we introduce a method to deal with cases where neither feature point matching nor template matching can be applied. This works by adding laser points to the scene and shows a lot of promise. Using PSO provides a robust solution and creating interest points using distance to other points results in the potential for real-time matching. Thirdly, the problem of colour correction is tackled by using a PSO algorithm with no outlier rejection. This produces a colour correction matrix as good as, or slightly better than, the standard pseudo-inverse matrix method. Adding outlier rejection decreased the error by 11.3%, visibly improving the colour reproduction. Hence, the PSO algorithm is reliable in this application and beats conventional algorithms. \begin{table}
\begin{tabular}{c c} \hline \hline
**Run** & **Max Pix Error (um)** \\ \hline
1 & 7 \\
2 & 7 \\
3 & 8 \\
4 & 9 \\
5 & 6 \\
6 & 12 \\
7 & 6 \\
8 & 13 \\
9 & 8 \\
10 & 8 \\ \hline \hline \end{tabular}
\end{table} 
Table 14: PSO real results over 10 searches. Fourthly, image distortions are corrected through PSO and CMA-ES. Here, the CMA-ES search seems to be more consistent across multiple runs than the PSO search, which also gave satisfactory results. Indeed, the PSO search for a solution to image distortion correction has been shown to increase measurement accuracy from 247 \(\upmu\)m to average accuracy of 8.4 \(\upmu\)m. As this calibration is performed once per system, a number of runs could be made and the lowest error homography matrix and polynomial constants picked, reaching the quality of CMA-ES. Overall, there are many potential uses of PSO in this application. We have demonstrated four of them. In all cases, the PSO-based algorithm can either reach the quality of the current best approach or beat it. In some cases, it also offers a speed advantage. In this way, we have demonstrated the applicability of PSO in an industrial setting. This research received no external funding. Not applicable.