Yarn bobbin recognition method and system based on circular convolution kernel under complex background
By using a custom circular convolution kernel and Canny algorithm combined with a gradient descent method in complex backgrounds, the circular characteristics of the yarn barrel are identified, and the problem of low accuracy and accuracy of the yarn barrel recognition in the prior art is solved, and higher recognition accuracy and speed are achieved.
Patent Information
- Application Number
- CN202210328627.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-30
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2042-03-30
AI Technical Summary
In the complex background, the existing circle detection algorithm has problems such as large calculation volume, large memory usage, and difficult to determine the parameter quantization interval standards, resulting in low accuracy and accuracy of yarn barrel recognition.
The circle filter with a custom circular convolution kernel is used to identify the center of the image, and the circular contour is extracted in combination with the Canny algorithm, the circle is fitted using the gradient descent method, and the anti-interference ability is improved through iterative methods.
It improves the accuracy and accuracy of yarn barrel recognition, enhances the robustness of the algorithm, and accelerates the speed of yarn barrel recognition.
Smart Images

Figure CN114663457B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and in particular to a yarn tube recognition method based on a circular convolution kernel under a complex background and a yarn tube recognition system based on a circular convolution kernel under a complex background. Background Art
[0002] Currently, under existing circumstances, bobbins are generally located by detecting ellipses or circles in images. However, current circle detection algorithms, such as Hough-circle transform and traditional Hough transform, have the following defects:
[0003] (1) The one-to-many parameter mapping causes a large amount of computation;
[0004] (2) Large memory footprint;
[0005] (3) It is difficult to determine the parameter quantization interval standard.
[0006] In some complex backgrounds, there may be false detections.
[0007] In addition, the least squares method is usually used in the circle fitting process, but the robustness of this method is not good enough. The parameters of the circle will be affected by the interfering pixels, and the fitted circle will be close to the interfering pixels, resulting in errors in the center position of the circle, affecting the accuracy and precision of yarn tube recognition. Summary of the invention
[0008] In view of the above problems, the present invention provides a yarn tube recognition method and system based on a circular convolution kernel in a complex background. The circular convolution kernel is used to roughly identify the center of a circle in an image. On this basis, the Canny algorithm is used to extract the circular contour in the image, and then the gradient descent method is used to fit the circle based on the contour points. The anti-interference ability is improved through an iterative method, so that circular yarn tubes can be identified in a complex background. This method improves the accuracy and precision of yarn tube recognition, improves the robustness of the algorithm, and improves the speed of yarn tube recognition.
[0009] To achieve the above object, the present invention provides a yarn bobbin recognition method based on a circular convolution kernel under a complex background, comprising:
[0010] Obtain the image of the yarn tube area and convert the color image into a grayscale image;
[0011] Using a circular filter with a custom circular convolution kernel to identify the center of the grayscale image, and displaying the candidate center of the circle in the grayscale image after adaptive binarization and morphological processing;
[0012] Using the Canny algorithm to perform edge detection and contour extraction on the grayscale image, and screening to obtain a characteristic contour area according to the position of the candidate circle center;
[0013] Extracting contour points of the characteristic contour area, fitting a circle using a gradient descent method, and displaying the center of the fitting circle in the image;
[0014] If the distance between the center of the fitted circle and the center of the candidate circle is not within a preset threshold range, the Canny algorithm and the gradient descent method are used to iteratively fit a circle to the grayscale image;
[0015] If the distance between the fitting circle center and the candidate circle center is within a preset threshold range, the fitting circle center is used as the identification circle center, and the fitting circle is used as the contour circle of the bobbin area.
[0016] In the above technical solution, preferably, the circular filter using a custom circular convolution kernel to identify the center of the grayscale image, and the specific process of displaying the candidate center of the circle in the grayscale image after adaptive binarization and morphological processing includes:
[0017] Using a circular filter with a preset pixel diameter to perform linear spatial filtering on the grayscale image;
[0018] Using the convolution kernel in the X direction to slide the filtered grayscale image with a fixed step length to obtain a convolution image in the X direction;
[0019] Using the convolution kernel in the Y direction to slide the filtered grayscale image with a fixed step length to obtain a convolution image in the Y direction;
[0020] The convolution images in the X direction and the Y direction are superimposed with a weight of 0.5 to obtain a superimposed image;
[0021] Adaptively binarizing the superimposed image and performing a morphological opening operation;
[0022] The contour is extracted from the image after the opening operation, and the center of the contour is used as a candidate circle center, and the candidate circle center is displayed in the image.
[0023] In the above technical solution, preferably, the specific process of fitting a circle using the gradient descent method includes:
[0024] The objective function is set for the fitting process, and the objective function is:
[0025]
[0026] Among them, Xi is the horizontal coordinate of the contour point, yi is the vertical coordinate of the contour point, r is the radius of the circle, a is the horizontal coordinate of the center of the circle, b is the vertical coordinate of the center of the circle, and n is the number of contour points;
[0027] Determine whether the objective function satisfies the Lipschitz continuity condition |f(x1)-f(x2)|≤L||x1-x2|| to ensure the convergence of the objective function;
[0028] Obtaining the partial derivative of the objective function, and obtaining the gradient descent direction according to the relationship between the coordinates of the pixel point and the initial value;
[0029] Selecting an iterative step size of an update function, calculating the product of the iterative step size and the gradient descent direction as an update value, and subtracting the update value from the circle parameters in the objective function to implement the update, wherein the circle parameters include the abscissa of the circle, the ordinate of the circle and the radius of the circle;
[0030] The updated circle parameters are respectively substituted into the objective function to determine whether the objective function reaches the preset termination condition. If the preset termination condition is not reached, the iteration step size is reselected to update the circle parameters. If the preset termination condition is reached, the circle is fitted with the current circle parameters.
[0031] In the above technical solution, preferably, the iteration step size is selected in the range of 0.001 to 10.
[0032] In the above technical solution, preferably, if more than one candidate circle center is obtained after adaptive binarization and morphological processing, the threshold of the adaptive binarization algorithm is returned to be re-determined, and the image is adaptively binarized again until only one candidate circle center is obtained.
[0033] The present invention further proposes a yarn tube recognition system based on a circular convolution kernel under a complex background, which uses a yarn tube recognition method based on a circular convolution kernel under a complex background as disclosed in any one of the above technical solutions, including:
[0034] An image conversion module is used to obtain an image of the yarn tube area and convert the color image into a grayscale image;
[0035] A circle center recognition module, used to recognize the circle center of the grayscale image by using a circular filter with a custom circular convolution kernel, and to display a candidate circle center in the grayscale image through adaptive binarization and morphological processing;
[0036] A contour extraction module, used to perform edge detection and contour extraction on the grayscale image using the Canny algorithm, and to obtain a characteristic contour area based on the position of the candidate circle center;
[0037] A circle center fitting module is used to extract the contour points of the characteristic contour area, fit the circle using the gradient descent method, and display the fitting circle center in the image;
[0038] An iterative fitting module, used for iteratively fitting a circle on the grayscale image using a Canny algorithm and a gradient descent method when the distance between the fitting circle center and the candidate circle center is not within a preset threshold range;
[0039] The bobbin identification module is used to use the fitting circle center as the identification circle center and the fitting circle as the contour circle of the bobbin area when the distance between the fitting circle center and the candidate circle center is within a preset threshold range.
[0040] In the above technical solution, preferably, the circle center recognition module is specifically used for:
[0041] Using a circular filter with a preset pixel diameter to perform linear spatial filtering on the grayscale image;
[0042] Using the convolution kernel in the X direction to slide the filtered grayscale image with a fixed step length to obtain a convolution image in the X direction;
[0043] Using the convolution kernel in the Y direction to slide the filtered grayscale image with a fixed step length to obtain a convolution image in the Y direction;
[0044] The convolution images in the X direction and the Y direction are superimposed with a weight of 0.5 to obtain a superimposed image;
[0045] Adaptively binarizing the superimposed image and performing a morphological opening operation;
[0046] The contour is extracted from the image after the opening operation, and the center of the contour is used as a candidate circle center, and the candidate circle center is displayed in the image.
[0047] In the above technical solution, preferably, the circle center fitting module is specifically used for:
[0048] The objective function is set for the fitting process, and the objective function is:
[0049]
[0050] Among them, Xi is the horizontal coordinate of the contour point, yi is the vertical coordinate of the contour point, r is the radius of the circle, a is the horizontal coordinate of the center of the circle, b is the vertical coordinate of the center of the circle, and n is the number of contour points;
[0051] Determine whether the objective function satisfies the Lipschitz continuity condition |f(x1)-f(x2)|≤L||x1-x2|| to ensure the convergence of the objective function;
[0052] Obtaining the partial derivative of the objective function, and obtaining the gradient descent direction according to the relationship between the coordinates of the pixel point and the initial value;
[0053] Selecting an iterative step size of an update function, calculating the product of the iterative step size and the gradient descent direction as an update value, and subtracting the update value from the circle parameters in the objective function to implement the update, wherein the circle parameters include the abscissa of the circle, the ordinate of the circle and the radius of the circle;
[0054] The updated circle parameters are respectively substituted into the objective function to determine whether the objective function reaches the preset termination condition. If the preset termination condition is not reached, the iteration step size is reselected to update the circle parameters. If the preset termination condition is reached, the circle is fitted with the current circle parameters.
[0055] In the above technical solution, preferably, the iteration step size is selected in the range of 0.001 to 10.
[0056] In the above technical solution, preferably, if the center recognition module obtains more than one candidate center after adaptive binarization and morphological processing, it returns to redefine the threshold of the adaptive binarization algorithm and re-performs adaptive binarization on the image until only one candidate center is obtained.
[0057] Compared with the prior art, the beneficial effects of the present invention are as follows: the center of a circle in an image is roughly identified by a circular convolution kernel, and on this basis, the circular contour in the image is extracted by using the Canny algorithm, and then the circle is fitted based on the contour points by using the gradient descent method, and the anti-interference ability is improved by an iterative method, so that a circular yarn tube can be identified in a complex background. This method improves the accuracy and precision of yarn tube identification, improves the robustness of the algorithm, and improves the speed of yarn tube identification. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 A schematic diagram of a process of a yarn bobbin recognition method based on a circular convolution kernel under a complex background disclosed in an embodiment of the present invention;
[0059] Figure 2 A schematic diagram of a candidate circle center recognition process disclosed in an embodiment of the present invention;
[0060] Figure 3 A schematic diagram comparing the recognition results of the least square method and the gradient descent method disclosed in an embodiment of the present invention;
[0061] Figure 4 and Figure 5 It is a statistical diagram of the algorithm time consumption and circle fitting situation for different iteration step sizes;
[0062] Figures 6 to 9 A schematic diagram comparing the recognition results of the Hough circle detection algorithm and the gradient descent method under four image backgrounds disclosed in an embodiment of the present invention;
[0063] Fig.10 for Figures 6 to 9 A schematic diagram showing a comparison of recognition speeds disclosed in the illustrated embodiment;
[0064] Fig.11 It is a schematic diagram comparing the center position of the circle identified by the least squares method, the Hough circle detection algorithm and the gradient descent method;
[0065] Fig.12 A schematic diagram of a module of a yarn bobbin recognition system based on a circular convolution kernel under a complex background disclosed in an embodiment of the present invention.
[0066] In the figure, the corresponding relationship between each component and the reference numeral is as follows:
[0067] 11. Image conversion module, 12. Circle center recognition module, 13. Contour extraction module, 14. Circle center fitting module, 15. Iterative fitting module, 16. Yarn tube recognition module. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0069] The present invention is further described in detail below in conjunction with the accompanying drawings:
[0070] like Figure 1 As shown, according to a method for identifying a yarn tube based on a circular convolution kernel under a complex background provided by the present invention, the method comprises:
[0071] Obtain the image of the yarn tube area and convert the color image into a grayscale image;
[0072] A circular filter with a custom circular convolution kernel is used to identify the center of a circle in a grayscale image, and after adaptive binarization and morphological processing, the candidate center of a circle is displayed in the grayscale image.
[0073] The Canny algorithm is used to perform edge detection and contour extraction on the grayscale image, and the characteristic contour area is obtained by screening according to the position of the candidate circle center;
[0074] Extract the contour points of the feature contour area, use the gradient descent method to fit the circle, and display the center of the fitting circle in the image;
[0075] If the distance between the center of the fitted circle and the center of the candidate circle is not within the preset threshold range, the Canny algorithm and gradient descent method are used to iteratively fit the circle on the grayscale image;
[0076] If the distance between the fitting circle center and the candidate circle center is within a preset threshold range, the fitting circle center is used as the identification circle center, and the fitting circle is used as the contour circle of the yarn cone area.
[0077] In this embodiment, the center of a circle in an image is roughly identified by a circular convolution kernel. On this basis, the Canny algorithm is used to extract the circular contour in the image. The circle is then fitted based on the contour points using the gradient descent method. The anti-interference ability is improved through an iterative method, so that a circular yarn tube can be identified in a complex background. This method improves the accuracy and precision of yarn tube identification, improves the robustness of the algorithm, and improves the speed of yarn tube identification.
[0078] Specifically, Figure 2 As shown in the figure, before the recognition process, in order to eliminate the influence of light and different yarn colors, we first convert the color image into a grayscale image.
[0079] Preferably, two circular convolution kernels circle_x and circle_y in the X direction and the Y direction are designed according to the characteristics of the circle.
[0080] A circular filter with a preset pixel diameter is used to perform linear spatial filtering on the grayscale image.
[0081] In general, a linear spatial filtering of an image of size M×N is performed using a filter of size m×n. It can be expressed as follows: where x and y are variable, allowing the filter to access every pixel in f.
[0082]
[0083] When the filter slides to the detection area, the convolution sum is particularly large, and there will be larger pixel values at this time.
[0084] Use the convolution kernel circle_x in the X direction to slide the filtered grayscale image with a fixed step length to obtain the convolution image in the X direction;
[0085] Use the convolution kernel circle_y in the Y direction to slide the filtered grayscale image with a fixed step length to obtain the convolution image in the Y direction;
[0086] The convolution images in the X direction and the Y direction are superimposed with a weight of 0.5 to obtain a superimposed image;
[0087] The superimposed image is subjected to adaptive binarization processing. At this time, there are still some interference points in the image. In order to remove these interference points, the image is further processed using the morphological opening operation to remove the interference signal.
[0088] The contour is extracted from the image after the opening operation, and the center of the contour is used as a candidate circle center, and the candidate circle center is displayed in the image.
[0089] In the above implementation, preferably, if more than one candidate circle center is obtained after adaptive binarization and morphological processing, the threshold of the adaptive binarization algorithm is returned to be re-determined, and the image is adaptively binarized again until only one candidate circle center is obtained.
[0090] In the above implementation, in the process of fitting a circle using the gradient descent method, the direction of the next advance is determined according to the gradient direction of the current point, and the distance of a change is determined according to the step size. By repeating the above steps, a local or global optimal solution can be obtained. The distances from all pixel points on the contour to the initial center of the circle are summed and divided by the number of points. The operation principle is similar to mean filtering, which can filter out interfering pixel points far away from the circle, thereby improving anti-interference. Each iteration will change the parameter value of the circle, so that the target value is close to the optimal solution. When the value of the objective function no longer changes, it means that the optimal solution has been found, and the parameters of the circle corresponding to the optimal solution are used as the parameters of the fitted circle.
[0091] Preferably, in order to ensure that the global optimal solution can be obtained, we need to set the objective function to a convex function. The specific objective function is:
[0092]
[0093] Among them, Xi is the horizontal coordinate of the contour point, yi is the vertical coordinate of the contour point, r is the radius of the circle, a is the horizontal coordinate of the center of the circle, b is the vertical coordinate of the center of the circle, and n is the number of contour points;
[0094] Determine whether the objective function satisfies the Lipschitz continuity condition |f(x1)-f(x2)|≤L||x1-x2||;
[0095] Obtain the partial derivative of the objective function and obtain the gradient descent direction based on the relationship between the pixel coordinates and the initial value. The specific formula is:
[0096]
[0097]
[0098]
[0099] Among them, formula (1) is the partial derivative of the objective function with respect to a, formula (2) is the partial derivative of the objective function with respect to b, and formula (3) is the partial derivative of the objective function with respect to r;
[0100] The iteration step of the update function is selected, the product of the iteration step and the gradient descent direction is calculated as the update value, and the circle parameters in the objective function are respectively subtracted from the update value to achieve the update, where the circle parameters include the horizontal coordinate of the circle, the vertical coordinate of the circle and the radius of the circle.
[0101] In the update function, the size of the iteration step has a very important impact on the entire algorithm. If the iteration step is too small, it will lead to too many iterations and waste of computing power. If the iteration step is too large, it will also lead to iteration divergence. Therefore, choosing a suitable step size plays a very important role in the algorithm.
[0102] The product of the iteration step length and the gradient change direction is used as the update value, and the update value is subtracted from the horizontal coordinate a of the circle, the vertical coordinate b of the circle, and the radius r of the circle to implement the update process. Specifically, taking the horizontal coordinate a as an example, the formula of the update process is:
[0103]
[0104] Among them, α represents the iteration step size.
[0105] Substitute the updated circle parameters into the objective function to determine whether the updated objective function reaches the preset termination condition. The specific termination condition is:
[0106]
[0107] Here, ε is a preset constant close to 0.
[0108] If L(a, b, r)>ε, it is determined that the preset termination condition has not been met. At this time, the iteration step size is reselected to update the circle parameters. If L(a, b, r)≤ε, it is determined that the preset termination condition has been met. At this time, it means that the optimal solution has been obtained, indicating that the circle formed by the current circle parameters is the circle containing the most contour points, and this circle is used as the fitting circle.
[0109] The following describes the process of fitting a circle using the least squares method in the prior art:
[0110] According to the obtained coordinates of the center of the circle, the image is divided into feature intervals, and then the contour of the feature interval is recognized according to the Canny algorithm. After the contour recognition is completed, the detected contour points are stored in a two-dimensional container using the contour recognition function in opencv. However, not all contour points are valid contour points. For example, in the feature area, dirt on the surface of the yarn tube, pixels of other edge contours, etc., are all interfering pixels, which will affect the accuracy of detecting the center of the circle. The least squares method fits the pixels in the image and initially generates a circle. The equation of the circle can be expressed as:
[0111] (x) 2+(yb) 2 =r 2
[0112] The formula for the least squares method is as follows:
[0113]
[0114] Let the 3×3 matrix be A, the 3×1 matrix be B, and the circle parameter matrix be X. Assign the coordinate information of each pixel point to matrices A and B. After calculating the matrix, we can get the parameter values of the parameter matrix. The calculation formula is as follows:
[0115] x=A - ·(A T ) - ·A T ·B
[0116] According to the calculation and fitting of the least squares method mentioned above, through implementation and comparison, such as Figure 3 As shown, compared with the gradient descent method of the present invention, the robustness of the least squares method is not good enough. After the coordinates of the interfering pixel points are stored in the A matrix, the parameters of the circle solved at this time will be affected by the interfering pixel points, resulting in errors in the position of the center of the circle.
[0117] In the above implementation, preferably, the iteration step size is selected in the range of 0.001 to 10.
[0118] Specifically, in the implementation process, the selection of different iteration steps has a direct impact on the algorithm time consumption and circle fitting. When the iteration step is too small, it will lead to too many iterations, which will greatly increase the calculation time. However, if the iteration step is too large, the optimal solution may be skipped directly, causing the objective function to diverge and fail to obtain the optimal solution.
[0119] The comparison of different iteration step sizes on algorithm time consumption and circle fitting is shown in the following table:
[0120]
[0121] Through this form and Figure 4 and Figure 5 It can be seen that when the step size is greater than 10, the center position of the fitted circle gradually deviates from the center of the circle, that is, divergence occurs, which will cause fitting errors. Through analysis, when the step size is 1, the fitting speed is faster and the coordinates of the fitted circle are close, so it is preferred to take the iteration step size of 1 for iteration.
[0122] In addition, the Hough circle detection algorithm and the gradient descent method were tested during the implementation to compare the fitting speed under different background images. The comparison results are shown in the following table:
[0123]
[0124] In the above test process, the circle fitting of the Hough circle detection algorithm and the gradient descent method under different background images is also compared. The comparison results are shown in the following table:
[0125]
[0126] like Fig.10 and Fig.11 As shown in the figure, the analysis of the above test results shows that the gradient descent algorithm is used to fit the circle. The algorithm has good robustness and can fit the circle in the contour without adjusting any parameters. Compared with the traditional Hough circle detection algorithm, the fitting speed of this algorithm is increased by about 4 times, and the positioning accuracy is close to 98%. Therefore, it can meet the requirements of real-time detection of the inner circle of the yarn tube in the image in actual textile production.
[0127] like Fig.12 As shown, the present invention further proposes a yarn tube recognition system based on a circular convolution kernel under a complex background, and applies a yarn tube recognition method based on a circular convolution kernel under a complex background disclosed in any one of the above embodiments, including:
[0128] An image conversion module 11 is used to obtain a yarn tube area image and convert the color image into a grayscale image;
[0129] The circle center recognition module 12 is used to recognize the circle center of the grayscale image by using a circular filter with a custom circular convolution kernel, and to display the candidate circle center in the grayscale image through adaptive binarization and morphological processing;
[0130] The contour extraction module 13 is used to perform edge detection and contour extraction on the grayscale image using the Canny algorithm, and to obtain a characteristic contour area according to the position of the candidate circle center;
[0131] The circle center fitting module 14 is used to extract the contour points of the characteristic contour area, fit the circle using the gradient descent method, and display the fitting circle center in the image;
[0132] An iterative fitting module 15 is used to iteratively fit a circle to the grayscale image using a Canny algorithm and a gradient descent method when the distance between the center of the fitting circle and the center of the candidate circle is not within a preset threshold range;
[0133] The bobbin recognition module 16 is used to use the fitting center as the recognition center and the fitting circle as the contour circle of the bobbin area when the distance between the fitting center and the candidate center is within a preset threshold range.
[0134] In the above implementation, preferably, the circle center recognition module 12 is specifically used for:
[0135] A circular filter with a preset pixel diameter is used to perform linear spatial filtering on the grayscale image;
[0136] The filtered grayscale image is slid with a fixed step length using the convolution kernel in the X direction to obtain a convolution image in the X direction;
[0137] Use the convolution kernel in the Y direction to slide the filtered grayscale image with a fixed step length to obtain the convolution image in the Y direction;
[0138] The convolution images in the X direction and the Y direction are superimposed with a weight of 0.5 to obtain a superimposed image;
[0139] Adaptively binarize the superimposed image and perform morphological opening operation;
[0140] The contour is extracted from the image after the opening operation, and the center of the contour is used as a candidate circle center, and the candidate circle center is displayed in the image.
[0141] In the above implementation, preferably, the circle center fitting module 14 is specifically used for:
[0142] The objective function is set for the fitting process, and the objective function is:
[0143]
[0144] Among them, Xi is the horizontal coordinate of the contour point, yi is the vertical coordinate of the contour point, r is the radius of the circle, a is the horizontal coordinate of the center of the circle, b is the vertical coordinate of the center of the circle, and n is the number of contour points;
[0145] Determine whether the objective function satisfies the Lipschitz continuity condition |f(x1)-f(x2)|≤L||x1-x2|| to ensure the convergence of the objective function;
[0146] Obtain the partial derivative of the objective function and obtain the gradient descent direction based on the relationship between the pixel coordinates and the initial value;
[0147] Select the iteration step of the update function, calculate the product of the iteration step and the gradient descent direction as the update value, and subtract the update value from the circle parameters in the objective function to achieve the update, where the circle parameters include the horizontal coordinate of the circle, the vertical coordinate of the circle and the radius of the circle;
[0148] The updated circle parameters are substituted into the objective function respectively to determine whether the objective function reaches the preset termination condition. If the preset termination condition is not reached, the iteration step size is reselected to update the circle parameters. If the preset termination condition is reached, the circle is fitted with the current circle parameters.
[0149] In the above embodiment, preferably, if the circle center recognition module 12 obtains more than one candidate circle center after adaptive binarization and morphological processing, it returns to redefine the threshold of the adaptive binarization algorithm and re-performs adaptive binarization on the image until only one candidate circle center is obtained.
[0150] According to the yarn tube recognition system based on circular convolution kernel under complex background disclosed in the above-mentioned embodiment, the functions to be realized by each module thereof are respectively realized according to the steps in the yarn tube recognition method based on circular convolution kernel under complex background disclosed in the above-mentioned embodiment, with reference to the specific implementation manner of the above-mentioned yarn tube recognition method, which will not be repeated here.
[0151] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A yarn bobbin recognition method based on circular convolution kernel under complex background, characterized in that: include: Obtain the image of the yarn tube area and convert the color image into a grayscale image; Using a circular filter with a custom circular convolution kernel to identify the center of the grayscale image, and displaying the candidate center of the circle in the grayscale image after adaptive binarization and morphological processing; Using the Canny algorithm to perform edge detection and contour extraction on the grayscale image, and screening to obtain a characteristic contour area according to the position of the candidate circle center; Extracting contour points of the characteristic contour area, fitting a circle using a gradient descent method, and displaying the center of the fitting circle in the image; If the distance between the center of the fitted circle and the center of the candidate circle is not within a preset threshold range, the Canny algorithm and the gradient descent method are used to iteratively fit a circle to the grayscale image; If the distance between the fitting circle center and the candidate circle center is within a preset threshold range, the fitting circle center is used as the identification circle center, and the fitting circle is used as the contour circle of the bobbin area; The specific process of fitting a circle using the gradient descent method includes: The objective function is set for the fitting process, and the objective function is: Among them, Xi is the horizontal coordinate of the contour point, yi is the vertical coordinate of the contour point, r is the radius of the circle, a is the horizontal coordinate of the center of the circle, b is the vertical coordinate of the center of the circle, and n is the number of contour points; Determine whether the objective function satisfies the Lipschitz continuity condition |f(x1)-f(x2)|≤L||x1-x2|| to ensure the convergence of the objective function; Obtaining the partial derivative of the objective function, and obtaining the gradient descent direction according to the relationship between the coordinates of the pixel point and the initial value; Selecting an iteration step of the update function, calculating the product of the iteration step and the gradient descent direction as an update value, and subtracting the update value from the circle parameters in the objective function to implement the update, wherein the circle parameters include the abscissa of the circle, the ordinate of the circle and the radius of the circle; The updated circle parameters are respectively substituted into the objective function to determine whether the objective function reaches the preset termination condition. If the preset termination condition is not reached, the iteration step size is reselected to update the circle parameters. If the preset termination condition is reached, the circle is fitted with the current circle parameters.
2. The yarn bobbin recognition method based on circular convolution kernel under complex background according to claim 1 is characterized in that: The specific process of using the circular filter with the custom circular convolution kernel to identify the center of the grayscale image, and then performing adaptive binarization processing and morphological processing to display the candidate center of the circle in the grayscale image includes: Using a circular filter with a preset pixel diameter to perform linear spatial filtering on the grayscale image; Using the convolution kernel in the X direction to slide the filtered grayscale image with a fixed step length to obtain a convolution image in the X direction; Using the convolution kernel in the Y direction to slide the filtered grayscale image with a fixed step length to obtain a convolution image in the Y direction; The convolution images in the X direction and the Y direction are superimposed with a weight of 0.5 to obtain a superimposed image; Adaptively binarizing the superimposed image and performing a morphological opening operation; The contour is extracted from the image after the opening operation, and the center of the contour is used as a candidate circle center, and the candidate circle center is displayed in the image.
3. The yarn bobbin recognition method based on circular convolution kernel under complex background according to claim 1 is characterized in that: The selection range of the iteration step is 0.001 to 10.
4. The yarn tube recognition method based on circular convolution kernel under complex background according to claim 1 or 2, characterized in that: If more than one candidate circle center is obtained after the adaptive binarization and morphological processing, the threshold of the adaptive binarization algorithm is re-determined, and the image is adaptively binarized again until only one candidate circle center is obtained.
5. A yarn bobbin recognition system based on circular convolution kernel under complex background, characterized in that: The yarn bobbin recognition method based on a circular convolution kernel under a complex background as claimed in any one of claims 1 to 4 comprises: An image conversion module is used to obtain an image of the yarn tube area and convert the color image into a grayscale image; A circle center recognition module, used to recognize the circle center of the grayscale image by using a circular filter with a custom circular convolution kernel, and to display the candidate circle center in the grayscale image through adaptive binarization processing and morphological processing; A contour extraction module, used to perform edge detection and contour extraction on the grayscale image using the Canny algorithm, and to obtain a characteristic contour area based on the position of the candidate circle center; A circle center fitting module is used to extract the contour points of the characteristic contour area, fit the circle using the gradient descent method, and display the fitting circle center in the image; An iterative fitting module, used for iteratively fitting a circle on the grayscale image using a Canny algorithm and a gradient descent method when the distance between the fitting circle center and the candidate circle center is not within a preset threshold range; A bobbin identification module, configured to use the fitting circle center as the identification circle center and the fitting circle as the contour circle of the bobbin area when the distance between the fitting circle center and the candidate circle center is within a preset threshold range; The circle center fitting module is specifically used for: The objective function is set for the fitting process, and the objective function is: Among them, Xi is the horizontal coordinate of the contour point, yi is the vertical coordinate of the contour point, r is the radius of the circle, a is the horizontal coordinate of the center of the circle, b is the vertical coordinate of the center of the circle, and n is the number of contour points; Determine whether the objective function satisfies the Lipschitz continuity condition |f(x1)-f(x2)|≤L||x1-x2|| to ensure the convergence of the objective function; Obtaining the partial derivative of the objective function, and obtaining the gradient descent direction according to the relationship between the coordinates of the pixel point and the initial value; Selecting an iteration step of the update function, calculating the product of the iteration step and the gradient descent direction as an update value, and subtracting the update value from the circle parameters in the objective function to implement the update, wherein the circle parameters include the abscissa of the circle, the ordinate of the circle and the radius of the circle; The updated circle parameters are respectively substituted into the objective function to determine whether the objective function reaches the preset termination condition. If the preset termination condition is not reached, the iteration step size is reselected to update the circle parameters. If the preset termination condition is reached, the circle is fitted with the current circle parameters.
6. The yarn bobbin recognition system based on circular convolution kernel under complex background according to claim 5, characterized in that: The circle center recognition module is specifically used for: Using a circular filter with a preset pixel diameter to perform linear spatial filtering on the grayscale image; Using the convolution kernel in the X direction to slide the filtered grayscale image with a fixed step length to obtain a convolution image in the X direction; Using the convolution kernel in the Y direction to slide the filtered grayscale image with a fixed step length to obtain a convolution image in the Y direction; The convolution images in the X direction and the Y direction are superimposed with a weight of 0.5 to obtain a superimposed image; Adaptively binarizing the superimposed image and performing a morphological opening operation; The contour is extracted from the image after the opening operation, and the center of the contour is used as a candidate circle center, and the candidate circle center is displayed in the image.
7. The yarn bobbin recognition system based on circular convolution kernel under complex background according to claim 5, characterized in that: The selection range of the iteration step is 0.001 to 10.
8. The yarn tube recognition system based on circular convolution kernel under complex background according to claim 5 or 6, characterized in that: If the circle center recognition module obtains more than one candidate circle center after the adaptive binarization and morphological processing, it returns to re-determine the threshold of the adaptive binarization algorithm and re-adaptively binarizes the image until only one candidate circle center is obtained.
Citation Information
Patent Citations
Intelligent sorting system of caterpillar fungus and utilization method of intelligent sorting system
CN108311411A
An image recognition and positioning method for shielded round mature fruits
CN109684997A