Metal bone screw defect detection method based on image processing

By acquiring, preprocessing and partitioning the screw image, the detection error problem caused by the threshold dependence in the prior art is solved, and more accurate screw defect detection is achieved.

CN119338754BActive Publication Date: 2025-08-26SUZHOU SUNAN ZIMMERED MEDICAL INSTR
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411317824.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-20
Publication Date
2025-08-26
Estimated Expiration
2044-09-20

AI Technical Summary

Technical Problem

The existing screw defect detection technology relies too much on preset thresholds, which leads to errors in the detection results, especially when there is an error in the color of the screw, and it is impossible to accurately judge the defect.

Method used

By building a screw image acquisition scene, pre-processing after the screw image is acquired, the precise image is extracted, the thread partition is divided, and the error threshold between the partition features is analyzed to determine whether the thread has defects.

Benefits of technology

It improves the accuracy and rationality of screw defect detection, reduces misjudgment caused by changes in light conditions, and enhances the effectiveness of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119338754B_ABST
    Figure CN119338754B_ABST
Patent Text Reader

Abstract

The present invention discloses a metal bone screw defect detection method based on image processing, which relates to the technical field of screw defect detection and comprises the following steps: building a screw image acquisition scene and acquiring screw images; pre-processing the acquired screw images and extracting precise screw images; dividing the threads in the precise screw images into regions to obtain thread partitions; performing defect analysis on the thread partitions to determine whether there are defects in the thread partitions. The present invention is used to solve the problem that the existing screw defect detection technology still relies too much on preset thresholds and has too much subjective influence, which leads to the problem that the screw defect detection results are prone to errors.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of screw defect detection, and in particular to a metal bone screw defect detection method based on image processing. Background Art

[0002] Screw defect detection technology refers to the use of image processing, computer vision, pattern recognition and machine learning technologies to automatically detect and analyze screw products to detect possible defects or problems. These technologies aim to improve the quality and consistency of screw products on the production line, reduce reliance on manual inspection, and improve production efficiency and product safety.

[0003] Existing screw defect detection technologies are usually based on the grayscale features of the screw surface. A preset threshold is used to determine whether the grayscale features exceed the threshold to determine whether there are defects on the screw surface. However, the threshold judgment is too dependent on the preset threshold, and the subjective influence is too large. If there is an error in the color of the screw surface, it does not affect the screw defect detection, but the threshold judgment is likely to determine it as a defective screw, resulting in errors in the screw defect detection results and a reduction in the screw yield. For example, in a patent application with publication number CN108982540A, a method, device and equipment for detecting screw appearance defects are disclosed. This solution is to judge the defects on the screw surface through the preset L channel brightness threshold of the standard screw thread. If there is an error in the screw color, it is easy to cause errors in the results of the screw surface defect detection. The existing screw defect detection technology also has the problem of being too dependent on the preset threshold and having too large a subjective influence, which leads to errors in the screw defect detection results. Summary of the Invention

[0004] The present invention aims to solve one of the technical problems in the prior art to at least a certain extent, by building a screw image acquisition scene, acquiring screw images, and then preprocessing the acquired screw images to extract precise screw images, and then numbering the image pixels in the precise screw images, and extracting the screw pixels belonging to the screws, and then dividing the screw pixels into regions to obtain thread partitions, performing defect analysis on the thread partitions, analyzing the partition characteristics of the thread partitions through defect-free screw samples, and then analyzing the error thresholds between different partition characteristics, and finally analyzing the thread partitions obtained during actual detection based on the error thresholds obtained by analysis to determine whether the screw threads have defects, so as to solve the problem that the existing screw defect detection technology still relies too much on preset thresholds and has too much subjective influence, which leads to errors in the screw defect detection results.

[0005] To achieve the above objectives, in a first aspect, the present application provides a method for detecting defects in metal bone screws based on image processing, comprising the following steps:

[0006] Build a screw image acquisition scene to collect screw images;

[0007] Preprocess the collected screw images and extract the precise screw images;

[0008] Divide the threads in the precise image of the screw into regions to obtain thread partitions;

[0009] Perform defect analysis on thread partitions to determine whether there are defects in the thread partitions.

[0010] Furthermore, a screw image acquisition scene is constructed, and the acquisition of screw images includes the following sub-steps:

[0011] Create an enclosed space;

[0012] There are four surfaces in the closed space, namely surface A, surface B, surface C and surface D, surface A is opposite to surface C, and surface B is opposite to surface D;

[0013] A point light source is provided at the geometric center, the midpoint of the top edge, and the midpoint of the bottom edge of the A surface, respectively, for illuminating the enclosed space;

[0014] The C surface is a white background wall, and the B and D surfaces have channels for conveyor belts to transport screws into and out of the enclosed space;

[0015] Collect screw images.

[0016] Furthermore, collecting the screw image includes the following sub-steps:

[0017] There is a fixing plate on the conveyor belt for fixing screws;

[0018] After the screws are fixed by the fixing plate, they are brought into the closed space by the conveyor belt;

[0019] The A surface is also provided with a high-definition camera for taking images of the screws.

[0020] Furthermore, preprocessing the acquired screw image to extract the precise screw image includes the following sub-steps:

[0021] Grayscale processing is performed on the screw image to obtain a screw grayscale image;

[0022] Perform contour extraction on the screw grayscale image to obtain the screw outline, and change the grayscale values ​​of all pixels in the screw grayscale image except the pixels within the screw outline to 255;

[0023] The processed grayscale image of the screw is marked as the precise image of the screw.

[0024] Furthermore, the threads in the precise screw image are divided into regions to obtain thread partitions, which includes the following sub-steps:

[0025] Numbering the image pixels in the precise image of the screw and extracting the screw pixels belonging to the screw;

[0026] The screw pixels are divided into regions to obtain thread partitions.

[0027] Furthermore, numbering the image pixels in the precise screw image and extracting the screw pixels belonging to the screw includes the following sub-steps:

[0028] Obtain the grayscale value of the image pixel in the precise image of the screw, named image grayscale value;

[0029] Eliminate image pixels with a grayscale value of 255 and name the remaining pixels as screw pixels;

[0030] The image composed of screw pixels is completed into a rectangle, marked as the completed image, and the blank part of the completed image is restored to the image pixel with an image grayscale value of 255;

[0031] The pixels in the completed image are named as pixels to be analyzed, and the pixels to be analyzed are numbered and named as the number to be analyzed. (n,m) Indicates that, n and m are positive integers, P (n,m) Indicates the pixel to be analyzed located at the nth column and the mth row in the completed image;

[0032] Integrate all the pixels to be analyzed whose grayscale values ​​are not 255, name them as screw pixels, and name the screw pixel numbers to be analyzed as screw pixel numbers.

[0033] Furthermore, the screw pixel points are divided into regions to obtain thread partitions, which includes the following sub-steps:

[0034] Take any screw pixel as the target, mark it as the center pixel, obtain the pixels to the left, upper left, and above the center pixel to be analyzed, and mark them as the left neighbor, upper left neighbor, and upper neighbor;

[0035] Detect whether the left neighbor, upper left neighbor, and upper neighbor are screw pixels. If none of the left neighbor, upper left neighbor, and upper neighbor are screw pixels, output the region boundary signal; otherwise, output the region internal signal.

[0036] Obtain the screw pixel points of the output area boundary signal, mark them as boundary points, and change their grayscale values ​​to 0 for annotation in the completed image;

[0037] Sort and number the boundary punctuation points from top to bottom, using the symbol S i Represents, where i is a positive integer and i is the sequence number of S;

[0038] Starting with i=1, get S i With S i+1 P (n,m) , S i P (n,m) The corresponding n and m are marked as h and q respectively, and S i+1 P (n,m) The corresponding n and m are marked as g and p respectively;

[0039] Get P (n,q) To P (n,p) The screw pixels between are marked as regional pixels; get the P of the regional pixels. (n,m) The maximum value of n is marked as k, and the minimum value of h and g is marked as f;

[0040] Set P with f≤n≤k and q≤m≤p (n,m) Integrate into a thread partition, add 1 to i and re-analyze until i=max(i)-1, and stop the analysis to obtain several thread partitions, where max(i) is the maximum value of i.

[0041] Furthermore, defect analysis is performed on the thread partition to determine whether there are defects in the thread partition, including the following sub-steps:

[0042] Conduct defect analysis on thread partitions, analyze the partition characteristics of thread partitions using defect-free screw samples, and then analyze the error thresholds between different partition characteristics;

[0043] Based on the error threshold obtained by analysis, the thread partitions obtained during actual detection are analyzed to determine whether there are defects in the screw threads.

[0044] Furthermore, defect analysis is performed on the thread partitions. The partition characteristics of the thread partitions are analyzed using defect-free screw samples. The error thresholds between different partition characteristics are then analyzed. The process includes the following sub-steps:

[0045] The thread partitions are numbered in the order from top to bottom in the completion diagram, and the symbol R t Represents, where t is a positive integer and t is the sequence number of R;

[0046] For any R t , obtain the image gray value of the screw pixel in the thread partition, named screw gray value, and calculate R t The number of different screw grayscale values ​​in , is marked as grayscale number;

[0047] A plane rectangular coordinate system is established with the screw grayscale value as the X-axis and the grayscale quantity as the Y-axis, named the partition feature coordinate system. The screw grayscale value and the corresponding grayscale quantity are entered into the partition feature coordinate system. The adjacent coordinate points in the partition feature coordinate system are connected by a smooth curve, and the resulting curve is named R t Partition characteristics;

[0048] All R t The partition feature is entered into the partition feature coordinate system, the difference between the maximum and minimum values ​​in the grayscale quantity of the same screw grayscale value is calculated, marked as the feature difference, and the maximum value in the feature difference is found and marked as the maximum difference;

[0049] A first number of screw samples are analyzed to obtain the first number of maximum differences, and a maximum value among the maximum differences is found and marked as an error threshold.

[0050] Furthermore, based on the error threshold obtained by analysis, the thread partitions obtained during actual detection are analyzed to determine whether the screw thread has defects, including the following sub-steps:

[0051] Calculate the R of the thread partition obtained during actual detection t Partition characteristics;

[0052] Taking R1 as the standard, calculate each R t The maximum difference relative to R1 is marked as t difference;

[0053] Compare the t difference with the error threshold. If the t difference is less than or equal to the error threshold, the partition is output as a non-defective signal; if the t difference is greater than the error threshold, the partition is output as a defective signal.

[0054] If there is no defect signal in all output partitions, the screw is judged to be non-defective; otherwise, the screw is judged to be defective.

[0055] Beneficial effects of the present invention: The present invention collects screw images by building a screw image collection scene, and then pre-processes the collected screw images to extract accurate screw images. Then, the image pixels in the accurate screw images are numbered, and the screw pixels belonging to the screws are extracted. The screw pixels are then divided into regions to obtain thread partitions. The advantage is that, for the screw threads, each circle of the threads is divided into regions. Under a reasonable shooting environment, the grayscale features of the thread partitions obtained by division are usually similar, which provides a judgment basis for subsequent defect judgment and improves the accuracy and rationality of screw defect detection.

[0056] The present invention performs defect analysis on thread partitions, analyzes the partition characteristics of the thread partitions using defect-free screw samples, then analyzes the error thresholds between different partition characteristics, and finally analyzes the thread partitions obtained during actual detection based on the error thresholds obtained by the analysis to determine whether the screw threads have defects. The advantage is that the partition characteristics of the thread partitions are extracted, and under the condition of uniform light distribution, the color distribution of the thread partitions on the screw surface is usually similar. The error threshold of this model of screw is obtained by analyzing the selected screw samples, thereby judging the defects of the screws, thereby improving the accuracy and effectiveness of screw defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 is a flow chart of the steps of the method of the present invention;

[0058] Figure 2 The screw image of the present invention;

[0059] Figure 3 It is an accurate image of the screw of the present invention;

[0060] Figure 4 is the complementary image of the present invention;

[0061] Figure 5 A schematic diagram of the boundary punctuation of the present invention;

[0062] Figure 6 A schematic diagram of the thread partitioning of the present invention;

[0063] Figure 7 A schematic diagram of the partitioning features of the present invention;

[0064] Figure 8 Schematic diagram of the partition feature coordinate system of the present invention;

[0065] Figure 9 Schematic diagram of the structure of the electronic device of the present invention. DETAILED DESCRIPTION

[0066] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only 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 making creative efforts are within the scope of protection of the present invention.

[0067] Example 1, please refer to Figure 1 As shown, the present application provides a metal bone screw defect detection method based on image processing, comprising the following steps:

[0068] Step S1: Building a screw image acquisition scene to acquire screw images. Step S1 includes the following sub-steps:

[0069] Step S101: establishing a closed space, requiring that external light cannot enter the closed space;

[0070] Step S102: There are four surfaces around the closed space, named surface A, surface B, surface C, and surface D, surface A is opposite to surface C, and surface B is opposite to surface D;

[0071] Step S103: a point light source is provided at the geometric center, the midpoint of the top edge, and the midpoint of the bottom edge of surface A, respectively, to illuminate the enclosed space;

[0072] Step S104: Surface C is a white background wall, and surfaces B and D have passages for conveyor belts to transport screws into and out of the enclosed space;

[0073] In specific implementation, the closed space is set up to place the screws in a uniform shooting environment to prevent changes in lighting conditions from affecting the color of the screw surface, thereby affecting the detection results of screw defects;

[0074] Step S105, collecting screw images;

[0075] Step S105 includes the following sub-steps:

[0076] Step S1051: There is a fixing plate on the conveyor belt for fixing screws;

[0077] Step S1052: After the fixing plate fixes the screws, the screws are brought into the closed space by a conveyor belt;

[0078] See also Figure 2 As shown, in step S1053, a high-definition camera is also provided on surface A for capturing images of the screws;

[0079] In a specific implementation, a small hole is provided in the fixing plate, and the diameter of the small hole can be adjusted according to the specifications of the screw. After the screw is placed in the small hole, the nut is clamped by the small hole to achieve the fixation of the screw, and the small hole can drive the screw to rotate to photograph the threads of different surfaces of the screw. The focus of this embodiment is on the detection of surface defects of the screw thread. The detection of the nut can adopt existing technology. The image of the screw taken in this embodiment is as follows: Figure 2 shown.

[0080] Step S2, preprocessing the acquired screw image to extract a precise screw image; Step S2 includes the following sub-steps:

[0081] Step S201, grayscale processing is performed on the screw image to obtain a screw grayscale image;

[0082] Step S202: performing contour extraction on the screw grayscale image to obtain the screw outline, and changing the grayscale values ​​of all pixels in the screw grayscale image except the pixels within the screw outline to 255;

[0083] See also Figure 3 As shown, in step S203, the processed screw grayscale image is marked as a screw precise image;

[0084] In the specific implementation, the fixing plate should be removed when extracting the screw contour. The fixing plate appears as a rectangle in the screw image. That is, the grayscale values ​​of the rectangles in the screw image are all changed to 255. The accurate image of the screw is obtained as shown in the following figure. Figure 3 shown.

[0085] Step S3, dividing the threads in the precise image of the screw into regions to obtain thread partitions; Step S3 includes the following sub-steps:

[0086] Step S301, numbering the image pixels in the precise screw image and extracting the screw pixels belonging to the screw;

[0087] Step S301 includes the following sub-steps:

[0088] Step S3011, obtaining the grayscale value of the image pixel in the precise image of the screw, which is named as the image grayscale value;

[0089] Step S3012: remove image pixels with a grayscale value of 255, and name the remaining pixels as screw pixels;

[0090] See also Figure 4 As shown, in step S3013, the image composed of the screw pixels is completed into a rectangle, marked as the completed image, and the blank part in the completed image is restored to the image pixel with an image gray value of 255;

[0091] Step S3014: Name the pixels in the completed image as pixels to be analyzed, number the pixels to be analyzed, and name them as numbers to be analyzed. (n,m) Indicates that, n and m are positive integers, P (n,m) Indicates the pixel to be analyzed located at the nth column and the mth row in the completed image;

[0092] Step S3015: Integrate all pixels to be analyzed whose grayscale values ​​are not 255, name them as screw pixels, and name the screw pixel numbers to be analyzed as screw pixel numbers;

[0093] In the specific implementation, the purpose of step S3011 to step S3013 is to narrow the scope of image processing so that only a small area to which the screw image belongs needs to be considered, which greatly reduces the number of pixels in the image and can greatly improve the speed of image processing. The completed image is as follows: Figure 4 As shown; Figure 4 Pixels that are not pure white are screw pixels;

[0094] Step S302, dividing the screw pixels into regions to obtain thread partitions;

[0095] Step S302 includes the following sub-steps:

[0096] Step S3021: Taking any screw pixel as the target, marking it as the center pixel, obtaining the pixels to be analyzed to the left, upper left, and above the center pixel, and marking them as the left neighbor, upper left neighbor, and upper neighbor;

[0097] Step S3022: Detect whether the left neighbor, the upper left neighbor, and the upper neighbor are screw pixels. If none of the left neighbor, the upper left neighbor, and the upper neighbor are screw pixels, output a region boundary signal; otherwise, output a region internal signal.

[0098] Step S3023: Obtain the screw pixel points of the output area boundary signal, mark them as boundary points, and change their grayscale values ​​to 0 for annotation in the completed image;

[0099] In a specific implementation, the thread is protruding. For any viewing angle, the area can be demarcated by the thread, that is, the area between two threads is a thread partition. The boundary of the thread partition can be found by searching the boundary of the thread, and the thread partition is divided based on the two boundaries. If the left neighboring point, the left upper neighboring point, and the upper neighboring point are not screw pixels, it means that the center pixel point is at the edge of the thread. In this embodiment, the boundary points obtained include P (1,7) 、P (2,22) 、P (2,37) 、P (2,52) 、P (2,67) 、P (2,82) 、P (2,97) 、P (2,112) 、P (2,127) 、P (2,142) 、P (2,157) 、P (2,172) and P (4,187) If the boundary of the thread is inclined, there may be a situation where multiple boundary points are identified on the same thread, but in such cases the boundary points are continuous and adjacent. Assuming P (4,3) 、P (3,4) and P (2,5)They are all boundary punctuation points. They show an inclined trend from the lower left to the upper right, but they are continuously adjacent to each other in an oblique direction. They can be integrated. Usually, the boundary of the thread is vertical. If this happens, it means that there is a fracture on the edge of the thread. Then the actual boundary punctuation point of the thread is P. (4,3) 、P (3,4) and P (2,5) When they are completed into a rectangle, find the vertices of P (4,3) 、P (3,4) and P (2,5) The minimum value of n and the minimum value of m are 2 and 3 respectively. (2,3) As the actual boundary punctuation, the detected P (4,3) 、P (3,4) and P (2,5) It is not treated as a boundary punctuation mark;

[0100] See also Figure 5 As shown, in step S3024, the boundary punctuation marks are sorted and numbered in order from top to bottom, and the symbol S is used. i Represents, where i is a positive integer and i is the sequence number of S;

[0101] Step S3025, starting with i=1, obtain S i With S i+1 P (n,m) , S i P (n,m) The corresponding n and m are marked as h and q respectively, and S i+1 P (n,m) The corresponding n and m are marked as g and p respectively;

[0102] Step S3026, obtain P (n,q) To P (n,p) The screw pixels between are marked as regional pixels; get the P of the regional pixels. (n,m) The maximum value of n is marked as k, and the minimum value of h and g is marked as f;

[0103] Step S3027: P with f≤n≤k and q≤m≤p (n,m) Integrate into a thread partition, increase i by 1 and reanalyze until i=max(i)-1, and stop the analysis to obtain several thread partitions, where max(i) is the maximum value of i;

[0104] In the specific implementation, the order of boundary punctuation is as follows: Figure 5 As shown, taking S1 as an example, obtain the P of S1 and S2 (n,m) , where S1's P (n,m) P (1,7) , at this time h=1, q=7, P of S2 (n,m) P(2,22) At this time, g = 2 and p = 22; the process of finding k is to determine the right boundary of the thread partition. When k = 33 is found, since h < g, then f = h = 1. The P where 1 ≤ n ≤ 33 and 7 ≤ m ≤ 22 (n,m) is integrated into a thread partition; and so on until all of S i is completely analyzed.

[0105] Step S4: Conduct defect analysis on the thread partition to determine whether there are defects in the thread partition; Step S4 includes the following sub-steps:

[0106] Step S401: Conduct defect analysis on the thread partition, analyze the partition characteristics of the thread partition through screw samples without defects, and then analyze the error thresholds between different partition characteristics;

[0107] Step S401 includes the following sub-steps:

[0108] Please refer to Figure 6 As shown, in Step S4011, number the thread partitions in the order from top to bottom in the completed drawing, represented by the symbol R t , where t is a positive integer and t is the serial number of R;

[0109] Step S4012: For any R t , obtain the image gray value of the screw pixel points in the thread partition, name it the screw gray value, and count the number of different screw gray values in R t , marked as the gray number;

[0110] In a specific implementation, 12 thread partitions are obtained. As Figure 6 shown, Figure 6 in the left column from top to bottom are R1 to R6 in sequence, and in the left column from top to bottom are R7 to R 12 . Taking R2 as an example, in R2, the pixel points with a gray value of 255 are not screw pixel points, so they are not included in the statistical range. In R2, the screw gray values include several screw gray values such as 137, 146, 158, 89, and 96. Taking the screw gray value of 137 as an example, there are 16 screw pixel points with a screw gray value of 137 in the thread partition of R2, that is, the gray number of the screw gray value of 137 is 16. And so on, count the gray numbers of different screw gray values;

[0111] Please refer to Figure 7 shown, in Step S4013, establish a plane rectangular coordinate system with the screw gray value as the X-axis and the gray number as the Y-axis, named the partition characteristic coordinate system. Enter the screw gray value and the corresponding gray number into the partition characteristic coordinate system, connect the adjacent coordinate points in the partition characteristic coordinate system through a smooth curve, and name the obtained curve R tPartition characteristics;

[0112] See also Figure 8 As shown, in step S4014, all R t The partition feature is entered into the partition feature coordinate system, the difference between the maximum and minimum values ​​in the grayscale quantity of the same screw grayscale value is calculated, marked as the feature difference, and the maximum value in the feature difference is found and marked as the maximum difference;

[0113] Step S4015: Analyze the first number of screw samples to obtain the first number of maximum differences, find the maximum value among the maximum differences, and mark it as the error threshold;

[0114] In the specific implementation, the partition feature coordinate system of R2 is constructed as follows Figure 7 As shown, the curve is the R2 partition feature. Similarly, the R1 to R 12 Partition characteristics; all R t Partition feature entry partition feature coordinate system such as Figure 8 As shown, Figure 8 There are 12 partition features in total. Taking the grayscale value of a screw as 137 as an example, the maximum value is 17 and the minimum value is 15. The calculated feature difference is 2. The feature difference of each screw grayscale value is calculated, and the maximum value between them is found. The maximum difference is 7. The first number is set to 200. The first number is set to avoid the occurrence of accidental events. The screw manufacturer can manually screen the first number of screws without defects in the early stage of production and enter the features, so as to analyze and obtain the error threshold corresponding to the screw model. In this embodiment, the error threshold is calculated and found to be 8.

[0115] Step S402: Analyze the thread partitions obtained during actual detection based on the error threshold obtained through analysis to determine whether the screw threads have defects.

[0116] Step S402 includes the following sub-steps:

[0117] Step S4021, calculate the R of the thread partition obtained during actual detection t Partition characteristics;

[0118] Step S4022, taking R1 as the standard, calculate each R t The maximum difference relative to R1 is marked as t difference;

[0119] Step S4023, comparing the t difference with the error threshold. If the t difference is less than or equal to the error threshold, a partition-free signal is output; if the t difference is greater than the error threshold, a partition-defective signal is output.

[0120] Step S4024: If all output partitions have no defect signals, the screw is determined to be non-defective; otherwise, the screw is determined to be defective;

[0121] In the specific implementation, since R1 is the connection part between the nut and the thread, it is usually the most different from other thread partitions. Calculating the t difference based on R1 can reduce the amount of calculation. 11 t differences are calculated, which are 8, 3, 7, 7, 6, 4, 5, 4, 6, 6 and 16 respectively. R is obtained by comparison. 12 If the t difference is greater than the error threshold, the partition is output with a defect signal; if the other t differences are less than or equal to the error threshold, the partition is output with a non-defect signal; if there is an output defect signal, the screw is judged to be defective, and in fact there is indeed a defect at the screw tip, so the judgment result is accurate.

[0122] Example 2, please refer to Figure 9 As shown, Figure 9 The present invention illustrates a schematic diagram of the structure of an electronic device, which may include: a processor, a communication interface, a memory, and a communication bus. The processor, the communication interface, and the memory communicate with each other via the communication bus. The memory stores computer-readable instructions, and the processor can call the instructions from the memory. When the computer-readable instructions are executed by the processor, the processor executes the steps of a metal bone screw defect detection method based on image processing to achieve the following functions: establishing a screw image acquisition scene and acquiring screw images; preprocessing the acquired screw images to extract precise screw images; dividing the threads in the precise screw images into regions to obtain thread partitions; and performing defect analysis on the thread partitions to determine whether any defects exist in the thread partitions.

[0123] In addition, the logical instructions in the above-mentioned memory can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present application, or the part that contributes to the existing technology, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program code.

[0124] Example 3. The present application also provides a computer program product, which includes a computer program stored on a computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the metal bone screw defect detection method based on image processing provided by the above methods. The method includes: building a screw image acquisition scene and acquiring screw images; preprocessing the acquired screw images and extracting precise screw images; dividing the threads in the precise screw images into regions to obtain thread partitions; performing defect analysis on the thread partitions to determine whether there are defects in the thread partitions.

[0125] Example 4. The present application also provides a computer-readable storage medium. The present application provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the metal bone screw defect detection method based on image processing are executed to achieve the following functions: building a screw image acquisition scene and acquiring screw images; preprocessing the acquired screw images and extracting precise screw images; dividing the threads in the precise screw images into regions to obtain thread partitions; performing defect analysis on the thread partitions to determine whether there are defects in the thread partitions.

[0126] Through the description of the above embodiments, the embodiments of the present invention can be provided as methods, systems, or computer program products. Based on this understanding, the essence of the above technical solutions or the portion that contributes to the prior art can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for enabling a computer device (such as a personal computer, server, or network device) to execute the methods described in various embodiments or certain portions of the embodiments.

[0127] In the embodiments provided in this application, it should be understood that the disclosed system or method can be implemented in other ways. The embodiments described above are merely illustrative. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of systems, modules and units can be electrical, mechanical or other forms.

[0128] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A metal bone screw defect detection method based on image processing, characterized in that: The steps include: Build a screw image acquisition scene to collect screw images; Preprocess the collected screw images and extract the precise screw images; Divide the threads in the precise image of the screw into regions to obtain thread partitions; Perform defect analysis on thread partitions to determine whether there are defects in the thread partitions; The thread partitioning in the precise screw image is performed to obtain the thread partitioning, which includes the following sub-steps: Numbering the image pixels in the precise image of the screw and extracting the screw pixels belonging to the screw; Divide the screw pixels into regions to obtain thread partitions; Numbering the image pixels in the precise screw image and extracting the screw pixels belonging to the screw includes the following sub-steps: Obtain the grayscale value of the image pixel in the precise image of the screw, named image grayscale value; Eliminate image pixels with a grayscale value of 255 and name the remaining pixels as screw pixels; The image composed of screw pixels is completed into a rectangle, marked as the completed image, and the blank part of the completed image is restored to the image pixel with an image grayscale value of 255; The pixels in the completed image are named as pixels to be analyzed, and the pixels to be analyzed are numbered and named as the number to be analyzed. (n,m) Indicates that, n and m are positive integers, P (n,m) Indicates the pixel to be analyzed located at the nth column and the mth row in the completed image; Integrate all pixels to be analyzed whose grayscale values ​​are not 255, name them as screw pixels, and name the screw pixel numbers to be analyzed as screw pixel numbers; The following sub-steps are involved in dividing the screw pixels into regions and obtaining thread partitions: Take any screw pixel as the target, mark it as the center pixel, obtain the pixels to the left, upper left, and above the center pixel to be analyzed, and mark them as the left neighbor, upper left neighbor, and upper neighbor; Detect whether the left neighbor, upper left neighbor, and upper neighbor are screw pixels. If none of the left neighbor, upper left neighbor, and upper neighbor are screw pixels, output the region boundary signal; otherwise, output the region internal signal. Obtain the screw pixel points of the output area boundary signal, mark them as boundary points, and change their grayscale values ​​to 0 for annotation in the completed image; Sort and number the boundary punctuation points from top to bottom, using the symbol S i Represents, where i is a positive integer and i is the sequence number of S; Starting with i=1, get S i With S i+1 P (n,m) , S i P (n,m) The corresponding n and m are marked as h and q respectively, and S i+1 P (n,m) The corresponding n and m are marked as g and p respectively; Get P (n,q) To P (n,p) The screw pixels between are marked as regional pixels; get the P of the regional pixels. (n,m) The maximum value of n is marked as k, and the minimum value of h and g is marked as f; Set P with f≤n≤k and q≤m≤p (n,m) Integrate into a thread partition, add 1 to i and re-analyze until i=max(i)-1, and stop the analysis to obtain several thread partitions, where max(i) is the maximum value of i.

2. The metal bone screw defect detection method based on image processing according to claim 1, characterized in that: Building a screw image acquisition scene. Capturing screw images includes the following sub-steps: Create an enclosed space; There are four surfaces in the closed space, namely surface A, surface B, surface C and surface D, surface A is opposite to surface C, and surface B is opposite to surface D; A point light source is provided at the geometric center, the midpoint of the top edge, and the midpoint of the bottom edge of the A surface, respectively, for illuminating the enclosed space; The C surface is a white background wall, and the B and D surfaces have channels for conveyor belts to transport screws into and out of the enclosed space; Collect screw images.

3. The metal bone screw defect detection method based on image processing according to claim 2, characterized in that: The acquisition of screw images includes the following sub-steps: There is a fixing plate on the conveyor belt for fixing screws; After the screws are fixed by the fixing plate, they are brought into the closed space by the conveyor belt; The A surface is also provided with a high-definition camera for taking images of the screws.

4. The metal bone screw defect detection method based on image processing according to claim 3, characterized in that: Preprocessing the acquired screw image to extract the precise screw image includes the following sub-steps: Grayscale processing is performed on the screw image to obtain a screw grayscale image; Perform contour extraction on the screw grayscale image to obtain the screw outline, and change the grayscale values ​​of all pixels in the screw grayscale image except the pixels within the screw outline to 255; The processed grayscale image of the screw is marked as the precise image of the screw.

5. The metal bone screw defect detection method based on image processing according to claim 4, characterized in that: Performing defect analysis on thread partitions to determine whether there are defects in the thread partitions includes the following sub-steps: Conduct defect analysis on thread partitions, analyze the partition characteristics of thread partitions using defect-free screw samples, and then analyze the error thresholds between different partition characteristics; Based on the error threshold obtained by analysis, the thread partitions obtained during actual detection are analyzed to determine whether there are defects in the screw threads.

6. The metal bone screw defect detection method based on image processing according to claim 5, characterized in that: Defect analysis of thread partitions involves analyzing the partition characteristics of thread partitions using defect-free screw samples, and then analyzing the error thresholds between different partition characteristics. This process includes the following sub-steps: The thread partitions are numbered in the order from top to bottom in the completion diagram, and the symbol R t Represents, where t is a positive integer and t is the sequence number of R; For any R t , obtain the image gray value of the screw pixel in the thread partition, named screw gray value, and calculate R t The number of different screw grayscale values ​​in , is marked as grayscale number; A plane rectangular coordinate system is established with the screw grayscale value as the X-axis and the grayscale quantity as the Y-axis, named the partition feature coordinate system. The screw grayscale value and the corresponding grayscale quantity are entered into the partition feature coordinate system. The adjacent coordinate points in the partition feature coordinate system are connected by a smooth curve, and the resulting curve is named R t Partition characteristics; All R t The partition feature is entered into the partition feature coordinate system, the difference between the maximum and minimum values ​​in the grayscale quantity of the same screw grayscale value is calculated, marked as the feature difference, and the maximum value in the feature difference is found and marked as the maximum difference; A first number of screw samples are analyzed to obtain the first number of maximum differences, and a maximum value among the maximum differences is found and marked as an error threshold.

7. The method for detecting defects in metal bone screws based on image processing according to claim 6, characterized in that: Based on the error threshold obtained by analysis, the thread partitions obtained during actual inspection are analyzed to determine whether the screw threads have defects, including the following sub-steps: Calculate the R of the thread partition obtained during actual detection t Partition characteristics; Taking R1 as the standard, calculate each R t The maximum difference relative to R1 is marked as t difference; Compare the t difference with the error threshold. If the t difference is less than or equal to the error threshold, a partition-free signal is output. If the t difference is greater than the error threshold, the output partition has a defect signal; If there is no defect signal in all output partitions, the screw is judged to be non-defective; otherwise, the screw is judged to be defective.

Citation Information

Patent Citations

  • Method, device and equipment for detecting appearance blemish of screw

    CN108982540A

  • Deformed steel bar surface defect detection method and system based on machine vision

    CN110223296A

  • Defect detection method and device for threaded connector, electronic equipment and storage medium

    CN112164025A