## 2 Materials and Methods
### Segmentation and Preprocessing  
Accurate detection of circular grids is a prerequisite of the proposed calibration method. An automatic two-stage method was developed for the segmentation of the circles from Set 1. To take advantage of the full 72 dB dynamic range of the camera, recordings were imported into MATLAB (MathWorks, Natick, MA, USA) directly in the native 12-bit format from the proprietary Vision-Research.cine (Vision Research Inc., Wayne, NJ, USA) files without any conversion or compression. To reduce the noise of images, frames of the recordings were averaged over time and then a Gaussian filter with a size of 2 pixels was applied. The Center and radius of the FOV were estimated using the method described in [24]. A strip parallel to the x-axis centered at the center of the FOV with a width of nine pixels was selected. The strip was averaged over the rows, and then locations of its local minima were detected. Detected locations were paired based on their distances from the center of the FOV. The average of each pair was used as the coarse estimation of the x-coordinate of centers of circles. Half of the difference between each pair was used as the row-wise estimation of radii of circles. This process was repeated for a strip parallel to the y-axis averaged over the columns. The average of each pair was used as the coarse estimation of the y-coordinate of centers of circles. Half of the difference between each pair was used as the column-wise estimation of radii of circles. The final coarse estimation of the radius of each circle was computed as the average of its row- and column-wise radii. A grid search over all combinations of the three estimated parameters \(\pm 1\) pixel with the resolution of 0.25 pixels was used for fine-tuning of the estimated parameters. Specifically, for each case, the target parameters were used to create a ring mask with a width of 1 pixel. The mask was then applied to the gradient of the image, and the summation of the results was used as the cost function. The set of parameters that minimized the cost function was selected as the final estimation of the center and radius of each circle. Figure 4 shows the process, with the results on an example image.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Dataset** & **Data Number.** & **Purpose** & **Recording Specs** \\ \hline Set 1 & 65 & \begin{tabular}{c} Training the model for conversion from \\ pixel into mm \\ \end{tabular} & \begin{tabular}{c} Circular grids \\ No laser light \\ \end{tabular} \\ \hline Set 2 & 72 & \begin{tabular}{c} Training the model for estimation of the \\ working distance \\ \end{tabular} & \begin{tabular}{c} White paper \\ With laser light \\ \end{tabular} \\ \hline Set 3 & 4 & \begin{tabular}{c} Checking validity of central angle \\ measurement from endoscopic images \\ \end{tabular} & \begin{tabular}{c} 15\({}^{\circ}\) sectors \\ No laser light \\ \end{tabular} \\ \hline Set 4 & 105 & \
\begin{tabular}{c} Evaluating accuracy of horizontal \\ measurements \\ \end{tabular} &
\begin{tabular}{c} Line segments \\ With laser light \\ \end{tabular} \\ \hline \hline \end{tabular}
\end{table}
Table 1: Summary of the datasets used in this study.  
The segmentation of the laser points for Set 2 was based on the method described in [24]. Target objects in Set 3 were 24 radial lines, which were detected using the Hough transform [30]. Figure 3B shows the grid after segmentation. The actual horizontal measurements on laryngeal images will rely on the manual segmentation of the target object. To better reflect this, a graphical user interface was developed for manual segmentation of line segments from Set 4.