A quality detection method for locked metal bone plates based on machine vision
By fixing the locked metal bone plate and shooting at high-definition cameras, combined with grayscale processing and edge law analysis, the problems of edge extraction errors and large distance measurement errors in bone plate image quality detection in the prior art are solved, and high-precision bone plate quality detection is achieved.
Patent Information
- Application Number
- CN202410854920.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-06-28
AI Technical Summary
The existing bone plate image quality detection technology is easily affected by threads during edge extraction and distance measurement, resulting in edge extraction errors and distance measurement errors, which cannot support high-precision quality detection.
By fixing the locked metal bone plate and taking a high-definition camera, the bone plate image is obtained and grayscale processing and analysis is performed. Based on the main pixel grid and edge grayscale rules in the grayscale diagram, the starting measurement point of the screw hole is found, and the size of the bone plate is accurately analyzed.
It improves the accuracy and effectiveness of bone plate image quality detection, reduces edge extraction errors and distance measurement errors, and supports high-precision bone plate quality detection.
Smart Images

Figure CN118552518B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of bone plate image quality detection, and in particular to a locking metal bone plate quality detection method based on machine vision. Background Art
[0002] Bone plate image quality detection technology refers to the use of computer vision and image processing technology to analyze and evaluate bone plate images to determine whether the image quality meets the requirements.
[0003] Existing bone plate image quality detection technologies usually perform quality inspections on the size information and surface defects of the bone plate to determine whether the quality of the metal plate is qualified; for example, a patent application with application publication number CN113793338A discloses a method, system, device and storage medium for defect detection of metal parts with holes. In this solution, when a defect is detected on a certain side of the part to be detected during the detection process, the subsequent module will no longer collect images for detection of the product, but will directly skip it, thereby reducing image acquisition and software processing time, that is, reducing the waste of computing resources; the existing technology usually uses edge extraction technology to find the edges of each screw hole of the bone plate when analyzing the size information, and then obtains the size of each screw hole by measuring the distance between the edges. However, the existing bone plate image quality detection technology has difficulty in correctly extracting the edge of the image. There is usually a black threaded part in the image, which is located in the screw hole. The existing bone plate image quality detection technology is usually affected by it, resulting in errors in the edge extraction result, and further leading to errors in the assessment of the size of the screw hole. At the same time, the existing bone plate image quality detection technology usually uses AI distance measurement when measuring distance. The error of AI distance measurement is usually large and cannot support the quality inspection of bone plates that require high precision. The existing bone plate image quality detection technology also has the problem that the edge extraction of the bone plate is easily affected by the thread and the AI distance measurement cannot support the quality inspection of the bone plate that requires high precision, resulting in inaccurate quality assessment of the size of the bone plate. 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 fixing a locking metal plate, then photographing the locking metal plate with a high-definition camera to obtain an image of the plate, grayscale processing of the image of the plate to obtain a grayscale map of the plate, and then analyzing the main pixel grid, the main adjacent pixel grid and the adjacent neighborhood pixel grid in the grayscale map of the plate to obtain an image to be analyzed, analyzing the image to be analyzed to obtain the horizontal edge grayscale law and the vertical edge grayscale law of the image to be analyzed, and then finding the starting point of each screw hole in the grayscale map of the plate based on the horizontal edge grayscale law and the vertical edge grayscale law, and analyzing whether the size of the locking metal plate is qualified based on the starting point, so as to solve the problems in the existing plate image quality detection technology that the edge extraction of the plate is easily affected by the thread and the AI ranging cannot support the quality detection of the plate requiring high precision, resulting in inaccurate quality assessment of the size of the plate.
[0005] To achieve the above object, the present application provides a method for detecting the quality of a locked metal bone plate based on machine vision, comprising the following steps:
[0006] The locking metal bone plate is fixed, and the locking metal bone plate is photographed by a high-definition camera to obtain an image of the bone plate;
[0007] Performing grayscale processing on the bone plate image to obtain a bone plate grayscale image, and then analyzing the bone plate grayscale image to obtain an image to be analyzed;
[0008] Analyze the image to be analyzed to obtain the horizontal edge grayscale law and the vertical edge grayscale law of the image to be analyzed, and then find the starting point of each screw hole in the bone plate grayscale image based on the horizontal edge grayscale law and the vertical edge grayscale law;
[0009] Analyze whether the size of the locking metal plate is qualified based on the starting point.
[0010] Furthermore, it is characterized in that the locked metal bone plate is fixed, and the locked metal bone plate is photographed by a high-definition camera to obtain an image of the bone plate, which includes the following sub-steps:
[0011] Place the locking metal plate at the point to be photographed, and stabilize the locking metal plate with a stabilizer;
[0012] Aim the high-definition camera at the locked metal plate, ensuring that the locked metal plate spans the image and occupies a length ratio greater than the first shot ratio of the image length;
[0013] The locking metal bone plate is photographed to obtain a bone plate image.
[0014] Further, it is characterized in that grayscale processing is performed on the bone plate image to obtain a bone plate grayscale image, and then the bone plate grayscale image is analyzed to find the starting point of each screw hole in the bone plate grayscale image, which includes the following sub-steps:
[0015] The bone plate image is gray-scale processed to obtain a bone plate gray-scale image, and the gray-scale value of a pixel grid in the bone plate gray-scale image is marked as a pixel gray-scale;
[0016] Find the pixel grayscale that is below the first grayscale threshold and has the largest proportion, mark it as the maximum proportion grayscale, and mark the pixel grid whose pixel grayscale is equal to the maximum proportion grayscale as the main pixel grid;
[0017] Find the pixel grids adjacent to the main pixel grid, mark them as the main adjacent pixel grids, find the pixel grids within the eight neighborhoods of the main adjacent pixel grids, and mark them as the adjacent neighborhood pixel grids;
[0018] The adjacent neighborhood pixel grids are further analyzed to obtain the image to be analyzed.
[0019] Furthermore, it is characterized in that further analyzing the adjacent neighborhood pixel grids comprises the following sub-steps:
[0020] The number of subject pixel grids in the adjacent neighborhood pixel grids is counted and marked as the subject pixel number. The subject pixel ratio is obtained by dividing the subject pixel number by 8. The remaining adjacent neighborhood pixel grids are counted according to the pixel grayscale ratio and marked as the neighborhood pixel ratio.
[0021] Compare the main pixel ratio with the neighboring pixel ratio. If the main pixel ratio is greater than or equal to the neighboring pixel ratio, output the main pixel signal; if the main pixel ratio is less than the neighboring pixel ratio, output the non-main pixel signal;
[0022] If all the main pixel signals are output, the pixel grayscale of the corresponding main adjacent pixel grid is changed to the grayscale with the maximum proportion, and the main adjacent pixel grid is marked as the main pixel grid;
[0023] After analyzing all the adjacent pixel grids of the subject, the image to be analyzed is obtained.
[0024] Furthermore, it is characterized in that analyzing the image to be analyzed includes the following sub-steps:
[0025] Marking pixel grids whose pixel grayscale in the image to be analyzed is less than a first grayscale threshold as metal grayscale grids, marking pixel grids whose pixel grayscale in the image to be analyzed is greater than or equal to the first grayscale threshold as blank grayscale grids, and marking blank grayscale grids adjacent to metal grayscale grids as starting grayscale grids;
[0026] The metal grayscale grid whose pixel grayscale is equal to the maximum grayscale proportion is renamed as the surface grayscale grid, and the surface grayscale grid adjacent to the metal grayscale grid is marked as the starting grayscale grid;
[0027] Perform lateral edge analysis on the image to be analyzed to obtain the lateral edge grayscale rule;
[0028] Perform longitudinal edge analysis on the image to be analyzed to obtain the longitudinal edge grayscale rule;
[0029] Based on the horizontal edge grayscale rule and the vertical edge grayscale rule, mark the starting point of each screw hole in the image to be analyzed.
[0030] Furthermore, it is characterized in that the lateral edge analysis of the image to be analyzed includes the following sub-steps:
[0031] Taking the starting grayscale grid as the starting point, searching for a first number of metal grayscale grids in a direction toward the adjacent metal grayscale grids in the horizontal direction, marking them as a horizontal transition grayscale group, wherein the metal grayscale grids in the horizontal transition grayscale group include a horizontal transition grayscale grid and a horizontal transition peripheral grayscale grid, integrating the starting grayscale grid and the horizontal transition grayscale grids adjacent to the starting grayscale grid into a horizontal peripheral grayscale group, wherein the horizontal peripheral grayscale group includes a horizontal starting peripheral grayscale grid and a horizontal transition peripheral grayscale grid;
[0032] The pixel grayscale of the horizontal starting peripheral grayscale grid is represented by the symbol TSPG, the pixel grayscale of the horizontal transition peripheral grayscale grid is represented by the symbol TEPG, and the pixel grayscale of the horizontal transition grayscale grid is represented by the symbol TEGG;
[0033] Calculate TSPG-TEPG and mark the result as the lateral starting gradient value; calculate TEPG-TEGG and mark the result as the lateral transition gradient value;
[0034] Perform the same analysis on all horizontal starting grayscale grids to obtain a number of horizontal starting gradient values and horizontal transition gradient values;
[0035] A rectangular coordinate system is established with the horizontal starting gradient value as the X-axis and the horizontal transition gradient value as the Y-axis, named as a horizontal gradient scatter plot, and the horizontal starting gradient value and the corresponding horizontal transition gradient value are entered into the horizontal gradient scatter plot;
[0036] Polynomial regression is performed on the transverse gradient scatter plot to obtain the grayscale law of the transverse edge.
[0037] Furthermore, it is characterized in that the longitudinal edge analysis of the image to be analyzed includes the following sub-steps:
[0038] Taking the starting grayscale grid as the starting point, searching for a first number of metal grayscale grids in the direction of the longitudinally adjacent metal grayscale grids, marking them as a longitudinal transition grayscale group, wherein the metal grayscale grids in the longitudinal transition grayscale group include a longitudinal transition grayscale grid and a longitudinal transition peripheral grayscale grid, integrating the starting grayscale grid and the longitudinal transition grayscale grids adjacent to the starting grayscale grid into a longitudinal peripheral grayscale group, wherein the longitudinal peripheral grayscale group includes a longitudinal starting peripheral grayscale grid and a longitudinal transition peripheral grayscale grid;
[0039] The pixel grayscale of the vertical starting peripheral grayscale grid is represented by the symbol PSPG, the pixel grayscale of the vertical transition peripheral grayscale grid is represented by the symbol PEPG, and the pixel grayscale of the vertical transition grayscale grid is represented by the symbol PEGG;
[0040] Calculate PSPG-PEPG and mark the result as the longitudinal starting gradient value; calculate PEPG-PEGG and mark the result as the longitudinal transition gradient value;
[0041] Perform the same analysis on all the vertical starting grayscale grids to obtain a number of vertical starting gradient values and vertical transition gradient values;
[0042] A rectangular coordinate system is established with the longitudinal starting gradient value as the X-axis and the longitudinal transition gradient value as the Y-axis, named as a longitudinal gradient scatter plot, and the longitudinal starting gradient value and the corresponding longitudinal transition gradient value are entered into the longitudinal gradient scatter plot;
[0043] Perform polynomial regression on the longitudinal gradient scatter plot to obtain the longitudinal edge grayscale law.
[0044] Furthermore, it is characterized in that, based on the horizontal edge grayscale law and the vertical edge grayscale law, marking the starting point of each screw hole in the image to be analyzed includes the following sub-steps:
[0045] Obtain the horizontal edge grayscale law and the vertical edge grayscale law, substitute the horizontal starting gradient value into the horizontal edge grayscale law, substitute the vertical starting gradient value into the vertical edge grayscale law, and mark the calculated results as the horizontal initial limit value and the vertical initial limit value respectively;
[0046] The horizontal initial limit value is increased by the first error ratio and decreased by the first error ratio respectively to obtain a horizontal upper limit value and a horizontal lower limit value, and all horizontal transition gradient values corresponding to the horizontal initial gradient value are compared with the horizontal upper limit value and the horizontal lower limit value, and if the horizontal transition gradient value is greater than or equal to the horizontal lower limit value and less than or equal to the horizontal upper limit value, a horizontal transition pixel signal is output; otherwise, a horizontal edge pixel signal is output;
[0047] If a horizontal transition pixel signal is output, the corresponding horizontal starting peripheral grayscale grid, horizontal transition grayscale grid and horizontal transition peripheral grayscale grid are all changed to blank pixel grids, and the pixel grayscale is changed to the second grayscale threshold value; if a horizontal edge pixel signal is output, the horizontal transition grayscale grid and the horizontal transition peripheral grayscale grid are changed to blank pixel grids, the corresponding pixel grayscale is changed to the second grayscale threshold value, and the horizontal transition grayscale grid is marked as an edge pixel grid;
[0048] The longitudinal initial limit value is increased by the first error ratio and decreased by the first error ratio respectively to obtain a longitudinal upper limit value and a longitudinal lower limit value, and all longitudinal transition gradient values corresponding to the longitudinal initial gradient value are compared with the longitudinal upper limit value and the longitudinal lower limit value, and if the longitudinal transition gradient value is greater than or equal to the longitudinal lower limit value and less than or equal to the longitudinal upper limit value, a longitudinal transition pixel signal is output; otherwise, a longitudinal edge pixel signal is output;
[0049] If a longitudinal transition pixel signal is output, the corresponding longitudinal starting peripheral grayscale grid, longitudinal transition grayscale grid and longitudinal transition peripheral grayscale grid are all changed to blank pixel grids, and the pixel grayscale is changed to the second grayscale threshold value; if a longitudinal edge pixel signal is output, the longitudinal transition grayscale grid and longitudinal transition peripheral grayscale grid are changed to blank pixel grids, the corresponding pixel grayscale is changed to the second grayscale threshold value, and the longitudinal transition grayscale grid is marked as an edge pixel grid;
[0050] The screw holes of the locking metal bone plate are analyzed to obtain the starting point of each screw hole.
[0051] Furthermore, it is characterized in that analyzing the screw holes of the locking metal bone plate comprises the following sub-steps:
[0052] All the remaining metal grayscale grids are marked as edge pixel grids, and the pixel grids in the image to be analyzed are numbered and named as pixel numbers, which are represented by the symbol S (n,m) Indicates, where n and m are both positive integers and (n,m) is the number of S, n is the row number, and m is the column number;
[0053] Extract the circular area in the image to be analyzed, mark it as the screw hole area, find the pixel numbers of all edge pixel grids, and mark them as edge pixel numbers;
[0054] For any screw hole area, the edge pixel number in the screw hole area is marked as the edge screw hole pixel number, the edge screw hole pixel number with the smallest n and the largest n are marked as the leftmost pixel number and the rightmost pixel number, and the edge screw hole pixel number with the smallest m and the largest m are marked as the topmost pixel number and the bottommost pixel number;
[0055] Find the leftmost pixel number and the rightmost pixel number that are the same as m, and mark them as the left starting point and the right starting point; find the topmost pixel number and the bottommost pixel number that are the same as n, and mark them as the top starting point and the bottom starting point;
[0056] All screw hole areas are analyzed to obtain starting points of different screw hole areas, wherein the starting points include a left starting point, a right starting point, an upper starting point, and a lower starting point.
[0057] Further, it is characterized in that analyzing whether the size of the locking metal bone plate is qualified based on the starting point comprises the following sub-steps:
[0058] Get the horizontal and vertical lengths of the shooting area of the high-definition camera;
[0059] Calculate the horizontal length multiplied by the vertical length to get the area, and then calculate max(n)×max(m) to get the number of pixels, where max(n) is the maximum value of n and max(m) is the maximum value of m;
[0060] calculate , RA is the area, PC is the number of pixels, the calculation result is marked as pixel length, the value of m from the lower starting point minus the value of m from the upper starting point is calculated, marked as the longitudinal diameter, and the value of n from the right starting point minus the value of n from the left starting point is calculated, marked as the transverse diameter;
[0061] Acquiring specification information of a locking metal bone plate, wherein the specification information includes a standard diameter of a screw hole;
[0062] The longitudinal diameter and the transverse diameter are added and the average value is taken to calculate the measured diameter of the screw hole. The measured diameter of the screw hole is subtracted from the standard diameter of the screw hole and the absolute value is taken to obtain the screw hole diameter difference. The screw hole diameter difference is compared with the first error threshold. If the screw hole diameter difference is less than the first error threshold, a size qualified signal is output; if the screw hole diameter difference is greater than or equal to the first error threshold, a size unqualified signal is output.
[0063] Beneficial effects of the present invention: The present invention fixes the locking metal bone plate, then uses a high-definition camera to shoot the locking metal bone plate to obtain a bone plate image, performs grayscale processing on the bone plate image to obtain a bone plate grayscale map, and then analyzes the main pixel grid, the main adjacent pixel grid and the adjacent neighborhood pixel grid in the bone plate grayscale map to obtain an image to be analyzed. The advantage is that when a computer displays an image, for parts of the same color, the grayscale value usually fluctuates slightly due to the lighting of the shooting, rather than being all equal. Therefore, the main pixel grid represents the main part of the bone plate, and its adjacent neighborhood grids will have many main adjacent pixel grids with similar colors. By analyzing the adjacent neighborhood pixel grids of the main adjacent pixel grid, it can be confirmed whether the main adjacent pixel grid is part of the main pixel grid, thereby improving the accuracy of the grayscale value of the bone plate grayscale image.
[0064] The present invention analyzes the image to be analyzed, obtains the horizontal edge grayscale law of the image to be analyzed based on the horizontal transition grayscale group and the horizontal peripheral grayscale group, and obtains the vertical edge grayscale law based on the vertical transition grayscale group and the vertical peripheral grayscale group. The advantage is that when a computer displays an image, in order to make the image edge transition smoother, it will add smooth transition pixels at the edge of the image, and such pixels usually have certain rules in the horizontal and vertical directions. By finding the horizontal edge grayscale law and the vertical edge grayscale law, it can be confirmed which part of the image to be analyzed belongs to the smooth transition pixels and which part belongs to the edge pixels, thereby improving the accuracy and rationality of bone plate image quality detection.
[0065] The present invention finds the starting point of each screw hole in the grayscale image of the bone plate based on the horizontal edge grayscale law and the longitudinal edge grayscale law, and analyzes whether the size of the locked metal bone plate is qualified based on the starting point. The advantage is that the analysis of the starting point can accurately find the edge pixel grid located at the outermost edge of each screw hole, while the existing measurement by contour extraction is easily affected by the thread surface, and the measurement with the bottom edge of the thread surface and the top edge of the screw hole will lead to inaccurate measurement results, thereby leading to inaccurate quality assessment of the bone plate, thereby improving the accuracy and effectiveness of bone plate image quality detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1 is a flow chart of the steps of the method of the present invention;
[0067] Figure 2 A schematic diagram of fixing a locking metal bone plate according to the present invention;
[0068] Figure 3 A grayscale image of a bone plate of the present invention;
[0069] Figure 4A schematic diagram of adjacent pixel grids of the main body of the present invention;
[0070] Figure 5 A schematic diagram of eight neighborhoods of adjacent pixel grids of the main body of the present invention;
[0071] Figure 6 The image to be analyzed of the present invention;
[0072] Figure 7 is a schematic diagram of the starting grayscale grid of the present invention;
[0073] Figure 8 It is a schematic diagram of the lateral transition grayscale grid, the lateral transition peripheral grayscale grid and the lateral starting peripheral grayscale grid of the present invention;
[0074] Fig. 9 is a scatter plot of the transverse gradient of the present invention;
[0075] Fig.10 It is a schematic diagram of the longitudinal transition grayscale grid, the longitudinal transition peripheral grayscale grid and the longitudinal starting peripheral grayscale grid of the present invention;
[0076] Fig.11 It is the longitudinal gradient scatter plot of the present invention;
[0077] Fig.12 Schematic diagram of the screw hole area of the present invention. DETAILED DESCRIPTION
[0078] 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.
[0079] Example 1, please refer to Figure 1 As shown, in the first aspect, the present application provides a method for detecting the quality of a locking metal bone plate based on machine vision, comprising the following steps:
[0080] Step S1, fix the locking metal bone plate, and photograph the locking metal bone plate with a high-definition camera to obtain an image of the bone plate; Step S1 includes the following sub-steps:
[0081] See also Figure 2 As shown, step S101, placing a locking metal bone plate at a position to be photographed, and stabilizing the locking metal bone plate by a stabilizer;
[0082] Step S102, aiming the high-definition camera at the locked metal bone plate, ensuring that the locked metal bone plate spans the image, and the length ratio occupied by the locked metal bone plate is greater than the first shooting ratio of the image length;
[0083] Step S103, photographing the locked metal bone plate to obtain an image of the bone plate;
[0084] In the specific implementation, the high-definition camera uses an existing high-definition camera to fix the locking metal bone plate. Figure 2 As shown, the locked metal plate is clamped in the point to be photographed by moving and fixing the stabilizer. The purpose of fixing it with the stabilizer is to allow the locked metal plate to be in the center of the point to be photographed, and it needs to be placed horizontally. The high-definition camera is located above the point to be photographed. When the locked metal plate is placed horizontally, the image taken by the high-definition camera is placed vertically. When shooting, the distance between the high-definition camera and the desktop needs to be moved so that the length of the locked metal plate accounts for a larger proportion in the plate image than the first shooting ratio. The first shooting ratio is set to 90%. The first shooting ratio is set to make the image of the locked metal plate larger, so that more details can be captured.
[0085] Step S2, grayscale processing is performed on the bone plate image to obtain a bone plate grayscale image, and then the bone plate grayscale image is analyzed to obtain an image to be analyzed; Step S2 includes the following sub-steps:
[0086] See also Figure 3 As shown, step S201, grayscale processing is performed on the bone plate image to obtain a bone plate grayscale image, and the grayscale value of the pixel grid in the bone plate grayscale image is marked as the pixel grayscale;
[0087] Step S202, searching for a pixel grayscale that is below a first grayscale threshold and has the largest proportion, marking it as the grayscale with the largest proportion, and marking a pixel grid whose pixel grayscale is equal to the grayscale with the largest proportion as a main pixel grid;
[0088] See also Figures 4 to 5 As shown, step S203, find pixel grids adjacent to the main pixel grid, mark them as main adjacent pixel grids, find pixel grids within the eight neighborhoods of the main adjacent pixel grid, mark them as adjacent neighborhood pixel grids;
[0089] In a specific implementation, the bone plate image is gray-scale processed to obtain a bone plate gray-scale image such as Figure 3As shown, since the color of the locked metal plate is silver-gray, the plate image and the plate grayscale image are difficult to distinguish by naked eye observation; since the grayscale value of the blank area of the grayscale image is usually above 250, the first grayscale threshold is set to 250 to prevent the blank area from affecting the selection of the main pixel grid; since there are too many main pixel grids, in this embodiment, only the main adjacent pixel grids of one main pixel grid are selected as an example for analysis, in order to explain the specific analysis process, and the analysis process of the remaining main adjacent pixel grids is omitted; the maximum proportion of grayscale is found to be 146, and the pixel grid with a pixel grayscale of 146 is marked as the main pixel grid, wherein any main pixel grid is selected, and the main adjacent pixel grids in its eight neighborhoods are as follows Figure 4 As shown in FIG. 1 , the pixel grid with numbers is the main adjacent pixel grid, and the corresponding numbers are the pixel grayscales of the main adjacent pixel grid. The pixel grid without numbers is the main pixel grid and is not counted in the main adjacent pixel grid. This embodiment takes the main adjacent pixel grid corresponding to 144 as an example to find out the eight neighborhoods of the main adjacent pixel grid. Figure 5 As shown, Figure 6 In , each number corresponds to the pixel grayscale of the adjacent neighborhood pixel grid, and the blank pixel grid is the main adjacent pixel grid;
[0090] Step S204, further analyzing the adjacent neighborhood pixel grids to obtain an image to be analyzed;
[0091] Step S204 includes the following sub-steps:
[0092] Step S204.1, counting the number of subject pixel grids in the adjacent neighborhood pixel grids, marking it as the subject pixel number, dividing the subject pixel number by 8 to obtain the subject pixel ratio; counting the percentage of the remaining adjacent neighborhood pixel grids according to the pixel grayscale, marking it as the neighborhood pixel ratio;
[0093] Step S204.2, comparing the main pixel ratio with the neighboring pixel ratio, if the main pixel ratio is greater than or equal to the neighboring pixel ratio, outputting the main pixel signal; if the main pixel ratio is less than the neighboring pixel ratio, outputting the non-main pixel signal;
[0094] Step S204.3, if all the main pixel signals are output, the pixel grayscale of the corresponding main adjacent pixel grid is changed to the grayscale with the maximum proportion, and the main adjacent pixel grid is marked as the main pixel grid;
[0095] See also Figure 6 As shown, step S204.4, after analyzing all the adjacent pixel grids of the subject, an image to be analyzed is obtained;
[0096] In the specific implementation, the number of subject pixels is 3, the subject pixel ratio is calculated to be 3 / 8, the neighboring pixel ratio of pixel grayscale 145 is 3 / 8, the neighboring pixel ratios of pixel grayscale 151 and pixel grayscale 148 are both 1 / 8, and the subject pixel ratio is greater than 1 / 8 and equal to 3 / 8 through comparison, that is, the subject pixel ratio is greater than or equal to the neighboring pixel ratio, and the subject pixel signal is output for all three comparisons, then the pixel grayscale of the corresponding subject adjacent pixel grid is changed to 146 and the subject adjacent pixel grid is marked as the subject pixel grid; after analyzing all the subject adjacent pixel grids, the image to be analyzed is obtained as follows Figure 6 As shown, since the image is too small, it is difficult for the naked eye to perceive the change, but the grayscale value has changed.
[0097] Step S3, analyzing the image to be analyzed, obtaining the horizontal edge grayscale law and the vertical edge grayscale law of the image to be analyzed, and then finding the starting point of each screw hole in the bone plate grayscale image based on the horizontal edge grayscale law and the vertical edge grayscale law; Step S3 includes the following sub-steps:
[0098] See also Figure 7 As shown, step S301, marking the pixel grids whose pixel grayscale in the image to be analyzed is less than the first grayscale threshold as metal grayscale grids, marking the pixel grids whose pixel grayscale in the image to be analyzed is greater than or equal to the first grayscale threshold as blank grayscale grids, and marking the blank grayscale grids adjacent to the metal grayscale grids as starting grayscale grids;
[0099] Step S302, renaming the metal grayscale grid whose pixel grayscale is equal to the maximum grayscale proportion as the surface grayscale grid, and marking the surface grayscale grid adjacent to the metal grayscale grid as the starting grayscale grid;
[0100] In the specific implementation, the starting grayscale grid is marked as Figure 7 As shown, Figure 7 The pure black pixel grid in is the starting grayscale grid;
[0101] Step S303, performing horizontal edge analysis on the image to be analyzed to obtain a horizontal edge grayscale rule;
[0102] Step S303 includes the following sub-steps:
[0103] See also Figure 8 As shown, step S303.1, starting from the starting grayscale grid, searching for a first number of metal grayscale grids in a direction toward the adjacent metal grayscale grids in the horizontal direction, marking them as a horizontal transition grayscale group, wherein the metal grayscale grids in the horizontal transition grayscale group include a horizontal transition grayscale grid and a horizontal transition peripheral grayscale grid, integrating the starting grayscale grid and the horizontal transition grayscale grids adjacent to the starting grayscale grid into a horizontal peripheral grayscale group, wherein the horizontal peripheral grayscale group includes a horizontal starting peripheral grayscale grid and a horizontal transition peripheral grayscale grid;
[0104] In a specific implementation, in order to make the edge of an image smoother when the computer displays the image, smoothing pixels are usually added to the edge of the image, and the number of smoothing pixels is usually not more than 3. Since there is a starting grayscale grid, the first number is set to 2 for finding smoothing pixels. Since there are too many starting grayscale grids, it is not convenient to show them specifically. Therefore, in this embodiment, only one starting grayscale grid is randomly selected for illustration, and the analysis process of the other starting grayscale grids is omitted in this embodiment. The distribution of the horizontal transition grayscale grid, the horizontal transition peripheral grayscale grid and the horizontal starting peripheral grayscale grid is as follows: Figure 8 As shown, Figure 8 The starting grayscale grid in is the horizontal starting peripheral grayscale grid;
[0105] Step S303.2, using symbol TSPG to represent the pixel grayscale of the horizontal starting peripheral grayscale grid, using symbol TEPG to represent the pixel grayscale of the horizontal transition peripheral grayscale grid, and using symbol TEGG to represent the pixel grayscale of the horizontal transition grayscale grid;
[0106] Step S303.3, calculate TSPG-TEPG, and mark the calculation result as the lateral starting gradient value; calculate TEPG-TEGG, and mark the calculation result as the lateral transition gradient value;
[0107] Step S303.4, performing the same analysis on all horizontal starting grayscale grids to obtain a number of horizontal starting gradient values and horizontal transition gradient values;
[0108] See also Fig. 9 As shown, in step S303.5, a rectangular coordinate system is established with the horizontal starting gradient value as the X axis and the horizontal transition gradient value as the Y axis, named as a horizontal gradient scatter plot, and the horizontal starting gradient value and the corresponding horizontal transition gradient value are entered into the horizontal gradient scatter plot;
[0109] Step S303.6, performing polynomial regression on the horizontal gradient scatter plot to obtain the grayscale law of the horizontal edge;
[0110] In the specific implementation, TSPG=252, TEPG=230, TEGG=140 are obtained, and the horizontal starting gradient value is 22 and the horizontal transition gradient value is 90 through calculation; the same analysis is performed on all horizontal starting grayscale grids to obtain several horizontal starting gradient values and horizontal transition gradient values, and then the horizontal gradient scatter plot is constructed as shown below Fig. 9 As shown in the figure, polynomial regression is performed on the horizontal gradient scatter plot to obtain the horizontal edge grayscale law: YH=0.0013×XH 2 +1.1458×XH+58.379, where YH is the lateral transition gradient value and XH is the lateral starting gradient value;
[0111] Step S304, performing longitudinal edge analysis on the image to be analyzed to obtain a longitudinal edge grayscale rule;
[0112] Step S304 includes the following sub-steps:
[0113] See also Fig.10 As shown, step S304.1, starting from the starting grayscale grid, searching for a first number of metal grayscale grids in the direction of the longitudinally adjacent metal grayscale grids, marking them as a longitudinal transition grayscale group, the metal grayscale grids in the longitudinal transition grayscale group include a longitudinal transition grayscale grid and a longitudinal transition peripheral grayscale grid, integrating the starting grayscale grid and the longitudinal transition grayscale grids adjacent to the starting grayscale grid into a longitudinal peripheral grayscale group, the longitudinal peripheral grayscale group includes a longitudinal starting peripheral grayscale grid and a longitudinal transition peripheral grayscale grid;
[0114] Step S304.2, using symbol PSPG to represent the pixel grayscale of the vertical starting peripheral grayscale grid, using symbol PEPG to represent the pixel grayscale of the vertical transition peripheral grayscale grid, and using symbol PEGG to represent the pixel grayscale of the vertical transition grayscale grid;
[0115] Step S304.3, calculate PSPG-PEPG, and mark the calculation result as the longitudinal starting gradient value; calculate PEPG-PEGG, and mark the calculation result as the longitudinal transition gradient value;
[0116] Step S304.4, performing the same analysis on all the vertical starting grayscale grids to obtain a number of vertical starting gradient values and vertical transition gradient values;
[0117] See also Fig.11 As shown, in step S304.5, a rectangular coordinate system is established with the longitudinal starting gradient value as the X-axis and the longitudinal transition gradient value as the Y-axis, named as a longitudinal gradient scatter plot, and the longitudinal starting gradient value and the corresponding longitudinal transition gradient value are entered into the longitudinal gradient scatter plot;
[0118] Step S304.6, performing polynomial regression on the longitudinal gradient scatter plot to obtain the longitudinal edge grayscale law;
[0119] In a specific implementation, the distribution of the longitudinal transition grayscale grid, the longitudinal transition peripheral grayscale grid and the longitudinal starting peripheral grayscale grid is as follows: Fig.10 As shown, Fig.10 The starting grayscale grid in is the vertical starting peripheral grayscale grid; PSPG=252, PEPG=235, PEGG=178 are obtained, and the vertical starting gradient value is calculated to be 17, and the vertical transition gradient value is 57. The same analysis is performed on all the vertical starting grayscale grids to obtain several vertical starting gradient values and vertical transition gradient values, and then the vertical gradient scatter plot is constructed as shown in Fig.11As shown in the figure, polynomial regression is performed on the longitudinal gradient scatter plot to obtain the longitudinal edge grayscale law: YZ=0.0214×XZ 2 +0.3994×XZ+42.617, where YZ is the longitudinal transition gradient value and XZ is the longitudinal starting gradient value;
[0120] Step S305, marking the starting point of each screw hole in the image to be analyzed based on the horizontal edge grayscale rule and the vertical edge grayscale rule;
[0121] Step S305 includes the following sub-steps:
[0122] Step S305.1, obtaining a horizontal edge grayscale rule and a vertical edge grayscale rule, substituting the horizontal starting gradient value into the horizontal edge grayscale rule, substituting the vertical starting gradient value into the vertical edge grayscale rule, and marking the calculated results as a horizontal initial limit value and a vertical initial limit value respectively;
[0123] In the specific implementation, the horizontal edge grayscale rule is obtained as YH=0.0013×XH 2 +1.1458×XH+58.379, the vertical edge grayscale rule is YZ=0.0214×XZ 2 +0.3994×XZ+42.617, substitute different horizontal starting gradient values and vertical starting gradient values into the formula. For example, if the horizontal starting gradient value is 22 and the vertical starting gradient value is 28, substitute XH=22 into YH=0.0013×XH 2 +1.1458×XH+58.379, the calculated initial lateral limit is 84.2, substitute XZ=28 into YZ=0.0214×XZ 2 +0.3994×XZ+42.617, the calculated initial longitudinal limit is 70.6, and the calculation results are rounded to one decimal place;
[0124] Step S305.2, respectively increasing the horizontal initial limit by the first error ratio and decreasing the first error ratio to obtain a horizontal upper limit and a horizontal lower limit, comparing all horizontal transition gradient values corresponding to the horizontal initial gradient value with the horizontal upper limit and the horizontal lower limit, and outputting a horizontal transition pixel signal if the horizontal transition gradient value is greater than or equal to the horizontal lower limit and less than or equal to the horizontal upper limit; otherwise, outputting a horizontal edge pixel signal;
[0125] In specific implementation, the first error ratio is set by the manufacturer according to demand, and the value range is usually [5%, 15%]. In this embodiment, the first error ratio is set to 10%, then the horizontal initial limit is increased by the first error ratio and reduced by the first error ratio, and the horizontal upper limit and the horizontal lower limit are obtained to be 92.6 and 75.8 respectively. The calculation results are all rounded to one decimal place; find all horizontal starting gradient values equal to 22, and compare the corresponding horizontal transition gradient values with 92.6 and 75.8. If the horizontal transition gradient value is greater than or equal to 75.8 and less than or equal to 92.6, then the horizontal transition pixel signal is output, otherwise the horizontal edge pixel signal is output; in actual use, if it does not meet this rule, it proves that the horizontal transition grayscale grid does not belong to the smooth pixel grid, then it must be an edge pixel grid, and the same applies to the vertical direction;
[0126] Step S305.3, if a horizontal transition pixel signal is output, the corresponding horizontal starting peripheral grayscale grid, horizontal transition grayscale grid and horizontal transition peripheral grayscale grid are all changed to blank pixel grids, and the pixel grayscale is changed to the second grayscale threshold; if a horizontal edge pixel signal is output, the horizontal transition grayscale grid and the horizontal transition peripheral grayscale grid are changed to blank pixel grids, the corresponding pixel grayscale is changed to the second grayscale threshold, and the horizontal transition grayscale grid is marked as an edge pixel grid;
[0127] In a specific implementation, if a horizontal transition pixel signal is output, it means that the horizontal transition grayscale grid is part of the smooth pixel grid, and all of them are changed to the second grayscale threshold 255; if a horizontal edge pixel signal is output, it means that the horizontal transition grayscale grid is part of the edge pixel grid, and it is marked as an edge pixel grid; the horizontal transition grayscale grid and the horizontal transition peripheral grayscale grid are fixed as smooth pixel grids, because the number of smooth pixel grids is generally 2 to 3;
[0128] Step S305.4, respectively increasing the longitudinal initial limit by the first error ratio and decreasing the first error ratio to obtain a longitudinal upper limit and a longitudinal lower limit, comparing all longitudinal transition gradient values corresponding to the longitudinal initial gradient value with the longitudinal upper limit and the longitudinal lower limit, and outputting a longitudinal transition pixel signal if the longitudinal transition gradient value is greater than or equal to the longitudinal lower limit and less than or equal to the longitudinal upper limit; otherwise, outputting a longitudinal edge pixel signal;
[0129] Step S305.5, if a longitudinal transition pixel signal is output, the corresponding longitudinal starting peripheral grayscale grid, longitudinal transition grayscale grid and longitudinal transition peripheral grayscale grid are all changed to blank pixel grids, and the pixel grayscale is changed to the second grayscale threshold value; if a longitudinal edge pixel signal is output, the longitudinal transition grayscale grid and longitudinal transition peripheral grayscale grid are changed to blank pixel grids, the corresponding pixel grayscale is changed to the second grayscale threshold value, and the longitudinal transition grayscale grid is marked as an edge pixel grid;
[0130] In a specific implementation, the longitudinal initial limit is increased by the first error ratio and decreased by the first error ratio, respectively, to obtain a longitudinal upper limit value and a longitudinal lower limit value of 77.7 and 63.5, respectively, to find all longitudinal starting gradient values equal to 28, and to compare the corresponding longitudinal transition gradient values with 77.7 and 63.5, and if the longitudinal transition gradient value is greater than or equal to 63.5 and less than or equal to 77.7, then a longitudinal transition pixel signal is output, otherwise a longitudinal edge pixel signal is output; if a longitudinal transition pixel signal is output, it means that the longitudinal transition grayscale grid is part of the smooth pixel grid, and all of them are changed to the second grayscale threshold of 255; if a longitudinal edge pixel signal is output, it means that the longitudinal transition grayscale grid is part of the edge pixel grid, and it is marked as an edge pixel grid;
[0131] Step S305.6, analyzing the screw holes of the locking metal bone plate to obtain the starting point of each screw hole;
[0132] Step S305.6 includes the following sub-steps:
[0133] See also Fig.12 As shown, in step S305.6.1, all the remaining metal grayscale grids are marked as edge pixel grids, and the pixel grids in the image to be analyzed are numbered and named as pixel numbers, and the symbol S is used to represent the pixel grids. (n,m) Indicates, where n and m are both positive integers and (n,m) is the number of S, n is the row number, and m is the column number;
[0134] Step S305.6.2, extract the circular area in the image to be analyzed, mark it as the screw hole area, find the pixel numbers of all edge pixel grids, and mark them as edge pixel numbers;
[0135] In the specific implementation, all the remaining metal grayscale grids are marked as edge pixel grids, and the screw hole area is extracted as follows: Fig.12 As shown, Fig.12 The gray pixels between the white circles are edge pixel grids. Since only the size of the screw hole is detected, there is no need to analyze the starting gray grid around the locked metal bone plate. Therefore, only the analysis results of the screw hole area are displayed. Fig.12 , Fig.12 The image resolution is 400×400, that is, n is at most 400, and m is at most 400; the screw hole area includes screw hole area 1, screw hole area 2, screw hole area 3, screw hole area 4, screw hole area 5, and screw hole area 6. In this embodiment, screw hole area 1 is taken as an example to illustrate the selection of the starting point, and the analysis process of the screw hole area is the same as that of the screw hole area 1;
[0136] Step S305.6.3, for any screw hole area, mark the edge pixel number in the screw hole area as the edge screw hole pixel number, mark the edge screw hole pixel number with the smallest n and the largest n as the leftmost pixel number and the rightmost pixel number, respectively, and mark the edge screw hole pixel number with the smallest m and the largest m as the topmost pixel number and the bottommost pixel number, respectively;
[0137] Step S305.6.4, find the leftmost pixel number and the rightmost pixel number that are the same as m, and mark them as the left starting point and the right starting point; find the topmost pixel number and the bottommost pixel number that are the same as n, and mark them as the top starting point and the bottom starting point;
[0138] Step S305.6.5, analyzing all screw hole areas to obtain starting points of different screw hole areas, the starting points including left starting point, right starting point, top starting point and bottom starting point;
[0139] In a specific implementation, in the screw hole area 1, the edge screw hole pixel number includes S (196,22) , S (202,22) , S (182,35) , S (185,40) , S (215,33) , S (215,45) , S (196,56) and S (204,56) etc., where the leftmost pixel number is S (182,35) To S (185,40) , n is 182, m is 35 to 40, and the rightmost pixel number is S (215,33) To S (215,45) , n is 215, m is 33 to 45, and the top pixel number is S (196,22) To S (202,22) , m is 22, n is 196 to 202, and the lowest pixel number is S (196,56) To S (204,56) , m is 56, n is 196 to 204; for the rightmost pixel number and the leftmost pixel number, the intersection of m is [35,40], then a number is randomly selected from [35,40], such as 35, that is, S (182,35) Mark as the left measuring point, and set S (215,35) Marked as the right starting point; the selection of the upper starting point and the lower starting point is similar, and the upper starting point and the lower starting point are S (196,22) and S (196,56) .
[0140] Step S4, analyzing whether the size of the locked metal bone plate is qualified based on the starting point; Step S4 includes the following sub-steps:
[0141] Step S401, obtaining the horizontal length and vertical length of the shooting area of the high-definition camera;
[0142] Step S402, calculate the horizontal length multiplied by the vertical length to obtain the area of the region, and then calculate max(n)×max(m) to obtain the number of pixels, where max(n) is the maximum value of n and max(m) is the maximum value of m;
[0143] Step S403, calculate , RA is the area, PC is the number of pixels, the calculation result is marked as pixel length, the value of m from the lower starting point minus the value of m from the upper starting point is calculated, marked as the longitudinal diameter, and the value of n from the right starting point minus the value of n from the left starting point is calculated, marked as the transverse diameter;
[0144] Step S404, obtaining specification information of the locking metal bone plate, the specification information including the standard diameter of the screw hole;
[0145] Step S405, adding the longitudinal diameter and the transverse diameter and taking the average value to calculate the measured diameter of the screw hole, subtracting the measured diameter of the screw hole from the standard diameter of the screw hole and taking the absolute value to obtain the screw hole diameter difference, comparing the screw hole diameter difference with the first error threshold, if the screw hole diameter difference is less than the first error threshold, outputting a size qualified signal; if the screw hole diameter difference is greater than or equal to the first error threshold, outputting a size unqualified signal;
[0146] In the specific implementation, the horizontal length of the shooting area is obtained to be 100mm, the vertical length is 100mm, and the calculated area is 10000mm 2 , the number of pixels is calculated to be 160000, and the pixel length is calculated to be 0.25mm. The m of the lower measuring point is 56, and the m of the upper measuring point is 22, so the longitudinal diameter is 34, the n of the right measuring point is 215, and the n of the left measuring point is 182, so the transverse diameter is 33. The longitudinal diameter is added to the transverse diameter and the average is taken. The measured diameter of the screw hole is calculated to be 33.5, and the measured diameter of the screw hole is 8.375mm by the pixel length. The standard diameter of the screw hole is 9mm, and the calculated screw hole diameter difference is 0.625mm. The first error threshold is set to 1mm. By comparison, the screw hole diameter difference is less than the first error threshold, and the size qualification signal is output.
[0147] Embodiment 2, second aspect, the present application provides an electronic device, including a processor and a memory, the memory storing computer-readable instructions, when the computer-readable instructions are executed by the processor, the steps in the above method are executed. Through the above technical solution, the processor and the memory are interconnected and communicate with each other through a communication bus and / or other forms of connection mechanisms, the memory stores a computer program executable by the processor, when the electronic device is running, the processor executes the computer program to execute the method in any optional implementation of the above embodiment, to achieve the following functions: photographing the locked metal bone plate through a high-definition camera; grayscale processing of the bone plate image to obtain a bone plate grayscale image, and then analyzing the bone plate grayscale image to obtain an image to be analyzed; analyzing the image to be analyzed to obtain a starting point; analyzing whether the size of the locked metal bone plate is qualified based on the starting point.
[0148] Embodiment 3, third aspect, the present application provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the above method are executed. Through the above technical scheme, when the computer program is executed by the processor, the method in any optional implementation of the above embodiment is executed to achieve the following functions: photographing the locked metal bone plate with a high-definition camera; grayscale processing of the bone plate image to obtain a bone plate grayscale image, and then analyzing the bone plate grayscale image to obtain an image to be analyzed; analyzing the image to be analyzed to obtain a starting point; analyzing whether the size of the locked metal bone plate is qualified based on the starting point.
[0149] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0150] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program codes. Among them, the storage medium may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0151] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components 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 devices or units can be electrical, mechanical or other forms.
Claims
1. A method for detecting quality of a locking metal bone plate based on machine vision, characterized in that: The steps include: The locking metal bone plate is fixed, and the locking metal bone plate is photographed by a high-definition camera to obtain an image of the bone plate; Performing grayscale processing on the bone plate image to obtain a bone plate grayscale image, and then analyzing the bone plate grayscale image to obtain an image to be analyzed; Analyze the image to be analyzed to obtain the horizontal edge grayscale law and the vertical edge grayscale law of the image to be analyzed, and then find the starting point of each screw hole in the bone plate grayscale image based on the horizontal edge grayscale law and the vertical edge grayscale law; Analyze whether the size of the locking metal bone plate is qualified based on the starting point; Fixing the locked metal bone plate and photographing the locked metal bone plate with a high-definition camera to obtain an image of the bone plate includes the following sub-steps: Place the locking metal plate at the point to be photographed, and stabilize the locking metal plate with a stabilizer; Aim the high-definition camera at the locked metal plate, ensuring that the locked metal plate spans the image and occupies a length ratio greater than the first shot ratio of the image length; Photographing the locked metal bone plate to obtain a bone plate image; Grayscale processing is performed on the bone plate image to obtain a bone plate grayscale image, and then the bone plate grayscale image is analyzed to find the starting point of each screw hole in the bone plate grayscale image, including the following sub-steps: The bone plate image is gray-scale processed to obtain a bone plate gray-scale image, and the gray-scale value of a pixel grid in the bone plate gray-scale image is marked as a pixel gray-scale; Find the pixel grayscale that is below the first grayscale threshold and has the largest proportion, mark it as the maximum proportion grayscale, and mark the pixel grid whose pixel grayscale is equal to the maximum proportion grayscale as the main pixel grid; Find the pixel grids adjacent to the main pixel grid, mark them as the main adjacent pixel grids, find the pixel grids within the eight neighborhoods of the main adjacent pixel grids, and mark them as the adjacent neighborhood pixel grids; The adjacent neighborhood pixel grids are further analyzed to obtain the image to be analyzed.
2. A method for detecting quality of a locked metal bone plate based on machine vision according to claim 1, characterized in that: Further analysis of adjacent neighborhood pixels includes the following sub-steps: The number of subject pixel grids in the adjacent neighborhood pixel grids is counted and marked as the subject pixel number. The subject pixel ratio is obtained by dividing the subject pixel number by 8. The remaining adjacent neighborhood pixel grids are counted according to the pixel grayscale ratio and marked as the neighborhood pixel ratio. Compare the main pixel ratio with the neighboring pixel ratio. If the main pixel ratio is greater than or equal to the neighboring pixel ratio, output the main pixel signal; if the main pixel ratio is less than the neighboring pixel ratio, output the non-main pixel signal; If all the main pixel signals are output, the pixel grayscale of the corresponding main adjacent pixel grid is changed to the grayscale with the maximum proportion, and the main adjacent pixel grid is marked as the main pixel grid; After analyzing all the adjacent pixel grids of the subject, the image to be analyzed is obtained.
3. A method for detecting quality of a locked metal bone plate based on machine vision according to claim 2, characterized in that: The analysis of the image to be analyzed includes the following sub-steps: Marking pixel grids whose pixel grayscale in the image to be analyzed is less than a first grayscale threshold as metal grayscale grids, marking pixel grids whose pixel grayscale in the image to be analyzed is greater than or equal to the first grayscale threshold as blank grayscale grids, and marking blank grayscale grids adjacent to metal grayscale grids as starting grayscale grids; The metal grayscale grid whose pixel grayscale is equal to the maximum grayscale proportion is renamed as the surface grayscale grid, and the surface grayscale grid adjacent to the metal grayscale grid is marked as the starting grayscale grid; Perform lateral edge analysis on the image to be analyzed to obtain the lateral edge grayscale rule; Perform longitudinal edge analysis on the image to be analyzed to obtain the longitudinal edge grayscale rule; Based on the horizontal edge grayscale rule and the vertical edge grayscale rule, mark the starting point of each screw hole in the image to be analyzed.
4. A method for detecting quality of a locking metal bone plate based on machine vision according to claim 3, characterized in that: The lateral edge analysis of the image to be analyzed includes the following sub-steps: Taking the starting grayscale grid as the starting point, searching for a first number of metal grayscale grids in a direction toward the adjacent metal grayscale grids in the horizontal direction, marking them as a horizontal transition grayscale group, wherein the metal grayscale grids in the horizontal transition grayscale group include a horizontal transition grayscale grid and a horizontal transition peripheral grayscale grid, integrating the starting grayscale grid and the horizontal transition grayscale grids adjacent to the starting grayscale grid into a horizontal peripheral grayscale group, wherein the horizontal peripheral grayscale group includes a horizontal starting peripheral grayscale grid and a horizontal transition peripheral grayscale grid; The pixel grayscale of the horizontal starting peripheral grayscale grid is represented by the symbol TSPG, the pixel grayscale of the horizontal transition peripheral grayscale grid is represented by the symbol TEPG, and the pixel grayscale of the horizontal transition grayscale grid is represented by the symbol TEGG; Calculate TSPG-TEPG and mark the result as the lateral starting gradient value; calculate TEPG-TEGG and mark the result as the lateral transition gradient value; Perform the same analysis on all horizontal starting grayscale grids to obtain a number of horizontal starting gradient values and horizontal transition gradient values; A rectangular coordinate system is established with the horizontal starting gradient value as the X-axis and the horizontal transition gradient value as the Y-axis, named as a horizontal gradient scatter plot, and the horizontal starting gradient value and the corresponding horizontal transition gradient value are entered into the horizontal gradient scatter plot; Polynomial regression is performed on the transverse gradient scatter plot to obtain the grayscale law of the transverse edge.
5. The method for detecting quality of a locking metal bone plate based on machine vision according to claim 4, characterized in that: The vertical edge analysis of the image to be analyzed includes the following sub-steps: Taking the starting grayscale grid as the starting point, searching for a first number of metal grayscale grids in the direction of the longitudinally adjacent metal grayscale grids, marking them as a longitudinal transition grayscale group, wherein the metal grayscale grids in the longitudinal transition grayscale group include a longitudinal transition grayscale grid and a longitudinal transition peripheral grayscale grid, integrating the starting grayscale grid and the longitudinal transition grayscale grids adjacent to the starting grayscale grid into a longitudinal peripheral grayscale group, wherein the longitudinal peripheral grayscale group includes a longitudinal starting peripheral grayscale grid and a longitudinal transition peripheral grayscale grid; The pixel grayscale of the vertical starting peripheral grayscale grid is represented by the symbol PSPG, the pixel grayscale of the vertical transition peripheral grayscale grid is represented by the symbol PEPG, and the pixel grayscale of the vertical transition grayscale grid is represented by the symbol PEGG; Calculate PSPG-PEPG, and mark the calculation result as the longitudinal starting gradient value; Calculate PEPG-PEGG, and mark the calculation result as the longitudinal transition gradient value; Perform the same analysis on all the vertical starting grayscale grids to obtain a number of vertical starting gradient values and vertical transition gradient values; A rectangular coordinate system is established with the longitudinal starting gradient value as the X-axis and the longitudinal transition gradient value as the Y-axis, named as a longitudinal gradient scatter plot, and the longitudinal starting gradient value and the corresponding longitudinal transition gradient value are entered into the longitudinal gradient scatter plot; Perform polynomial regression on the longitudinal gradient scatter plot to obtain the longitudinal edge grayscale law.
6. A method for detecting quality of a locking metal bone plate based on machine vision according to claim 5, characterized in that: Based on the horizontal edge grayscale law and the vertical edge grayscale law, marking the starting point of each screw hole in the image to be analyzed includes the following sub-steps: Obtain the horizontal edge grayscale law and the vertical edge grayscale law, substitute the horizontal starting gradient value into the horizontal edge grayscale law, substitute the vertical starting gradient value into the vertical edge grayscale law, and mark the calculated results as the horizontal initial limit value and the vertical initial limit value respectively; The horizontal initial limit value is increased by the first error ratio and decreased by the first error ratio respectively to obtain a horizontal upper limit value and a horizontal lower limit value, and all horizontal transition gradient values corresponding to the horizontal initial gradient value are compared with the horizontal upper limit value and the horizontal lower limit value, and if the horizontal transition gradient value is greater than or equal to the horizontal lower limit value and less than or equal to the horizontal upper limit value, a horizontal transition pixel signal is output; otherwise, a horizontal edge pixel signal is output; If a horizontal transition pixel signal is output, the corresponding horizontal starting peripheral grayscale grid, horizontal transition grayscale grid and horizontal transition peripheral grayscale grid are all changed to blank pixel grids, and the pixel grayscale is changed to the second grayscale threshold value; if a horizontal edge pixel signal is output, the horizontal transition grayscale grid and the horizontal transition peripheral grayscale grid are changed to blank pixel grids, the corresponding pixel grayscale is changed to the second grayscale threshold value, and the horizontal transition grayscale grid is marked as an edge pixel grid; The longitudinal initial limit value is increased by the first error ratio and decreased by the first error ratio respectively to obtain a longitudinal upper limit value and a longitudinal lower limit value, and all longitudinal transition gradient values corresponding to the longitudinal initial gradient value are compared with the longitudinal upper limit value and the longitudinal lower limit value, and if the longitudinal transition gradient value is greater than or equal to the longitudinal lower limit value and less than or equal to the longitudinal upper limit value, a longitudinal transition pixel signal is output; otherwise, a longitudinal edge pixel signal is output; If a longitudinal transition pixel signal is output, the corresponding longitudinal starting peripheral grayscale grid, longitudinal transition grayscale grid and longitudinal transition peripheral grayscale grid are all changed to blank pixel grids, and the pixel grayscale is changed to the second grayscale threshold value; if a longitudinal edge pixel signal is output, the longitudinal transition grayscale grid and longitudinal transition peripheral grayscale grid are changed to blank pixel grids, the corresponding pixel grayscale is changed to the second grayscale threshold value, and the longitudinal transition grayscale grid is marked as an edge pixel grid; The screw holes of the locking metal bone plate are analyzed to obtain the starting point of each screw hole.
7. A method for detecting quality of a locking metal bone plate based on machine vision according to claim 6, characterized in that: The analysis of the screw holes of a locking metal bone plate includes the following sub-steps: All the remaining metal grayscale grids are marked as edge pixel grids, and the pixel grids in the image to be analyzed are numbered and named as pixel numbers, which are represented by the symbol S (n,m) Indicates, where n and m are both positive integers and (n,m) is the number of S, n is the row number, and m is the column number; Extract the circular area in the image to be analyzed, mark it as the screw hole area, find the pixel numbers of all edge pixel grids, and mark them as edge pixel numbers; For any screw hole area, the edge pixel number in the screw hole area is marked as the edge screw hole pixel number, the edge screw hole pixel number with the smallest n and the largest n are marked as the leftmost pixel number and the rightmost pixel number, and the edge screw hole pixel number with the smallest m and the largest m are marked as the topmost pixel number and the bottommost pixel number; Find the leftmost pixel number and the rightmost pixel number that are the same as m, and mark them as the left starting point and the right starting point; find the topmost pixel number and the bottommost pixel number that are the same as n, and mark them as the top starting point and the bottom starting point; All screw hole areas are analyzed to obtain starting points of different screw hole areas, wherein the starting points include a left starting point, a right starting point, an upper starting point, and a lower starting point.
8. The method for detecting quality of a locking metal bone plate based on machine vision according to claim 7, characterized in that: Analyzing whether the size of the locking metal bone plate is qualified based on the starting point includes the following sub-steps: Get the horizontal and vertical lengths of the shooting area of the high-definition camera; Calculate the horizontal length multiplied by the vertical length to get the area, and then calculate max(n)×max(m) to get the number of pixels, where max(n) is the maximum value of n and max(m) is the maximum value of m; calculate , RA is the area, PC is the number of pixels, the calculation result is marked as pixel length, the value of m from the lower starting point minus the value of m from the upper starting point is calculated, marked as the longitudinal diameter, and the value of n from the right starting point minus the value of n from the left starting point is calculated, marked as the transverse diameter; Acquiring specification information of a locking metal bone plate, wherein the specification information includes a standard diameter of a screw hole; The longitudinal diameter and the transverse diameter are added and the average value is taken to calculate the measured diameter of the screw hole. The measured diameter of the screw hole is subtracted from the standard diameter of the screw hole and the absolute value is taken to obtain the screw hole diameter difference. The screw hole diameter difference is compared with the first error threshold. If the screw hole diameter difference is less than the first error threshold, a size qualified signal is output; if the screw hole diameter difference is greater than or equal to the first error threshold, a size unqualified signal is output.
Citation Information
Patent Citations
Defect detection method, system and device for metal piece with hole and storage medium
CN113793338A
Machine-vision-based online dimensional measurement method of precise instrument
CN103292701A