Abstract

This paper proposed a new subpixel detection method that detects subpixel edges directly, as opposed to the previous method, which requires crossing the entire image. It shows superior subpixel detection on the edge directly, which enhances subpixel edge detection speed significantly. In order to overcome the problem of noise reduction, this paper employs bilateral filtering. The method first performed coarse localization with the improved operator to determine the coordinates and gradient direction of the edge points. Then, the Zernike moment algorithm was used for subpixel repositioning of edge points. Finally, subpixel level edge positioning of the image is obtained. The detection algorithm is used to identify the edges of large-size workpieces, and the results reveal that the approach has superior positioning accuracy, noise immunity, and fast detection speed.

1. Introduction

Vision is the most significant mechanism through which humans perceive their surroundings and acquire information, particularly in the area of industrial inspection [1]. For the target identification system with more complex background, the accurate acquisition of edge information is more important.

Traditional pixel detection methods are based on the presence of grayscale variations at the image edges; the first- and second-order derivative operators are used to localize the edges, such as Roberts, Prewitt, Sobel, Laplacian, and Canny operators [2]. With the improvement of image refinement, this edge detection can no longer meet the requirements of subsequent processing, requiring an accuracy of less than one pixel, so subpixel edge detection is applied; subpixel detection can enhance pixel detection quality from the margins to the inside [3, 4].

Researchers have paid more attention to it. The corresponding improvement works were made. The commonly used subpixel edge detection algorithms are usually divided into the fitting method [5, 6], interpolation method [7, 8], and moment method [9, 10]. Among them, the interpolation method is relatively simple, but vulnerable to noise; the fitting method can obtain better edges, but the computational effort is relatively large, and the required model is more complicated. The method of moments has better noise immunity and efficiency than the interpolation and fitting methods. The method of moments has better noise immunity and efficiency than the interpolation and fitting methods and is widely used in high-accuracy detection systems.

Kisworo et al. [11] proposed a new method to extract edge features to subpixel accuracy using edge models and local energy functions. Although this method provides good results for 1-D and 2-D edge types of images, the type of edges must be known to use the correct model, so there are limitations in practical applications. Ye et al. [12] introduced a high-precision subpixel edge detection algorithm based on Gaussian edge model. Bouchara and Ramdani [13] established a variable model for edge detection, but the results are easily affected by the gradient direction and position.

Hermosilla et al. [14] combined ENO (Essentially None Oscillation) interpolation with gradient detection algorithms for edge detection. Xie et al. [15] first used the Canny algorithm to process and then applied Hermitian interpolation for precise positioning and realized the calculation of the edge area. Jensen and Anastassiou [16] proposed a nonlinear interpolation scheme, which presents lower reconstruction errors than linear techniques in sharper images. Pap and Zou [17] proposed a nonlinear fourth-order interpolation combined with Canny operator to achieve edge location.

Tabatabai and Mitchell [18] firstly achieved subpixel detection accuracy by using a third-order gray moment edge detection method, which provides edge positions in closed form without interpolation or iteration and is not affected by additive and multiplicative gray scale variations. Lyvers et al. [19] proposed a method based on spatial moments, using spatial moments and edge step parameters to determine the edge position. These two approaches are highly accurate, but they are computationally costly and are only appropriate for images with limited information. On the basis of summarizing traditional edge detection methods, Canny [20] proposed the Canny algorithm; its accuracy of identifying image edges is much higher compared to those of other edge detection algorithms. Ghosal and Mehrotra [21] proposed the ZOM (Zernike orthogonal moments) method, but this method is not suitable for detecting small objects accurately. Yang et al. [22] proposed an algorithm combined with Otsu’s [23] and a traditional Zernike moment method; the optimal gray threshold can be obtained directly for edge detection. The inspection time is shortened, and the inspection quality is also very good. Shan and Boon [24] used a moment algorithm based on the fuzzy edge model, which is more in line with the actual situation than the ideal step model. This method has a very high computational accuracy in a noise-free ideal image, but the error in the noise image is very high. Da and Zhang [25] used the Sobel operator to perform moment operation on the region of interest and realized the initial rough localization of the edge. Zhao et al. [26] proposed a new algorithm that utilizes combinatorial kernels to improve resource utilization. In addition, it optimizes the radial polynomial of Zernike moments to reduce computation. Deng and Gwo [27] proposed a generalized Zernike moments method to calculate high-order generalized Zernike moment; the corresponding improvement is made to get the solution that the algorithm was slow in determining the edge point.

To address the above limitations, this paper proposes an improved Canny-Zernike moment subpixel edge detection algorithm. The Zernike moment in the algorithm has stable size before and after rotation, so the positioning accuracy is high and the antinoise performance is strong. It has obvious advantages and is widely used in subpixel detection. In this paper, the subpixel edge detection algorithm based on Zernike moments is studied to locate the edge of the image, and the corresponding improvements are made in solving the problem that the algorithm is slow in determining edge points. The results show that the method has high accuracy, stronger robustness, and faster detection speed for subpixel edge detection.

2. Theory of Subpixel Edge Detection

The commonly used subpixel edge detection algorithms are usually divided into a fitting method, interpolation method, and moment method. According to the rotation invariance of the moment, it performs well in complex environments and is not sensitive to noise. So it is an effective subpixel image edge detection method at present. The commonly used moments are grayscale moment, space moment, Zernike moment, etc. Especially the Zernike moment has a stable size before and after rotation, so the positioning accuracy is high and the antinoise performance is strong.

The principle of subpixel edge localization based on Zernike moments is the 4 parameters of the model calculated by Zernike moments at 3 different orders of the image, comparing these parameters with a set threshold to accurately locate the edges of the image. Zernike moments are orthogonalized functions based on Zernike polynomials, and the set of orthogonal polynomials utilized is a complete orthogonal set in the unit circle; Zernike moments are rotationally invariant. Zernike -order polynomial is defined as where is radial distance, is azimuth and meets the following condition: ; is an integer and satisfies the condition: is an even number, i is the imaginary unit, and is given by

3. Improved Canny-Zernike Moment Subpixel Edge Detection Algorithm

When a traditional algorithm is used to calculate Zernike moments, the centroid of the picture is recognized to be the coordinate origin and the total picture is projected inside the unit circle. The improved moment method does not need to cross the entire image. Therefore, the subpixel edge detection method can improve the detection speed.

In this paper, we use a bilateral filter to replace the Gaussian filter so as to reduce noise. The output pixel numeral value is determined by the weighted combination of adjacent pixel numeral values of the bilateral filtering, so pixel-level edge localization can be obtained. The calculation formulas of bilateral filtering for input pixels are where (the input image) is the value of each pixel of the image, is the weight of the pixel center point in , which contains location-domain Gaussian function and luminance Gaussian Function .

This paper chooses a detection template and increases 45° and 135° directions on it to improve detection precision. The gradient templates are as follows:

In formula (4), , and , represent the horizontal directions, vertical directions, 45°orientation, and 135°orientation of the gradient template, respectively. After filtering, the original image, the gradient components in four directions are obtained using the plane convolution of the multidirectional Canny template. The procedure for calculating gradients is as follows:

Equation (5) is the partial derivative of the gradient template in each direction, and in formula (6), the gradients and represent the horizontal and vertical directions, respectively. The gradient weighting coefficients are represented by and , respectively. The gradients in each direction are , respectively. At last, we can get the final gradient .

Based on the above principles of pixel-level edge operators, Zernike moments are recommended, and subpixel edge detection can be achieved without traversing the full image. The models of the second-order pixel are shown in Figure 1. The unit circle is an ideal edge region, denotes step gray level, denotes background gray level, and denotes the normal case of gray level edge area. is the distance from center perpendicular to the edge, the angle is between the edge normal, and the -axis direction.

When we calculate the edge parameters , , , and , 3 moments , and need to be calculated at first; the integral kernel formulas are: , , and .

On the basis of moment definition, the parameters of step edge can be represented by , , , and . Compare the obtained parameters with the set threshold, and determine the image edges accurately. According to the rotational invariance of the Zernike moment, introduce a fully orthonormal basis by using complex polynomials. We can calculate and get the above four parameters by the following formula:

The moments are determined using convolution of the template and picture gray scale because to the discreteness. If the unit circle is sampled within the pixel area, the template effect is taken into account. Because the stencil spans pixels around the center of the stencil, the radius must be lowered by half for convolution. As a result, the predicted vertical distance must be cut in half. As a result, the pixel point’s subpixel coordinates formula is

4. Experimental and Analysis

4.1. Experimental Setup

As illustrated in Figure 2, a large-scale workpiece image acquisition hardware platform based on machine vision is created to test the increased subpixel edge localization detection accuracy. Industrial computer, high-precision vision module, high-precision three-axis motion platform, and other mechanical structures make up the system.

Select the 3C product shell workpiece as the detecting object, and locate the round hole on the workpiece. Figure 3 depicts the detection workpiece drawing. The workpiece measures 1718 mm in length and 58 mm in width and contains 39 threaded holes.

4.2. Image Preprocessing

The vision system is driven by a high-precision motion platform to collect comprehensive pictures on the super-long detection workpiece. The source image takes up a lot of storage space due to its high color dimension, which slows down image processing. Meanwhile, Gaussian and Poisson noises are easily generated in the workshop due to electromagnetic signals, light interference, and system internal operation, affecting the extraction of workpiece information in the image. When the picture is being preprocessed, the source image is grayed, filtered denoising, and thresholded in order to accurately extract the critical information of the original image and improve image processing speed.

As shown in Figure 4, the channel information of the original image with a resolution of was grayed according to weighted average. The grayscale image keeps the critical edge outline information, and the storage data is a quarter of the original image. In image processing, the running memory of the system is less, and the processing speed is faster than the original image.

In view of the requirements of 3C workpiece detection, it is necessary to remove noise in the workpiece image during the image denoising process when we measure the position and size of screw holes on the source image of the target detection workpiece in this paper, but the edge features of the workpiece image and threaded hole features cannot be filtered out. Furthermore, median filtering is an excellent image denoising method [28]. Both iterative threshold segmentation and the OTSU threshold segmentation technique preserve the form of the picture contour better, as seen in Figure 5, but the former one is time-consuming. The OTSU is faster, and the segmentation is more precise. As a result, the OTSU approach is utilized to calculate thresholds.

4.3. Result Analysis

On the basis of image preprocessing, an improved subpixel edge detection method is adopted to process local image of the target detecting workpiece. The findings are shown in Figure 6 in comparison to the traditional Canny algorithm method. The presented approach has more evident local features for the detection of edge contours (line, circle) and is more in line with the edge of the genuine detected object, as is seen in the image comparison.

To further characterize the accuracy of pixel edge localization and subpixel edge localization, take the coordinates (1331.5, 1469.5) as the starting point on the edge contour of the detecting workpiece. Pick 6 points with a 1-pixel vertical coordinate step size and an unchanging horizontal coordinate. Each point is detected and located in the two approaches, and the detection results are displayed in Table 1.

It can be seen from Table 1 that the detection accuracy of Canny edge detection just reaches pixel grade, but the positioning accuracy of improved Zernike moment subpixel edge method has greater improvement and can reach 0.1-0.3 pixels.

5. Conclusions

This research proposes an enhanced Canny-Zernike moment algorithm to improve the measurement accuracy of target detecting workpieces. This improved detection approach can detect the edge and will not traverse the entire image, thus improving subpixel edge detection speed. Bilateral filtering is more suitable for noise reduction compared with other filtering methods. The output pixel value is derived by a weighted mixture of nearby pixel values thus improving the capability of Subpixel exact placement. A hardware platform for capturing large-scale workpiece image was created. The edge is measured with the enhanced Canny-Zernike subpixel detection method with a 3C large-size workpiece as the detection object. The results show that measurement accuracy can reach 0.1-0.3 pixels, which enhances edge placement accuracy and efficiency.

Data Availability

The data used to support the findings of this study are included within the article.

Conflicts of Interest

The authors declare that they have no competing interest.

Acknowledgments

This work was supported by the Special Project on Science and Technology Cooperation-“One Belt, One Road” China-Africa Science and Technology Cooperation (20212BDH80008) and the Key R&D Program Projects of Jiangxi Province (20181BBE58006).