An improved ACA-zernike moment-based edge detection method for magnetic tile

By improving the ACA-Zernike moment algorithm and combining adaptive median filtering, improved ant colony operator and Zernike moment edge detection, the problem of insufficient accuracy of traditional detection algorithms is solved, and sub-pixel level accurate measurement of magnetic tile axis length and chord length is achieved, improving detection accuracy and noise resistance.

CN118334069BActive Publication Date: 2026-03-17JIANGSU UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-13
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing methods for detecting the axial length and chord length of magnetic tiles mainly rely on manual visual inspection, which is difficult to meet modern measurement needs. Traditional edge detection algorithms only have pixel-level accuracy and cannot meet the requirements for high-precision detection.

Method used

Subpixel-level magnetic tile edge detection is performed by combining the improved ACA operator and Zernike moments. By using adaptive median filtering, improved ant colony operator and Zernike moment edge threshold selection, and least squares method to fit a straight line, accurate measurement of magnetic tile size is achieved.

Benefits of technology

It significantly improves the accuracy and noise resistance of magnetic tile detection, and achieves sub-pixel-level measurement of magnetic tile size, ensuring the accuracy and robustness of measurement results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118334069B_ABST
    Figure CN118334069B_ABST
Patent Text Reader

Abstract

This invention discloses an improved ACA-Zernike moment magnetic tile edge detection method. This method combines an improved ACA operator and Zernike moments for sub-pixel level magnetic tile edge detection. First, the ACA operator is improved by applying adaptive median filtering to obtain pixel-level images and achieve coarse localization. Based on this, the selection of the Zernike moment edge threshold is further optimized. Finally, by applying least squares fitting to a straight line, accurate measurement of the magnetic tile's axial length and chord length is achieved. This algorithm not only significantly reduces noise interference but also significantly improves detection accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to an improved ACA-Zernike rectangular magnetic tile edge detection method. Background Technology

[0002] Magnets are important materials for generating magnetic fields, commonly used in motors as excitation sources or rotor magnets to provide a stable magnetic field. The specifications of magnets affect the performance and efficiency of the motor. The shaft length and chord length of magnets are crucial for determining whether their specifications meet standards. Currently, the shaft length and chord length of magnets are mainly measured manually using calipers. In recent years, machine vision, as an important branch of artificial intelligence, simulates the functions and capabilities of the human visual system. Edge detection is also an important branch of machine vision and image processing, serving as a vital tool for achieving fast and high-precision edge localization and detection in images. In image measurement technology, traditional edge detection algorithms include the Sobel operator, Canny operator, and Laplace operator; however, these traditional edge detection algorithms only extract pixel-level precision, which is insufficient to meet modern measurement requirements. Summary of the Invention

[0003] This invention addresses the problems of existing technologies by providing an improved ACA-Zernike moment-based magnetic tile edge detection method. The method combines an improved ACA operator and Zernike moments for sub-pixel-level magnetic tile edge detection. First, the ACA operator is improved by applying adaptive median filtering to obtain pixel-level images and achieve coarse localization. Based on this, the selection of the Zernike moment edge threshold is further optimized. Finally, by applying least squares fitting to a straight line, accurate measurement of the magnetic tile's axial length and chord length is achieved. This algorithm not only significantly reduces noise interference but also significantly improves detection accuracy.

[0004] The technical solutions adopted in this invention are as follows:

[0005] An improved ACA-Zernike rectangular magnetic tile edge detection method includes the following steps:

[0006] 1) Acquire magnetic tile images f(x,y) and preprocess them, then use an improved ant colony operator to obtain pixel-level edges of the magnetic tile images;

[0007] 2) Based on the pixel-level edge coordinates obtained in step 1), the gray values ​​of the edge neighborhood pixels in the acquired original magnetic tile image f(x,y) are compared with the template coefficients M of the Zernike moment. 00 M 11 M 20 M 31 M 40Perform convolution to obtain the sub-template coefficients Z of the Zernike moments. 00 Z 11 Z 20 Z 31 Z 40 ;

[0008] 3) Obtain Zernike moments Z' of different orders through the edge step model. 00 Z' 11 Z' 20 Z' 31 Z' 40 Substitute the sub-template coefficients Z of the Zernike moments obtained in step 2) 00 Z 11 Z 20 Z 31 Z 40 The model parameters l, h, k, and θ are obtained.

[0009] 4) Use the two-dimensional Otsu algorithm to obtain the optimal judgment threshold k t Determine whether the edge pixels satisfy the edge detection condition k≥k t ∩l≤l t k t l t To determine the threshold;

[0010] 5) Based on the optimized least squares linear fitting, the sum of squares is used as a metric to replace the distance of the classical squares method to obtain the size of the magnetic tile.

[0011] Furthermore, during the image acquisition of the magnetic tile, the magnetic tile is illuminated by a dome-shaped LED light source, and an industrial camera captures and acquires the image of the magnetic tile.

[0012] Furthermore, an improved ant colony operator is used to obtain pixel-level edges of the magnetic tile image, specifically including:

[0013] 1) Ants select the next node using pheromones and heuristic functions. The transition probability formula is as follows:

[0014]

[0015] In the formula, p k (i,j) is the probability that an ant notices node j from node i, τ(i,j) is the pheromone on the path between node i and node j, η(i,j) is the heuristic function between node i and node j, usually taken as the reciprocal of the Euclidean distance between the two points, and α and β represent the importance of pheromone and heuristic function during the transition, respectively.

[0016] After the ant completes its first pathfinding according to the transition probability formula, the pheromone needs to be updated. The formula is as follows:

[0017]

[0018]

[0019] In the formula, m is the number of ants, ρ is the pheromone evaporation rate, and 0 < ρ ≤ 1 is defined; Δτ k( i,j) is the amount of pheromone released by the k-th ant on the edges it traverses, which is equal to the reciprocal of the path length constructed by ant k in this round; C k Represents the path length, which is R k The sum of the lengths of all edges in the array;

[0020] 2) Improvement through heuristics:

[0021] First, each ant is randomly distributed on an M×N two-dimensional grid. The ants move on the grid, and it is stipulated that each ant can only move one pixel in each step.

[0022] Next, the Sobel operator is selected as the heuristic information. The edges obtained using the Sobel operator will be used as the heuristic information η for the ant colony edge detection algorithm. The formula for the heuristic information of each pixel is as follows:

[0023]

[0024] 3) Pheromones Improvement:

[0025] The improved pheromone addition feature is called elite ants, and the following adaptive improvement is made to the pheromone quantity:

[0026]

[0027] After each iteration, the optimal path is given an additional amount of pheromone. The ant that finds this solution becomes the elite ant, and this optimal path is denoted as T. b For path T b Additional enhancements are provided to T b Each edge in the array increases by e / L b The size of the pheromone is obtained, where e is a parameter that defines the pheromone level given to path T. b The magnitude of the weight, L b It represents T b The length of △ is defined as:

[0028]

[0029] The value of e is improved as follows:

[0030]

[0031] Furthermore, using a 7×7 template of Zernike moments, the obtained pixel-level edge coordinates are convolved to obtain the desired Z-axis. 00 Z 11 Z 20 Z 31 Z 40 .

[0032] Further, step 3) includes: establishing an ideal edge step model, then extracting the four parameters l, k, h, and θ of the model, and mapping them to Zernike moments for calculation to obtain Zernike moments Z' of different orders. 00 Z' 11 Z' 20 Z' 31 Z' 40 At this point, Z' can be obtained. 00 Z' 11 Z' 20 Z' 31 Z' 40 The relationship between the four parameters l, k, h, and θ is then used to obtain Z. 00 Z 11 Z 20 Z 31 Z 40 Substituting these values ​​into the equations yields the specific values ​​for the four parameters l, k, h, and θ.

[0033] Furthermore, in step 5), the least squares optimization includes:

[0034] The traditional least squares method can be expressed by the following formula:

[0035] Traditional least squares method requires The value of is minimized, and the best estimate can be obtained by taking the partial derivatives of equations a and b respectively:

[0036]

[0037] To optimize the least squares method, a preliminary least squares fit is first performed on the target point set to obtain the first fitted line. Then, the sum of squares of the points to the fitted line is used as a metric to replace the straight-line distance between two points in the traditional least squares method. Assume the desired regression line is:

[0038] y i =a0x i +b0

[0039] The sum of squares function is defined as follows:

[0040]

[0041] Set a distance threshold according to the fitting accuracy requirements, determine whether point S is less than the threshold, add points that meet the screening conditions to the fitting point set for a second line fitting, and then use the points in the target point set to filter the distance between the points and the line of the newly fitted line until the distance between the points in the fitting point set and the fitted line is within the set range, and output the line fitting result.

[0042] The present invention has the following beneficial effects:

[0043] This invention enables more comprehensive measurement of magnetic tiles. It preprocesses the magnetic tiles and utilizes an improved ACA operator for pixel-level edge extraction. This process significantly enhances the operator's resistance to noise, ensuring the accuracy of the measurement results. The Zernike sub-pixel edge detection algorithm is improved, enhancing its adaptive performance and making it more suitable for magnetic tile size detection in different scenarios. An optimized least squares method is applied to fit the magnetic tile edges, using the sum of squares as a metric to replace the distance in the classic squares method, thus completing the detection of key dimensions of the magnetic tiles. Attached Figure Description

[0044] Figure 1 This is a flowchart of the present invention.

[0045] Figure 2 For the Zernike ideal edge model, Figure 2 In the image, (a) represents the edge of the original image, and (b) represents the edge of the rotated image.

[0046] Figure 3 This is a comparison of one-dimensional and two-dimensional Otsu's algorithm after adding Gaussian noise. Figure 3 In the image, (a) is the original image, (b) is a one-dimensional Otsu image, and (c) is a two-dimensional Otsu image. Detailed Implementation

[0047] The invention will now be further described with reference to the accompanying drawings.

[0048] like Figure 1 As shown, the present invention provides an improved ACA-Zernike rectangular magnetic tile edge detection method, comprising the following steps:

[0049] 1) During magnetic tile image acquisition, the magnetic tile is illuminated by a dome LED light source, and an industrial camera captures the magnetic tile image. Adaptive median filtering is used to preprocess the image for filtering and denoising.

[0050] 2) Use an improved ant colony operator to obtain pixel-level edges;

[0051] The state transition probability is the core of the ant colony algorithm. Ants select the next node using pheromones and heuristic functions. The transition probability formula is as follows:

[0052]

[0053] In the formula, p k (i,j) is the probability that an ant notices node j from node i; τ(i,j) is the pheromone on the path between nodes i and j; η(i,j) is the heuristic function between nodes i and j, usually taken as the reciprocal of the Euclidean distance between the two points. α and β represent the importance of the pheromone and heuristic function during the transition, respectively. After the ant completes the first pathfinding according to the transition probability formula, the pheromone needs to be updated, as shown in the following formula:

[0054]

[0055]

[0056] m is the number of ants; ρ is the pheromone evaporation rate, defined as 0 < ρ ≤ 1. △τ k (i,j) is the amount of pheromone released by the k-th ant on the edge it traverses, which is equal to the reciprocal of the path length constructed by ant k in this round. C k Represents the path length, which is R k The sum of the lengths of all edges in the interval.

[0057] Improvement of heuristic information:

[0058] Heuristic information is a prerequisite for ants to find edge points. Ants enhance their external perception ability by combining pheromones left in the local environment with heuristic information. First, each ant is randomly distributed on an M×N two-dimensional grid. The ants move on this grid, and it is stipulated that each ant can only move one pixel in each step.

[0059] Next, the Sobel operator is selected as the heuristic information because it provides accurate and complete edge localization and exhibits good connectivity of the detected edges. The edges obtained using the Sobel operator will serve as the heuristic information η for the ant colony edge detection algorithm. The formula for the heuristic information of each pixel is as follows:

[0060]

[0061] Pheromones improved:

[0062] The improved pheromone addition is called elite ant. This invention adopts the following adaptive improvement on pheromone quantity:

[0063]

[0064] After each iteration, the optimal path is given an additional amount of pheromone. The ant that finds this solution becomes the elite ant, and this optimal path is denoted as T. b For path T bAdditional enhancements are provided to T b Each edge in the array increases by e / L b The size of the pheromone is obtained, where e is a parameter that defines the pheromone level given to path T. b The magnitude of the weight, L b It represents T b The length of △ is defined as:

[0065]

[0066] The elite ant system enables this algorithm to converge quickly. To address the algorithm's tendency to get trapped in local optima, this invention improves the value of e as follows: In the initial iterations, to increase the algorithm's global search capability, the value of α is kept as small as possible, reducing the influence of elite ants on the algorithm. After a certain number of iterations, the value of α is gradually increased, giving elite ants a greater weight in the iteration process and preventing the algorithm from entering local optima. This invention modifies the parameter e... min Adaptive improvements are made as follows:

[0067]

[0068] 3) Take the pixel-level edge coordinates obtained in step 2), and combine the gray values ​​of the edge neighborhood pixels in the original image f(x,y) with the template coefficients M of the Zernike moments. 00 M 11 M 20 M 31 M 40 Perform convolution to obtain the sub-template coefficients Z of the Zernike moments. 00 Z 11 Z 20 Z 31 Z 40 ;

[0069] This invention uses Zernike's 7x7 template, and convolves this template with the grayscale values ​​of the edge point coordinates obtained in the previous step to obtain the Z-value needed in the next step. 00 Z 11 Z 20 Z 31 Z 40 M 00 M 11 M 20 M 31 M 40 The template content is as follows:

[0070]

[0071]

[0072]

[0073]

[0074]

[0075]

[0076] 4) Establish an ideal grayscale step model, such as Figure 3 Then, the four parameters l, k, h, and θ of the model are extracted and mapped to Zernike moments for calculation, resulting in Zernike moments Z' of different orders. 00 Z' 11 Z' 20 Z' 31 Z' 40 At this point, Z' can be obtained. 00 Z' 11 Z' 20 Z' 31 Z' 40 The relationship between the four parameters l, h, k, and θ of the edge, and then the Z obtained in step 3. 00 Z 11 Z 20 Z 31 Z 40 Substituting these values ​​into the equations yields the specific values ​​for the four parameters l, h, k, and θ.

[0077] like Figure 2 The image shows the ideal edge model of Zernike moments:

[0078] The principle of moment magnitude invariance can be used to obtain Zernike moments of different orders through a model:

[0079]

[0080] From equation (2), the four parameters l, h, k, and θ of the edge model can be obtained:

[0081]

[0082] 5) The condition for determining edge points in the Zernike algorithm is k ≥ k t ∩l≤l t , (k t l t To determine the threshold, the optimal threshold k is obtained using the two-dimensional Otsu algorithm. t Determine whether the edge pixels meet the edge judgment conditions;

[0083] The traditional Zernike algorithm determines edge points by the condition that k ≥ kt ∩l≤l t , where k t l t To determine the threshold, l t The range of values ​​for k is relatively fixed, but t The value range of k varies greatly, and since the specific values ​​of the edge parameters l and k have already been obtained in step 4, this invention focuses on k. t The method of determining the value can be improved. To address the above problem, a method based on the two-dimensional Otsu's method to obtain the optimal image threshold k is proposed. t .like Figure 3 As shown, Figure 3 In images (b) and (c), the same level of Gaussian noise (σ = 0.1) was added. Compared with the one-dimensional Otsu method, the two-dimensional Otsu method has a significantly stronger ability to remove Gaussian noise. Although some processing time is sacrificed, considering the uncertainty of factory operating conditions, the two-dimensional Otsu method is used to obtain the optimal threshold for the image.

[0084] 6) Obtain the size of the magnetic tile by fitting the optimized least squares linear curve.

[0085] This invention employs an improved least squares method to fit sub-pixel edge information to obtain continuous straight line contours. The edges of the magnetic tiles are fitted with a minimum bounding rectangle, the width and length of which are the axis and chord length of the magnetic tile. The main principle of the least squares method is to find the sub-pixel point closest to the true contour by minimizing the square of the error, thereby achieving sub-pixel-level fitting of the straight line contour.

[0086] Specifically, the least squares method can be expressed by the following formula: The algorithm for the least squares method requires... The value of is minimized, and the best estimate can be obtained by taking the partial derivatives of equations a and b respectively:

[0087]

[0088] Besides being computationally convenient, the least squares method also provides optimal parameter fitting results. However, the classical least squares method only considers the straight-line distance between two points. Therefore, this invention optimizes the least squares method. First, a preliminary least squares fitting is performed on the target point set to obtain the first fitted line. Then, the sum of the squares of the points to the fitted line is used as a metric to replace the straight-line distance between the two points in the classical least squares method.

[0089] Assume the desired regression line is:

[0090] y i =a0x i +b0

[0091] The sum of squares function is defined as follows:

[0092]

[0093] Set a distance threshold based on the required fitting accuracy, and determine if point S is less than this threshold. Add points that meet the filtering criteria to the fitting point set for a second line fitting. Then, use points from the target point set to filter the newly fitted line by point-to-line distances until all points in the fitting point set are within the set range, and output the line fitting result.

[0094] The above description is only a preferred embodiment of the present invention. It should be noted that those skilled in the art can make several improvements without departing from the principle of the present invention, and these improvements should also be considered within the scope of protection of the present invention.

Claims

1. An improved ACA-Zernike moment-based method for detecting the edge of a magnetic tile, characterized in that: Comprising the following steps: 1) Collecting the image f(x, y) of the magnetic tile and pre-processing, using the improved ant colony operator to obtain the pixel-level edge of the image of the magnetic tile; 2) Convolve the edge region pixel gray value in the collected original magnet tile image f(x, y) with the template coefficient M 00 , 11 , 20 , 31 , 40 of Zernike moment to obtain the sub-template coefficient Z 00 , 11 , 20 , 31 , 40 of Zernike moment; 3) Obtain different order Zernike moments Z through the edge step model , 00 , Z , 11 , Z , 20 , Z , 31 , Z , 40 , substitute the sub-template coefficients of Zernike moments obtained in step 2) Z 00 , Z 11 , Z 20 , Z 31 , Z 40 , to obtain model parameters l, h, k, θ; 4) Obtain the best judgment threshold kt by using two-dimensional Otsu algorithm to judge whether the edge pixel point meets the edge judgment condition k≥k t ∩l≤l t , k t , l t is the judgment threshold 5) According to the optimized least square fitting, the sum of squares is used as a measurement index to replace the distance of the classical least square method to obtain the size of the magnetic tile; Using the improved ant colony operator to obtain the pixel-level edge of the image of the magnetic tile, specifically including: 1) The ants select the next node through pheromone and heuristic function, and the transition probability formula is as follows: , In the formula, p k (i,j) represents the ant's starting point from node i. Note the nodes The probability, τ(i,j) is the node With nodes The pheromone on the path, η(i,j) is the heuristic function between node i and node j, usually taken as the reciprocal of the Euclidean distance between the two points, and α and β represent the importance of the pheromone and heuristic function during the transition, respectively; After the ants complete the first search according to the transition probability formula, the pheromone needs to be updated, and the formula is as follows: , , where m is the number of ants, p is the evaporation rate of pheromone, and 0 < p < 1 is specified; Δτ k (i,j) is the amount of pheromone released by the kth ant on the edge it passes through, which is equal to the inverse of the path length constructed by the ant k in this round; C k denotes the path length, which is the sum of the lengths of all edges in R k . 2) Heuristic information improvement: First, randomly distribute each ant on the MxN two-dimensional grid point array, and the ants move on the two-dimensional grid point array, and it is stipulated that the ants can only move one pixel point at each step, Then select the Sobel operator as the heuristic information, and the edge obtained by the Sobel operator will be used as the heuristic information η of the ant colony edge detection algorithm, and the formula of the heuristic information of the pixel point is as follows: , 3) Pheromone improvement: The improved pheromone adds an extra term called elite ant, and the following adaptive improvement is taken for the amount of pheromone: , The ants that find this solution become elite ants and the path is recorded as T b , and the additional reinforcement for path T b is achieved by increasing the pheromone on each edge of T b by e / L b , where e is a parameter that defines the magnitude of the weight given to path T b , L b represents the length of T b , and Δ is defined as: , The value of e is improved as follows: 。 2. The improved ACA-Zernike moment based method for detection of the edge of a magnet piece as claimed in claim 1, wherein: When collecting the image of the magnetic tile, the magnetic tile is irradiated by a dome LED light source, and the image of the magnetic tile is collected by an industrial camera.

3. The improved ACA-Zernike moment based magnet tile edge detection method of claim 1, wherein: Using a 7x7 template of Zernike moments, the resulting pixel-level edge coordinate scale values are convolved to obtain the desired Z 00 , Z 11 , Z 20 , Z 31 , Z 40 .

4. The improved ACA-Zernike moment based magnet tile edge detection method of claim 1, wherein: Step 3) includes: An ideal edge step model is established, and then four parameters l, k, h, θ of the model are extracted and mapped into Zernike moments for calculation to obtain Zernike moments Z of different orders , 00 , Z , 11 , Z , 20 , Z , 31 , Z , 40 , Z , 00 , Z , 11 , Z , 20 , Z , 31 , Z , 40 and the relationship expression of the four parameters l, k, h, θ, and then the obtained Z 00 , Z 11 , Z 20 , Z 31 , Z 40 are substituted to obtain specific numerical values of the four parameters l, k, h, θ.

5. The improved ACA-Zernike moment based magnet tile edge detection method of claim 1, wherein: In step 5), the least square optimization includes: The traditional least square method is represented by the following formula: The conventional least square method requires The values of a and b are obtained by taking the partial derivatives of the equation with respect to a and b, respectively. , Optimizing the least square method, first, the target point set is preliminarily fitted by the least square method, and the straight line of the first fitting is obtained, and the sum of squares of the points to the fitting straight line is used as a measurement index to replace the two-point straight line distance in the traditional least square method, and the regression straight line to be solved is assumed to be: , The square sum function is defined as follows: , According to the fitting accuracy requirement, the distance threshold is set, and it is judged whether the point S is less than the threshold, the points meeting the screening conditions are put into the fitting point set for the second time straight line fitting, and then the points in the target point set are used to screen the distance from the straight line, until the distance from the fitting point set to the fitting straight line is within the set range, and the straight line fitting result is output.