## 2 Materials and Methods
### Estimation of the Working Distance  
Referring to Equations (3) and (5), we see that accurate estimation of the working distance is a prerequisite of both uniform and non-uniform methods. The method for estimating the working distance has been presented in [24]. The method is described very shortly here, followed by an improvement over the previous approach. The position of a laser point is a function of the working distance, once the effect of magnification and rotation and displacement of the FOV are compensated for [24]. Therefore, we may train a statistical model that could decode the working distance from the position of a laser point. In [24], this was achieved by converting the position of the laser point from the Cartesian coordinate system into the polar coordinate system. Then, the radius component (r) of the position of the laser point was used for the training of the model. Equations (9) and (10) show the model (\(\mathcal{G}\)), where \(\rm r_{ij}\) is the radius computed from the laser point i at the working distance \(\rm w_{j}\), and \(\rm\beta_{i1},\ \rm\beta_{i2},\ \rm\beta_{i3},\ \rm\beta_{i4}\) are some constants determined during the training process:  
\[\rm w_{j}=\mathcal{G}(\rm r_{ij}) \tag{9}\]  
\[\mathcal{G}\big{(}\rm r_{ij}\big{)}=\rm\beta_{i1}e^{\rm\beta_{i2}\rm r_{ij}}+ \rm\beta_{i3}e^{\rm\beta_{i4}\rm r_{ij}} \tag{10}\]  
The original model also assumed that the data were mapped into a standard template by applying a chain of rotation, translation, and scaling operations on the recorded images. Flexible endoscopes have a fiducial marker (see, e.g., protrusion on right side of circle in Figures 4 and 6) that helps with the orientation of the recorded images. The rotation operation was parametrized in terms of the angle between the positive x-axis and the line connecting the fiducial marker to the FOV center. The rotation operation brings this  
Figure 6: Expressing a general measurement in terms of radial measurements. angle to a fixed and standard value across all recordings [24]. This value will be further termed standard angle. In essence, the standard angle it is the angle between the fiducial marker and the x-axis of the image after undergoing the rotation operation. For example, the standard angle of Figure 6 is zero degrees. First, we show that the performance of the original method depends on the value of this angle; then we propose an improved version to alleviate this problem. Ten-fold cross-validation over Set 2 was used to evaluate the effect of different standard angles on the accuracy of estimation of the working distance. To that end, the standard angle of the method proposed in [24] was varied between 0\({}^{\circ}\) and 180\({}^{\circ}\) in 5\({}^{\circ}\) increments, and then the segmented laser points from the training set were used to create the model. It has been shown that laser points from the top row (Figure 7A) degrade the accuracy of measurements [24]; therefore, laser points from the top row were discarded for this analysis. The trained model was then applied to the testing set, and measurement errors from the remaining 42 laser points were computed. MAE over all 10 folds is shown in Figure 7B. Figure 7B shows that the accuracy of the original method highly depends on the choice of the standard angle. Principal component analysis (PCA) is a mapping that is robust to linear transformations of the data points, including their rotation. Consequently, we propose a slight improvement over the original method. Let \(\mathrm{P_{ii}}\)\(\left| \begin{array}{c}\mathrm{x_{ij}}\\ \mathrm{y_{ij}}\end{array} \right.\) be the Cartesian coordinates of the laser point i (\(1\leq\mathrm{i}\leq 49\)) at the working distance \(\mathrm{w_{j}}\). We can store \(\mathrm{P_{ij}}\) for a specific value of \(i\) and all values of j (\(1\leq\mathrm{j}\leq\mathrm{n}\)) into a \(2\times\mathrm{n}\) data matrix \(\mathrm{P_{i}}\), where \(\mathrm{n}\) is the number of working distances in the dataset.