Metal bone screw defect detection method based on image processing
By collecting and preprocessing screw images, dividing thread partitions, and analyzing partition characteristics and error thresholds, the problem of detection errors caused by reliance on thresholds in the existing technology is solved, and more accurate and reliable screw defect detection is achieved.
Patent Information
- Application Number
- CN202411317824.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-20
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2044-09-20
Smart Images

Figure CN119338754A_ABST
Abstract
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 defect detection of the screw, but it is easy to be judged as a defective screw by the threshold judgment, thereby causing errors in the defect detection results of the screw and reducing the yield of the screw. For example, in a patent application with publication number CN108982540A, a method, device and equipment for detecting screw appearance defects are disclosed. The scheme is to judge the defects on the screw surface by the preset L channel brightness threshold of the standard screw thread. If there is an error in the color of the screw, 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 defect detection results of the screw. 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, then numbering the image pixels in the precise screw image, 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 the 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, resulting in errors in the defect detection results of the screws.
[0005] To achieve the above objectives, in a first aspect, the present application provides a metal bone screw defect detection method based on image processing, comprising the following steps: Build a screw image acquisition scene to collect screw images; Preprocessing the acquired screw image to extract the precise screw image; 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 thread partitions.
[0006] Furthermore, a screw image acquisition scene is constructed, and the acquisition of screw images includes the following sub-steps: Create an enclosed space; There are four surfaces in the closed space, which are named surface A, surface B, surface C and surface D respectively. 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 of the A surface, the midpoint of the top edge, and the midpoint of the bottom edge, respectively, for illuminating the enclosed space; The C surface is a white background wall, and the B and D surfaces have passages for conveyor belts to transport screws into and out of the closed space; The screw images are collected.
[0007] Furthermore, collecting the screw image 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.
[0008] Furthermore, preprocessing the acquired screw image to extract the precise screw image includes the following sub-steps: Grayscale 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.
[0009] Furthermore, the threads in the precise image of the screw are divided into regions to obtain thread partitions, 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; The screw pixels are divided into regions to obtain thread partitions.
[0010] Furthermore, numbering the image pixels in the precise image of the screw 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, which is named as the image grayscale value; Eliminate the 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 in the completed image is restored to the image pixel with an image gray 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 in the nth column and the mth row in the completed image; 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.
[0011] Furthermore, the screw pixel points are divided into regions to obtain thread partitions, which includes the following sub-steps: Take any screw pixel as the target, mark it as the central pixel, obtain the pixels to be analyzed to the left, upper left, and above the central pixel, and mark them as the left neighbor, upper left neighbor, and upper neighbor; Detect whether the left neighbor point, the upper left neighbor point and the upper neighbor point are screw pixels. If the left neighbor point, the upper left neighbor point and the upper neighbor point are not screw pixels, output the region boundary signal; otherwise, output the region internal signal; Get 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; The boundary punctuation points are numbered 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, 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.
[0012] Furthermore, defect analysis is performed on the thread partition to determine whether there are defects in the thread partition, including the following sub-steps: Conduct defect analysis on thread partitions, analyze the partition characteristics of thread partitions through 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.
[0013] Furthermore, defect analysis is performed on the thread partitions, the partition characteristics of the thread partitions are analyzed by using defect-free screw samples, and then the error thresholds between different partition characteristics are analyzed, including 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 serial 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 gray values in , marked as gray number; A plane rectangular coordinate system is established with the screw gray value as the X-axis and the gray quantity as the Y-axis, named the partition feature coordinate system. The screw gray value and the corresponding gray 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 Zoning characteristics; All R t The partition feature is entered into the partition feature coordinate system, the difference between the maximum value and the minimum value 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, marked as the maximum difference; The first number of screw samples are analyzed to obtain the first number of maximum differences, and the maximum value among the maximum differences is found and marked as the error threshold.
[0014] Furthermore, based on the error threshold obtained by analysis, the thread partition obtained during actual detection is analyzed to determine whether the thread of the screw has defects, including the following sub-steps: Calculate the R of the thread partition obtained during actual detection t Zoning 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, the output partition has no defect signal; 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 free of defects; otherwise, the screw is judged to be defective.
[0015] 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, and then numbers the image pixels in the accurate screw images, and extracts the screw pixels belonging to the screws, and then divides the screw pixels into regions to obtain thread partitions. The advantage is that, for the threads of the screws, 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. The present invention performs defect analysis on thread partitions, analyzes the partition characteristics of thread partitions through 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 threshold obtained by analysis to determine whether the screw threads have defects. The present invention has the advantage that the partition characteristics of the thread partitions are extracted, and when the light distribution is uniform, the color distribution presented by the thread partitions on the surface of the screw is usually similar. The error threshold of this model of screws is obtained by analyzing the selected screw samples, thereby determining the defects of the screws, thereby improving the accuracy and effectiveness of screw defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 is a flow chart of the steps of the method of the present invention; Figure 2 The screw image of the present invention; Figure 3 It is an accurate image of the screw of the present invention; Figure 4 is the complementary image of the present invention; Figure 5 A schematic diagram of the boundary punctuation of the present invention; Figure 6 It is a schematic diagram of the thread partition of the present invention; Figure 7 A schematic diagram of the partition characteristics of the present invention; Figure 8 It is a schematic diagram of the partition feature coordinate system of the present invention; Fig. 9 It is a schematic structural diagram of the electronic device of the present invention. DETAILED DESCRIPTION
[0017] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. 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 creative work are within the scope of protection of the present invention.
[0018] 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: Step S1, building a screw image acquisition scene to acquire screw images; Step S1 includes the following sub-steps: Step S101, establishing a closed space, requiring that external light cannot enter the closed space; Step S102, there are four surfaces around the closed space, which are named surface A, surface B, surface C and surface D respectively, surface A is opposite to surface C, and surface B is opposite to surface D; Step S103, a point light source is provided at the geometric center of surface A, the midpoint of the top edge, and the midpoint of the bottom edge, respectively, to illuminate the enclosed space; 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 closed space; In the specific implementation, the closed space is set 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; Step S105, collecting screw images; Step S105 includes the following sub-steps: Step S1051, there is a fixing plate on the conveyor belt for fixing screws; Step S1052, after the fixing plate fixes the screws, the screws are brought into the closed space by the conveyor belt; See also Figure 2 As shown, in step S1053, a high-definition camera is also provided on the A surface for taking images of the screws; 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 specification of the screw. After the screw is placed in the small hole, the nut is clamped by the small hole to fix 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 to detect the surface defects of the screw threads, and the detection of the nut can adopt the existing technology. The image of the screw taken in this embodiment is as follows: Figure 2 shown.
[0019] Step S2, preprocessing the acquired screw image to extract the precise screw image; Step S2 includes the following sub-steps: Step S201, grayscale processing is performed on the screw image to obtain a screw grayscale image; Step S202, performing contour extraction on the screw grayscale image to obtain the screw contour, and changing the grayscale values of all pixels in the screw grayscale image except the pixels within the screw contour to 255; See also Figure 3 As shown, in step S203, the grayscale image of the screw after processing is marked as a precise image of the screw; 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 figure. Figure 3 shown.
[0020] 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: Step S301, numbering the image pixels in the precise image of the screw, and extracting the screw pixels belonging to the screw; Step S301 includes the following sub-steps: 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; Step S3012, removing image pixels with an image grayscale value of 255, and naming the remaining pixels as screw pixels; See also Figure 4 As shown, in step S3013, the image composed of the screw pixels is completed into a rectangle, marked as a completed image, and the blank part in the completed image is restored to an image pixel with an image gray value of 255; Step S3014: Name the pixels in the completed image as pixels to be analyzed, number the pixels to be analyzed, name them as to-be-analyzed numbers, and use the symbol P (n,m) Indicates that n and m are positive integers, P (n,m) Indicates the pixel to be analyzed located in the nth column and the mth row in the completed image; Step S3015, integrating all the pixels to be analyzed whose grayscale values are not 255, naming them as screw pixels, and naming the screw pixel numbers to be analyzed as screw pixel numbers; In the specific implementation, the purpose of steps S3011 to 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 processed as follows: Figure 4As shown; Figure 4 The pixels that are not pure white are screw pixels; Step S302, dividing the screw pixel points into regions to obtain thread partitions; Step S302 includes the following sub-steps: Step S3021, taking any screw pixel as the target, marking it as the central pixel, obtaining the pixels to be analyzed to the left, upper left, and above the central pixel, and marking them as the left neighboring point, upper left neighboring point, and upper neighboring point; Step S3022, detecting whether the left neighbor point, the upper left neighbor point and the upper neighbor point are screw pixels, if the left neighbor point, the upper left neighbor point and the upper neighbor point are not screw pixels, outputting a region boundary signal; otherwise, outputting a region internal signal; Step S3023, obtaining the screw pixel points of the output area boundary signal, marking them as boundary points, and changing their grayscale values to 0 for marking in the completed image; 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, and the boundary of the thread partition can be found by finding the boundary of the thread, and the thread partition is divided with the two boundaries as the range; if the left neighbor point, the left upper neighbor point and the upper neighbor point are not screw pixels, it means that the center pixel point is at the edge of the thread. In this embodiment, the boundary punctuation 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 this case the boundary points are continuous and adjacent. Assume that 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 diagonally continuous and adjacent, so they can be integrated. Usually, the boundary of the thread is vertical. If this happens, it means that there is a break on the edge of the thread, so 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 values of n and m are 2 and 3 respectively. For P (2,3) as the actual boundary punctuation, the detected P (4,3) , P (3,4) and P (2,5) are not processed as boundary punctuation; Please refer to Figure 5 shown in step S3024. Sort and number the boundary punctuation in the order from top to bottom, represented by the symbol S i , where i is a positive integer and i is the serial number of S; In step S3025, starting with i = 1, obtain the P i of S i+1 . Mark the n and m corresponding to the P (n,m) of S i as h and q respectively, and mark the n and m corresponding to the P (n,m) of S i+1 as g and p respectively; (n,m) In step S3026, obtain the screw pixel points between P (n,q) and P (n,p) , and mark them as regional pixel points; obtain the maximum value of n in the P (n,m) of the regional pixel points, mark it as k, and mark the minimum value of h and g as f; In step S3027, integrate the P (n,m) where f ≤ n ≤ k and q ≤ m ≤ p into one thread partition, increment i by one and re - analyze until i = max(i) - 1 to stop the analysis, obtaining several thread partitions, where max(i) is the maximum value of i; In specific implementation, the sorting of the boundary punctuation is as Figure 5 shown. Taking S1 as an example, obtain the P (n,m) of S1 and S2. Among them, the P (n,m) of S1 is P (1,7) , at this time h = 1, q = 7, the P (n,m) of S2 is P (2,22) , at this time g = 2, p = 22; the process of finding k is to determine the right boundary of the thread partition. It is found that k = 33. Since h < g, then f = h = 1. Integrate the P (n,m) where 1 ≤ n ≤ 33 and 7 ≤ m ≤ 22 into one thread partition; and so on until all of S i are analyzed completely.
[0021] In step S4, perform defect analysis on the thread partitions to determine whether there are defects in the thread partitions. Step S4 includes the following sub - steps: Step S401, performing defect analysis on thread partitions, analyzing partition features of thread partitions using defect-free screw samples, and then analyzing error thresholds between different partition features; Step S401 includes the following sub-steps: See also Figure 6 As shown, in step S4011, the thread partitions are numbered in the order from top to bottom in the completion diagram, and the thread partitions are numbered by the symbol R t Represents, where t is a positive integer and t is the serial number of R; Step S4012, 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 , marked as grayscale number; In the specific implementation, 12 thread partitions are obtained, such as Figure 6 As shown, Figure 6 The left column in the middle is R1 to R6 from top to bottom, and the left column is R7 to R from top to bottom. 12 , taking R2 as an example, in R2, the pixel with a grayscale value of 255 is not a screw pixel, so it is not included in the statistical range. In R2, the screw grayscale values include 137, 146, 158, 89 and 96. Taking the screw grayscale value 137 as an example, there are 16 screw pixels with a screw grayscale value of 137 in the thread partition of R2, that is, the number of grayscales of the screw grayscale value 137 is 16. By analogy, the number of grayscales of different screw grayscale values is counted; See also Figure 7 As shown, in step S4013, a plane rectangular coordinate system is established with the gray value of the screw as the X-axis and the gray quantity as the Y-axis, and is named the partition feature coordinate system. The gray value of the screw and the corresponding gray quantity are entered into the partition feature coordinate system, and adjacent coordinate points in the partition feature coordinate system are connected by a smooth curve, and the obtained curve is named R t Zoning characteristics; See also Figure 8 As shown, step S4014, all R t The partition feature is entered into the partition feature coordinate system, the difference between the maximum value and the minimum value 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, marked as the maximum difference; Step S4015, analyzing the first number of screw samples to obtain the maximum difference values of the first number, finding the maximum value among the maximum differences, and marking it as the error threshold; In the specific implementation, the partition feature coordinate system of R2 is constructed as follows Figure 7 As shown in the figure, the curve is the R2 partition feature. Similarly, the R1 to R 12Partition 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. Take the gray value of screw 137 as an example, where the maximum value is 17 and the minimum value is 15. The feature difference is calculated to be 2. The feature difference of each screw gray value is calculated, and then 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 accidental events. The screw manufacturer can manually screen the first number of defective screws in the early stage of production to enter the features, so as to analyze and obtain the error threshold corresponding to the screw of this model; in this embodiment, the error threshold is calculated and found to be 8; Step S402, based on the error threshold obtained by analysis, analyzing the thread partitions obtained during actual detection to determine whether there are defects in the threads of the screw; Step S402 includes the following sub-steps: Step S4021, calculate the R of the thread partition obtained during the actual detection t Zoning characteristics; Step S4022, taking R1 as the standard, calculate each R t The maximum difference relative to R1 is marked as t difference; Step S4023, 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, a partition-defective signal is output; Step S4024, if all output partitions have no defect signals, the screw is determined to be defective; otherwise, the screw is determined to be defective; In the specific implementation, since R1 is the connecting 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. R 12 If the t difference is greater than the error threshold, the partition is output with a defect signal, and the remaining t differences are less than or equal to the error threshold, and the partition is output without a defect signal; if there is an output defect signal, the screw is judged to be defective, and in fact there is a defect at the tip of the screw, so the judgment result is accurate.
[0022] Example 2, please refer to Fig. 9 As shown, Fig. 9The structural schematic diagram of an electronic device is illustrated, and the electronic device may include: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus. The memory stores computer-readable instructions, and the processor can call the instructions in the memory. When the computer-readable instructions are executed by the processor, the steps in the metal bone screw defect detection method based on image processing are executed to achieve the following functions: build a screw image acquisition scene and acquire the screw image; pre-process the acquired screw image and extract the screw precise image; divide the thread in the screw precise image into regions to obtain thread partitions; perform defect analysis on the thread partitions and determine whether there are defects in the thread partitions.
[0023] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units 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 can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable 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, etc. Various media that can store program codes.
[0024] Embodiment 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, and the method includes: building a screw image acquisition scene to acquire the screw image; preprocessing the acquired screw image to extract the precise image of the screw; dividing the thread in the precise image of the screw into regions to obtain thread partitions; performing defect analysis on the thread partitions to determine whether there are defects in the thread partitions.
[0025] Embodiment 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 the processor, the steps in the metal bone screw defect detection method based on image processing are executed to achieve the following functions: build a screw image acquisition scene and acquire the screw image; pre-process the acquired screw image and extract the precise image of the screw; divide the thread in the precise image of the screw into regions to obtain thread partitions; perform defect analysis on the thread partitions to determine whether there are defects in the thread partitions.
[0026] Through the description of the above implementation methods, the embodiments of the present invention can be provided as methods, systems or computer program products. Based on such an understanding, the above technical solutions can be essentially or partly contributed to the prior art in the form of software products, which can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and include several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0027] In the embodiments provided in the present application, it should be understood that the disclosed system or method can be implemented in other ways. The embodiments described above are merely schematic. 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.
[0028] 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 it. 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; Preprocessing the acquired screw image to extract the precise screw image; 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 thread partitions.
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, the acquisition of screw images includes the following sub-steps: Create an enclosed space; There are four surfaces in the closed space, which are named surface A, surface B, surface C and surface D respectively. 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 of the A surface, the midpoint of the top edge, and the midpoint of the bottom edge, respectively, for illuminating the enclosed space; The C surface is a white background wall, and the B and D surfaces have passages for conveyor belts to transport screws into and out of the closed space; The screw images are collected.
3. The metal bone screw defect detection method based on image processing according to claim 2 is 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 is characterized in that: Preprocessing the acquired screw image to extract the precise screw image includes the following sub-steps: Grayscale 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 is characterized in that: The thread area in the screw precise image is divided into regions to obtain thread partitions, 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; The screw pixels are divided into regions to obtain thread partitions.
6. The metal bone screw defect detection method based on image processing according to claim 5, characterized in that: Numbering the image pixels in the precise image of the screw 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, which is named as the image grayscale value; Eliminate the 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 in the completed image is restored to the image pixel with an image gray 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 in the nth column and the mth row in the completed image; 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.
7. The metal bone screw defect detection method based on image processing according to claim 6, characterized in that: The screw pixel points are divided into regions to obtain thread partitions, which includes the following sub-steps: Take any screw pixel as the target, mark it as the central pixel, obtain the pixels to be analyzed to the left, upper left, and above the central pixel, and mark them as the left neighbor, upper left neighbor, and upper neighbor; Detect whether the left neighbor point, the upper left neighbor point and the upper neighbor point are screw pixels. If the left neighbor point, the upper left neighbor point and the upper neighbor point are not screw pixels, output the region boundary signal; otherwise, output the region internal signal; Get 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; The boundary punctuation points are numbered 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. 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, 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.
8. The metal bone screw defect detection method based on image processing according to claim 7, characterized in that: Performing defect analysis on thread partitions to determine whether there are defects in thread partitions includes the following sub-steps: Conduct defect analysis on thread partitions, analyze the partition characteristics of thread partitions through 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.
9. The metal bone screw defect detection method based on image processing according to claim 8, characterized in that: The defect analysis of thread partitions is performed, the partition characteristics of thread partitions are analyzed by defect-free screw samples, and then the error thresholds between different partition characteristics are analyzed, which 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 serial 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 , marked as grayscale number; A plane rectangular coordinate system is established with the screw gray value as the X-axis and the gray quantity as the Y-axis, named the partition feature coordinate system. The screw gray value and the corresponding gray 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 Zoning characteristics; All R t The partition feature is entered into the partition feature coordinate system, the difference between the maximum value and the minimum value 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, marked as the maximum difference; The first number of screw samples are analyzed to obtain the first number of maximum differences, and the maximum value among the maximum differences is found and marked as the error threshold.
10. The metal bone screw defect detection method based on image processing according to claim 9, characterized in that: Based on the error threshold obtained by analysis, the thread partition obtained during actual detection is analyzed to determine whether the thread of the screw has defects, including the following sub-steps: Calculate the R of the thread partition obtained during actual detection t Zoning characteristics; Taking R1 as the standard, calculate each R t The maximum difference relative to R1 is marked as t difference; The t difference is compared 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 free of defects; 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
Thread defect detection method and device, computing equipment and storage medium
CN115760747A
Bolt assembly defect visual detection method and system
CN117934419A
Cited By
Light guide plate defect analysis method and system
CN121141697A
Light guide plate defect analysis method and system
CN121141697B
Bolt shrinkage defect detection method applied to medical instrument
CN121213519A