## 3 Image Acquisition and Distortion Correction
### Circumferential Distortion Correction  
Before correction, the collected images of the inner surface of the holes need to undergo preprocessing [21], which includes gray conversion, median filtering and Laplacian sharpening. The gray conversion process uses a weighted average method that considers human sensitivity to three-channel colors. Each component is assigned a weight of 0.299, 0.587 and 0.114, respectively, to derive the corresponding gray value. Median filtering involves using the median gray value of a 3 \(\times\) 3 neighborhood surrounding each pixel as its own gray value, while Laplacian sharpening utilizes second-order differentiation in eight directions within a 3 \(\times\) 3 neighborhood to reflect abrupt changes in pixel grayscale values. Image sharpening can be achieved by adding this result to the original pixel. The results are shown in Figure 7b. Since the tool path is circular during hole machining process, Hough transform [22] is used to detect the center of the background texture in the peep image and consider it as the image center (\(u_{c}\), \(v_{c}\)). Firstly, the edge information is detected based on the discontinuity of the gray value of the image. Then, edges with a circular arc feature are identified using the Hough transform algorithm. By searching for maximum circle center overlap in the parameter space, contour and center coordinates that best match arc characteristics are obtained. The essence of the Hough circle detection algorithm lies in converting image plane coordinates into Hough space coordinates. A circle can be expressed in Cartesian coordinates as \((x-a)^{2}+(y-b)^{2}=R^{2}\), where a point \((x_{i}-a)+(y_{i}-b)^{2}=R^{2}\) is substituted. This equation represents a cone in Hough space with three parameters: a, b, and R. When this cone is projected onto the a-b plane, it becomes a circle. All circles with equal radii in Cartesian coordinates correspond to intersecting circles on the a-b plane in Hough space that share one common point. By identifying the most frequently occurring overlapping points in Hough space and subsequently converting them back to Cartesian coordinates on the image plane, a circle can be obtained with its center serving as the focal point of the image. The process of image preprocessing and circle center detection is shown in Figure 7, where (a) represents the original image, (b) shows the result of preprocessing, (c) displays the edge detection result, and (d) demonstrates the image center detection outcome. All image sizes are 980 \(\times\) 720 pixels, and the endoscopic image's center coordinates are (492, 348). Based on these coordinates, Figure 8 illustrates the circumferential correction results obtained using the difference expansion algorithm. Figure 8: Circumferential correction results. Figure 7: Preprocessing and center detection. (**a**) original image, (**b**) pre-processing results, (**c**) edge detection results, (**d**) center detection results. The goal of circumferential correction is to ensure the points with equal circumferential spacing on the inner surface of the hole maintain equal spacing after correction, while also ensuring that any circumference of the inner surface of the hole has consistent horizontal coordinates in the corrected image. As shown in Figure 6, the width of each calibration block is consistently maintained after circumferential correction. The pixel width was calculated by reading pixel coordinates and had an average of 44.76 pixels with a standard deviation of 1.53, indicating ideal correction effects. After correction, each pixel represented an actual circumferential arc length of \(i\) = 0.0335 mm/pixel. The N-axis coordinates of nine lines' calibration block centroids were counted, and their standard deviation was calculated as shown in Table 1.  
In Table 1, the minimum standard deviation in Row 6 is only 1.506. The pixels with large deviation are mainly concentrated at the top and bottom of the image due to inaccurate centering of the endoscopic image, causing horizontal pixel fluctuations.