# Particle Swarm Optimisation in Practice: Multiple Applications in a Digital Microscope System
## 6 Image Distortion Correction
### Results
#### 6.4.2 Real Data Results  
A calibration chart, shown in Figure 23, with 19 \(\times\) 19 dots was manually placed under the camera and positioned in the approximate centre of the field of view. The dots were detected with a blob detector and their centre recorded as per Figure 24.  
The PSO algorithm and CMA-ES [35] algorithm were used to find solutions to map the distorted points to undistorted points. A library was used to implement the CMA-ES function [47]. The results are shown in Tables 11 and 12, respectively. In total, 12 images were taken with a reference ruler in different positions and points 10 mm apart were selected manually. Figure 25 shows these images and the reference 10 mm measurements. Referring to Table 13, the points at the start and end of each 10 mm measurement are shown, with P1\({}_{x}\), P1\({}_{y}\) being one point and P2\({}_{x}\), P2\({}_{y}\) being the second point. The real number of pixels between the points is shown in the R\({}_{\rm pix}\) column. Each point is transformed using the solutions found and the predicted number of pixels between the transformed points is given in the P\({}_{\rm pix}\) column. The average of the predicted number of pixels is divided by 12 to give a pixel to mm ratio. This ratio is multiplied by the predicted number of pixels to give a predicted length shown in column P\({}_{\rm len}\). The real length, column R\({}_{\rm len}\) is calculated the same way. \begin{table}
\begin{tabular}{c c c c} \hline
**Run** & **Loss** & **Max Pix Error** & **Avg Pix Error** \\ \hline
1 & 168.7 & 1.55 & 0.62 \\
2 & 187.6 & 1.67 & 0.62 \\
3 & 187.2 & 1.64 & 0.62 \\
4 & 209.9 & 1.87 & 0.66 \\
5 & 212.9 & 1.88 & 0.67 \\
6 & 250.8 & 2.04 & 0.72 \\
7 & 209.4 & 1.83 & 0.66 \\
8 & 229.1 & 2.02 & 0.69 \\
9 & 187.9 & 1.70 & 0.62 \\
10 & 224.6 & 1.91 & 0.68 \\ \hline \end{tabular}
\end{table} 
Table 11: PSO real results. Figure 24: Detected points. The resolution in the horizontal direction is 10 mm \(\div\) 1920 = 5.2 um and in the vertical direction is 10 mm \(\div\) 1080 = 9.26 um. When no image distortion correction is used, a \begin{table}
\begin{tabular}{c|c c c c|c c c|c c c} \hline \hline \multirow{2}{*}{\#} & \multicolumn{4}{c|}{**Raw Data**} & \multicolumn{4}{c|}{**CMA-ES**} & \multicolumn{4}{c}{**PSO**} \\  & **P1\({}_{\mathbf{x}}\)** & **P1\({}_{\mathbf{y}}\)** & **P2\({}_{\mathbf{x}}\)** & **P2\({}_{\mathbf{y}}\)** & **R\({}_{\text{pix}}\)** & **P\({}_{\text{pix}}\)** & **R\({}_{\text{len}}\)** & **P\({}_{\text{len}}\)** & **P\({}_{\text{pix}}\)** & **R\({}_{\text{len}}\)** & **P\({}_{\text{len}}\)** \\ \hline
1 & 550 & 631 & 1395 & 633 & 845.0 & 857.5 & 9.850 & 10.008 & 856.3 & 9.850 & 9.994 \\
2 & 552 & 144 & 1402 & 148 & 850.0 & 857.3 & 9.909 & 10.006 & 857.0 & 9.909 & 10.002 \\
3 & 551 & 1034 & 1407 & 1039 & 856.0 & 856.1 & 9.979 & 9.992 & 856.3 & 9.979 & 9.995 \\
4 & 390 & 971 & 1141 & 562 & 855.2 & 856.6 & 9.969 & 9.998 & 857.5 & 9.969 & 10.009 \\
5 & 792 & 451 & 1537 & 870 & 854.7 & 856.7 & 9.964 & 9.999 & 857.4 & 9.964 & 10.007 \\
6 & 61 & 925 & 49 & 48 & 877.1 & 857.3 & 10.224 & 10.006 & 877.1 & 10.224 & 10.007 \\
7 & 500 & 954 & 495 & 102 & 852.0 & 856.9 & 9.932 & 10.002 & 857.2 & 9.932 & 10.005 \\
8 & 922 & 940 & 926 & 96 & 844.0 & 857.3 & 9.839 & 10.007 & 856.4 & 9.839 & 9.996 \\
9 & 1300 & 961 & 1294 & 111 & 850.0 & 857.1 & 9.909 & 10.004 & 856.8 & 9.909 & 10.001 \\
10 & 1834 & 939 & 1832 & 60 & 879.0 & 856.2 & 10.247 & 9.993 & 856.2 & 10.247 & 9.993 \\
11 & 863 & 266 & 1726 & 266 & 863.0 & 856.4 & 10.060 & 9.995 & 856.5 & 10.060 & 9.997 \\
12 & 888 & 833 & 1756 & 844 & 868.1 & 856.2 & 10.119 & 9.993 & 856.2 & 10.119 & 9.994 \\ \hline \hline \end{tabular}
\end{table} 
Table 13: _Resultsonrealimage_ using CMA-ES and PSO. The first column (#) reports the measurement number (see Figure 25) while raw data are reported in the second column as reference. Figure 25: Twelve sample images, including a reference ruler, used for evaluating the image distortion algorithms. maximum measurement error of 247 um (Table 13) is found.