#### Abstract

The machining accuracy of the compensation hole of the automobile brake master cylinder directly determines the safety of the automobile and the reliability of parking. How to detect the parameters of the compensation hole with high precision becomes a crucial issue. In this paper, by analyzing the principle of Hough transform detection technology and several optimization algorithms, a new method combining Zernike moment and improved gradient Hough transform is proposed to detect the circular hole parameters. The simulation experiment shows that the proposed algorithm satisfies 0.1 pixels in the coordinate detection of the center position, and the radius detection accuracy is 0.05 pixels, with fast detection speed and good robustness. Compared with the random Hough transform algorithm and the gradient Hough transform algorithm, the algorithm proposed in this paper has higher detection accuracy, faster detection speed, and better robustness, which meets the online detection accuracy requirements of the brake master cylinder compensation hole.

#### 1. Introduction

With the development of society, automobiles are also increasing. The reliability of automobile braking systems has become an important issue to be considered in the development of the automobile industry. At present, the compensation hole hydraulic brake master cylinder [1–3] is still an important part of the automobile brake system. The purpose of the brake master cylinder is to transfer the pressure of the driver on the brake pedal through a vacuum booster to the brakes of the four wheels so that the vehicle can decelerate or stop. As a key part of adjusting the brake fluid in the reservoir and pressure chamber of the automobile’s brake master cylinder, its dimensional accuracy and processing quality are strictly controlled. Taking the brake master cylinder of ZDZG-22.2-12.385-1 as an example, the nominal size of the compensation hole diameter is 0.7 mm, and the dimensional accuracy is ±0.021 mm. The service life requirement of brake master cylinder of automobile in China is to achieve 500,000 times at normal temperature and 120,000 times at 70°C. However, if the size of compensation hole does not meet the precision requirement, it cannot play the role of accurately controlling the speed of the brake fluid adjustment and the brake will fail, so the number of uses is far less than the use requirements; thus, the size of the compensation hole of the master cylinder must strictly meet the accuracy requirements. However, because the compensation hole of the automobile brake master cylinder is located on the inner side wall of the deep cavity blind hole [4], the existing measuring methods mainly include contact measurement and noncontact measurement, the contact-type measuring is mainly mechanical, such as coordinate measurement. Some scholars have proposed other contact measurement methods. For example, Professor Masuzawa of Tokyo University of Japan proposed a method for measuring deep-hole inner diameter by oscillating scanning measurement. The measurement method is to apply an oscillating circuit to the probe. When the probe contacts the hole wall, the circuit is online and disconnected when it is not in contact. The length of signal that can be detected is determined by the distance between the probe and the hole wall. The aperture is determined by the duty cycle of the signal. Although the contact measurement guarantees the accuracy of dimension to a certain extent, it is difficult to guarantee the real-time detection, and it will produce certain wear on the workpiece. The sampling and individual measurement methods of contact measurement lay a great hidden danger to the reliability of the automobile brake system. With the development of noncontact measurement, noncontact measurement has attracted more and more attention of scientific researchers due to its advantages such as no force on workpiece, fast detection speed, and high detection accuracy. Relevant scholars have developed a large-scale spy bore system based on CCD-TV [5], which can save and recall the observed images and qualitatively observe the aperture through optical means. However, the equipment is large and bulky, which is not easy to operate. Subsequently, in Zhang [6] et al.’s study, by using the structure of periscope and cooperating with grating ruler and stepper motor, the aperture measurement was realized. Wang [7] et al. developed a device for measuring position parameters of compensation hole by means of human–machine interaction. However, due to manual participation, the diameter of compensation hole detected is affected by workers’ actual working experience and fatigue level, and its detection accuracy is low. Du et al. [8], based on LabVIEW software, using image processing algorithms such as filtering, segmentation, and fitting, designed a set of high-precision visual inspection systems with high detection accuracy and fast processing speed, which provides important help for modern hole-type parts inspection method.

With the continuous development of machine vision, with its advantages of high efficiency, accuracy, and stability, it has become a very good method for noncontact measurement [9–12]. Through image processing algorithm, the parameter detection of target in image is completed, in which Hough transform detects target in image through space conversion and achieves better results. The circle Hough transform (CHT) is a parameter estimation algorithm based on the voting principle proposed by Hough in 1962 [13–15]. Circle Hough transform maps the sample points to the parameter space by using the transform of two coordinate systems and then determines the circular parameters by finding the peak value in the parameter space by using statistical voting or building an accumulator. Circle Hough transform has good robustness and antinoise ability. However, because the traditional Hough transform is a one-to-many mapping, there are problems such as a large amount of calculation, a large amount of resources, and a long detection time. In 1993, Xu et al. [16–18] proposed the Randomized Hough Transform algorithm (RHT), based on the principle that three points that are not on a straight line can determine the center of the circle, realizes many-to-one mapping, avoids a huge amount of calculation, and reduces the demand for memory. Afterwards, the researchers integrated the gradient information into the Hough transform, that is, the gradient Hough transform [19, 20], using the principle that the edge point gradient points to the center of the circle, to convert the cumulative matrix of the circle contour from three-dimensional to two-dimensional, but the algorithm is affected by noise serious. Therefore, in 2005, Cai and Zhou [21] proposed the gradient symmetry Hough transform, which effectively avoided the influence of noise on the coordinates of the detection circle center position by finding the gradient symmetry point. There are also some scholars who combine the Hough transform algorithm with machine learning algorithms to achieve very good results in target positioning, size detection, and flaw detection. Cha et al. [22] by combining the Hough transform with the support vector machine algorithm have constructed a robust separator, which automatically detects the bolt tightening and loosening and has real-time performance. Liu et al. [23] completed the detection of fabric point defects by combining the Hough transform and the application of the confrontation network. The defect detection rate is as high as 97.2%, which is better than traditional defect detection algorithms.

However, because these algorithms are based on pixel-level original contour extraction, they cannot meet high-precision detection requirements. For example, the accuracy of the edge detection of the brake master cylinder compensation hole directly affects the detection accuracy of the compensation hole size. If the detection accuracy is only improved from the hardware aspect, it will be very expensive. Therefore, how to implement subpixel edge detection through algorithms has become a research hotspot. Subpixel edge detection is to decompose the target edge pixels to locate more accurate edge positions. As the related algorithms of image edge subpixel detection [24–26] are successively proposed and improved and optimized, it is possible to detect the size of high precision. Therefore, the algorithm in this paper is combined and improved on the existing algorithm, and a high-precision method for obtaining circle parameters is proposed. The Zernike moment and the improved gradient Hough transform algorithm are combined to detect the circle hole parameters and realize the compensation of the automobile brake master cylinder. The high-precision detection of hole parameters is compared with similar algorithms under the same conditions. It is better than other algorithms in terms of speed, accuracy, robustness, etc. Therefore, the algorithm proposed in this paper can realize the real-time online detection requirements of the compensation hole of the automobile brake master cylinder.

#### 2. Subpixel Image Edge Extraction Based on Zernike Moment

Currently, subpixel edge detection algorithms mainly include moment method [25], interpolation method [27, 28], and edge fitting method [29, 30].Subpixel edge detection algorithm based on moment method mainly consists of gray moment, space moment, and Zernike moment. Zernike moment is an orthogonal moment [31] proposed by Ghosal and Methrotal in 1993, which solves the problem of redundant information in image processing because polynomials do not possess orthogonality. In this paper, the improved Zernike moment is used to extract the subpixels of the edge of the compensation hole. Figure 1 is the model of the subpixel edge of the image. The circle is the unit circle. The line represents the ideal edge of the part surrounded by the unit circle. The gray values on both sides of the inner edge of the unit circle are and , where is the gray difference, represents the distance from the origin to the edge, and represents the angle between the - and -axes. Figure 2 is the image of Figure 1 rotated by . At this time, the edge in the unit circle is perpendicular to the -axis. Let the rotated image be , so the following relationship exists:

The first step is to calculate the template coefficients of different orders. Using Zernike template [32], the template coefficients , , and of different orders of Zernike moment are calculated, as shown in Tables 1–4.

Through the convolution of the template and the image, Zernike’s moments , , and of different orders are obtained. Since the Zernike moment after the image rotation angle remains the same as the Zernike moment before image rotation, only the phase angle changes; the following relationship exists:

If the rotated Zernike moment is represented by , , and , according to the rotation invariance of formula (1), , , and can be expressed by the following equation:where can be expressed in the following form:

It can be seen from formula (1) that the imaginary part of is 0; then the following relational expression is given:where and represent the real and imaginary parts of , respectively. Then, you can get the calculation formula as follows:

Put the real and imaginary parts of the calculation result and the rotation angle into formula (1), to obtain the moment of the image after the image is rotated, as shown below:

According to the model in Figure 1, the calculation expressions of different orders of Zernike moment can be calculated after rotation.

The relationship of is as follows:

Simplify and get the expression of as follows:

The relationship of is as follows:

The expression of obtained by simplification is as follows:

The relationship of is as follows:

Simplify the expression of as follows:

Solving equations (3), (9), (11), and (13), we can further derive the distance from the origin to the edge , the gray value , and the gray value difference on both sides of the edge, the specific expressions.

Calculate the distance from the origin to the boundary:

Calculate the gray difference value on both sides of the boundary and the gray value on one side of the boundary:

After determining the inclination angle of the edge, the distance from the origin to the straight line, the gray value , and the gray difference value , the subpixel edge determination condition of Zernike moment is passed, and the point satisfying the condition is the subpixel edge point corresponding to the edge of the circular hole, where and are the threshold of gray difference and the threshold of distance from center to edge, respectively. The threshold value is determined by preexperiment. The larger and the smaller indicate that the harsher the conditions and the more accurate the subpixel edge was obtained, the same fewer edge points can be obtained.

Finally, while considering the template magnification effect [33], the subpixel coordinate position of the image is calculated by the following formula. The template effect is that the subpixel edge error is caused by the different size of the selected template, as long as it is calculated on the unit circle. The distance is increased to times the original, and the influence of the template effect can be removed. The specific expression is as follows, where is the template size:

#### 3. Hough Transform Based on Gradient Information

The Hough transform based on gradient information refers to the principle that the gradient direction of all pixels on the edge of the target points to the center of the circle. Due to the introduction of the gradient direction information of the edge, the parameter space is transformed from three-dimensional to two-dimensional, and the coordinate and gradient direction of pixel points on each target edge are made straight lines, and each point on the line is voted, in which the highest voting position is the coordinates of the center of a circle as shown in Figure 3.

The two edge points in Figure 3 are and . The coordinates of the two points are and , respectively. The gradient directions of the two points are and . After the edge points, draw straight lines and along the gradient direction. The intersection of the two straight lines is the target contour. The position of the center of the circle is represented by , and the center coordinates of the target contour can be calculated as [34]:

And by calculating the average value of the distance from the center coordinate to each pixel point on the edge of the target contour, the radius of the target circle can be obtained. The specific expression is as follows:

In the formula, and are the coordinates of the pixel on the edge contour, and is the distance between and the center of the circle .By calculating the average value of by the following formula, the radius of the target circle can be obtained:

However, the actual image will inevitably be affected by noise during acquisition and transmission, and the line in the gradient direction of edge points does not pass through the center accurately, so large errors will occur in calculating the position of the center of circle, which will affect the detection of the center and radius of the target contour.

#### 4. Circular Parameter Detection Algorithm Based on Circular Gradient Center Symmetric Point Hough Transform

Due to the Hough transform based on gradient information, in the presence of noise, the normal direction will be offset from the center of the circle. while there are still a large number of invalid accumulation problems in the symmetric Hough transform based on circular gradient. The algorithm in this paper is based on gradient information. It is proposed on the basis of Hough transform and circular gradient symmetry Hough transform. By calculating the detection method of Hough transformation of the center symmetry point of the circular gradient, the algorithm replaces the need to find symmetry points about the -axis and the-axis in the circular gradient symmetry method and then accumulates the data on the median bisector of the symmetry point, which causes a lot of invalid accumulation problems. It is proposed to find symmetrical points directly. Because the symmetrical points on the circle pass through the center of the circle, a large amount of invalid accumulation time can be saved to realize the parameter detection of the circular hole.

The principle of the Hough transform algorithm based on the center symmetry point of the circular gradient is to randomly select a point on the edge of the target and then search for the symmetry point in the image. The meaning of symmetric point is that the direction of vertical gradient and horizontal gradient are opposite to the direction of selected point. The relationship between the direction and size of the symmetry point is shown in Figure 4.

In the figure, represents the vertical direction, and represents the horizontal direction, where the direction of the arrow represents the gradient direction, and its combined direction points to the center of the circle. We can see from the graph that points a and *d* are symmetrical with respect to origin , they have similar size on gradient value, opposite vertical direction, and opposite horizontal direction, and the center of the circle passes through the line between points a and *d*. By finding a point in the rectangle surrounded by point *a* at the upper-left corner and *d* by point *d* at the lower-right corner, the angle between point *a* and point *d* is smaller than a fixed threshold , and the value of is determined by a preexperiment. The larger the value is, the more demanding the conditions are, and the fewer points fall in the region. Instead, the more points fall in the region and the more points the center may be voted on. By randomly selecting points on the target edge several times for calculation, the possible center position of the circle is formed at the center of the circle as shown in Figure 5. The center of the circle is calculated as the center of the target circle.

The algorithm does not completely rely on the gradient direction to determine the position of the center of the circle while using the gradient. The noise points in the image are removed by searching for the symmetrical points of the center of the circle. In the case of defective edges of the circle image, the parameter information of the circle can also be accurately detected.

#### 5. Experiment and Result Analysis

According to the Hough transform based on the central symmetry point of the circular gradient and the joint-improved Zernike moment detection algorithm proposed in this paper, the subpixel edge detection is performed for the compensation hole of the automobile brake master cylinder and the parameters of the circular hole are obtained. The image of the hole is only a part of the image. If the entire image is detected, the detection speed will inevitably be reduced. With the development of deep learning, Fast-RCNN based on convolutional neural network that automatically locates and detects the appearance area shows excellent characteristics [35, 36], so through network migration, the input layer and output layer of the trained Fast-RCNN network are removed, and the middle layer is retained. By collecting 40 images of compensating holes of different brake main cylinders as training images, the trained network can accurately and quickly detect the area of compensation hole from the image, realize fast positioning of compensating holes, and then only perform edge detection on the area of compensating holes to achieve high-precision detection of compensating hole size. The specific detection steps are as follows: *Step 1*. Firstly, the trained Fast-RCNN is obtained through network migration, which can quickly locate the compensation hole in the area and then only process the compensation hole in the area. *Step 2*. The area of compensation hole detected in Step1 is filtered by Gauss filtering to filter the noise in the image in preparation for the next edge detection. *Step 3*. For the noise-reduced image obtained by Step2, the Zernike moment is calculated to obtain the subpixel coordinates of the image edge. Since the internal environment of the automobile brake master cylinder is similar, the subpixel positioning on both sides of the edge can be determined through preliminary experiments. Therefore, the values of gray difference threshold and distance threshold on both sides of edge in subpixel positioning can be determined experimentally in advance; in this article, the values of and are predetermined to be 43 pixels and 0.1143 pixels by experiment. *Step 4*. The edge detection of the compensation hole is performed through the Sobel operator, the gradient value and direction angle of the edge are calculated, and the gradient image is obtained. *Step 5*. Randomly select a point from the position of the edge in the gradient image and find the edge point that is symmetrical to the center of the target edge, that is, the pixel point with similar gradient size and opposite horizontal gradient and vertical gradient. *Step 6*. Find the center point of the circle that meets the conditions from the area enclosed by the two edge points. The condition is that the angle difference between the center point of the circle and the two edge points is less than the set threshold , and the center point that meets the condition is voted. Among them, is determined by preexperiment, and the value of is 3° in this algorithm. *Step 7*. As shown in Figure 6, calculate the average value of the distance between the center of the circle and the subpixel point on the edge of the circle through formulas (18) and (19), and record it as the radius . *Step 8*. Draw it in the image.

##### 5.1. Detect Ideal Image Experiment

First, a 500500 image is generated by using the computer, in which a circle with a center of *O* (220, 280) pixels and a radius of *R* of 95.5 pixels is generated, in which the background is black, and the circle is white. By comparing the traditional random Hough transform, the Hough transform based on gradient value and the calculation accuracy and frame rate of the algorithm in this paper, as shown in Figures 7(a)–7(d), the red origin in the graph represents the center of the circle detected, and the green circle represents the edge of the circle detected by the algorithm. Through subjective observation of the circular edge detection effect in the figure, the random Hough and gradient Hough transform have little difference in the center position detection, but they exist on the edge of the circle. The detection algorithm proposed in this paper is obviously superior to the other two detection algorithms in the center of the circular hole and the edge detection effect.

**(a)**

**(b)**

**(c)**

**(d)**

The edge parameters of computer-generated circular image are detected, including the size of the image being 500500 pixels, the theoretical center position of the circle being (220, 280) pixels, and the theoretical radius being 95.5 pixels. The center position deviation detected by random Hough transform and gradient Hough transformation is between 1 and 2 pixels, and there is no deviation in the center position through the algorithm proposed in this paper. In terms of circular radius detection, the deviation between the radius and the theoretical radius pixel detected by random Hough transform and gradient Hough transform is more than 2 pixels, and through the detection algorithm proposed in this paper, the difference between the detected radius pixel value and the theoretical pixel value is only less than 0.05 pixels, and the detection accuracy is higher. In terms of the complexity of the algorithm, we know that the traditional Hough transform is a typical “one-to-many” mapping. The algorithm time complexity is . The random Hough transform and gradient Hough transform developed on the basis of it being in complexity aspects have been reduced, but the time complexity of the algorithm is still , and the algorithm proposed in this paper is simple and the parallel processing method has been adopted to further improve the complexity of the algorithm. The complexity of the algorithm is . From the table below, it can also be seen from the processing frame rate that when processing an image with a resolution of 500500 pixels, the frame rate processed by this algorithm is 3, while the frame rate of the other two algorithms is 2, so the processing frame rate of this algorithm is better than the other two algorithms being more suitable for the needs of online detection. The circular parameters detected are shown in Table 5.

##### 5.2. Algorithm Robustness Experiment

Because image is susceptibly contaminated by noise in the process of forming, transmitting, receiving, etc., and image noise will affect the result of image edge detection and then affect the detection accuracy of target size, this article is verified by manually adding noise to the generated image. The robustness of the proposed algorithm is verified. Among them, Gaussian noise is the most widely existing noise in image noise. Therefore, by adding Gaussian noise to the generated image, the robustness performance of the algorithm in this paper is verified. In the computer-generated image, the mean value and the variance are, respectively, added. The Gaussian noises of , , and can be seen from Figures 8(a) and 8(d). With the increase of variance, the noise content in image increases gradually, but the center and edge contour of the circle detected by the algorithm in this paper do not change significantly. Even when the image is heavily contaminated by noise, it still has a good noise resistance, which shows that the proposed algorithm has good robustness.

**(a)**

**(b)**

**(c)**

**(d)**

##### 5.3. Actual Detection Experiment of Compensation Hole

Finally, a motion mechanism and image acquisition system with high accuracy and efficiency are developed and tested on this system [2, 37].This experimental system consists of a high-precision lifting mechanism, an integrating sphere lighting system, a CCD camera, a self-developed double telecentric endoscope system, a motor, and a software processing system. As shown in Figure 9, by rotating the screw, the lifting mechanism with CCD camera enters the interior of the main brake cylinder of the vehicle, illuminates the integral ball illumination device outside the main brake cylinder, collects a clear image of the compensation hole of the secondary cylinder through software, transmits it to the computer in real time, and carries out real-time processing to obtain the contour information of the compensation hole of the standard master cylinder.

The algorithm flow is shown in Figure 10.This experiment detects the master cylinder of model ZDZG-22.2-12.385-1, the compensation hole diameter is 0.7 mm, and the detection accuracy is ±0.021 mm.

In order to compare the detection effects of various detection algorithms on the compensation hole being fair, we analyze the two aspects of (1) subjective observation of the compensation hole detection effect and (2) objective data detected by the compensation hole. First, collect a picture of the compensation hole of the automobile brake master cylinder. The picture of the compensation hole is shown in Figure 11(a). The same compensation hole image is rounded by the random Hough transform mentioned above, the gradient-based Hough transform, and the algorithm in this paper. The edge detection algorithm is implemented. The experimental computer for various algorithms is configured with i7cpu2, 8G memory, Windows 10 operating system, and the software used is MATLAB 2015b. The detection results are shown in Figures 11(b)–11(d).(1)Through subjective observation, we can see that the edge position of the compensation hole detected by random Hough has a large offset from the actual compensation hole, and the detected circle contour is obviously larger than the contour of the compensation hole, and the error is relatively large. The gradient information-based Hough transform is obviously better than the random Hough transform in the detection effect, and its relative error in the detection of the center position of the compensation hole is small, but there are still some errors in the contour detection of the compensating hole. The joint Zernike moment and the Hough transformation algorithm of the center symmetry point of the circular gradient proposed in this paper have better effect in detecting the parameters of the circular hole. It can be seen from Figure 11(d) that the edge overlaps well with the center position and edge of compensating hole, and there is no obvious offset in the center of compensating hole, which indicates that the detection effect of compensating hole is very accurate.(2)By recording the objective data of the compensation hole parameters and displaying it in Table 6, it is known from the above that the ZDZG-22.2-12.385-1 model master cylinder has a compensation hole radius of 0.35 mm, which is defined by one pixel in the image calibration. The representative actual size is 0.007291 mm, so the standard pixel size of the compensation hole in the image is 48 pixels. From Table 6, it can be seen that the pixel value of the compensation hole radius detected by the algorithm in this paper has the smallest difference with the standard size pixel value. It is 0.105 pixels, and the frame rate detected by the algorithm in this paper is also higher than the frame rate of the other two calculations. Therefore, it can be said that the detection accuracy and detection speed of the algorithm in this paper are due to the other two detection algorithms, using standard gauge blocks. After camera calibration [38, 39], the actual size of pix corresponding to each pixel is 0.007291 mm, and the actual diameter *D* of the brake master cylinder compensation hole is calculated by the formula

**(a)**

**(b)**

**(c)**

**(d)**

Finally, using random Hough transform, gradient Hough transform, and the algorithm in this paper, the same master cylinder compensation hole size is detected 30 times, and the pixel size of each time is recorded to form the experimental data shown in Table 7. The algorithm proposed in this paper calculates the average pixel radius of the compensation hole is 48.002 pixels, and the standard deviation is 0.003, which is better than random Hough transform and gradient Hough transform. The detection accuracy of the average radius is higher than 1.5 pixels. And draw the error between it and the standard size as the error curve shown in Figure 12. It can be clearly seen from the graph that the random Hough transform and gradient Hough transform algorithms have large errors, while the algorithm proposed in this paper has small errors and compensates. The accuracy of the hole radius is controlled within 0.05 pixels, which is significantly better than the other two detection algorithms. Therefore, the algorithm proposed in this paper has fast detection speed, high repeatability, and meets the real-time requirements of industrial sites.

#### 6. Conclusion

By introducing the algorithm theory of Hough transform and Zernike moment, this paper improves the edge detection algorithm of Hough transform based on gradient direction symmetry and achieves subpixel edge detection by combining Zernike moment. By comparing various Hough transform algorithms and the algorithm in this paper, it is found that the algorithm in this paper can accurately detect the parameter information of compensation hole of brake master cylinder, the radius detection accuracy is controlled at 0.05 pixels, with high detection accuracy, high speed, high repeatability, and good robustness; the new detection method is provided for online detection of compensation hole parameter information of automobile brake master cylinder. Although the proposed algorithm has some advantages in edge detection of compensation hole, how to further improve the speed and accuracy of detection becomes a difficult problem. With the development of deep convolution neural network, it gradually shows better effect in target recognition and semantics segmentation. How to combine classical image processing algorithm with depth learning algorithm? It will be the trend of our future research to apply it to the detection of compensation hole in the automobile brake master cylinder.

#### Data Availability

The data used to support the findings of this study are available from the corresponding author upon request.

#### Conflicts of Interest

The authors declare that there are no conflicts of interest regarding the publication of this paper.

#### Acknowledgments

The authors thank Professor Tao Jiang and the laboratory for the equipment support provided by the parameter detection of the compensation hole of the automobile brake master cylinder. This paper was supported by the National Key Research and Development Program, Development of Major Scientific Instruments and Equipment (2017YFF0105304); Key Research and Development Project of Jilin Province Science and Technology Development Plan (20200401117GX); and Jilin Province Provincial Industrial Innovation Special Fund Project (2018C038-4).