Key identification and damage detection method based on image processing
Through the key recognition and loss detection method based on image processing, the problem of insufficient accuracy and robustness of the residual recognition of key images is solved, and higher recognition accuracy and management efficiency are achieved.
Patent Information
- Application Number
- CN202411653009.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-02-25
AI Technical Summary
In the process of destructive identification of key images, the accuracy and robustness are insufficient, making it difficult to effectively identify the tiny damage and background interference of the key.
The key recognition and loss detection method based on image processing is adopted to identify and detect the damage of the key through steps such as image binarization, hole filling, acquisition of effective communication domains and rotation angle correction.
It improves the accuracy and robustness of key image damage recognition, can effectively prevent illegal copying and counterfeiting, simplify management processes, and reduce maintenance costs.
Smart Images

Figure CN119515849A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of computer vision and pattern recognition, and relates to a key recognition and damage detection method based on image processing. Background Art
[0002] The key image damage recognition algorithm is mainly based on computer vision and machine learning technology, and aims to detect and identify the damage of the key from the image. The core technologies of the algorithm include image preprocessing, feature extraction, model training and performance evaluation. With the widespread attention of this technology, people's technical requirements are getting higher and higher. In practical applications, the collected images may include uncertain noise and related background objects. The above-mentioned problems of interference from the image background may affect the detection and positioning of the key image. In addition, the shape and texture of the key are complex, and there is uncertainty in the rotation angle of the key. The problem of difficulty in characterizing image features makes it challenging to extract effective features.
[0003] Therefore, it is urgent to develop a new key image damage recognition algorithm to effectively improve the accuracy and robustness of key image damage recognition and meet the needs of practical applications. Summary of the invention
[0004] The purpose of the present invention is to provide a key recognition and damage detection method based on image processing, which solves the problem of insufficient accuracy and robustness in the key image damage recognition process in the prior art.
[0005] The technical solution adopted by the present invention is a key identification and damage detection method based on image processing, which is implemented according to the following steps: Step 1: Get the registration key dataset. Specifically including image binarization, hole filling, obtaining effective connected domain, and obtaining key image; Step 2: Get the test key image. Specifically, it includes obtaining an image with the plate removed, obtaining an image of a valid connected domain, and obtaining a test key image; Step 3: Key identification and defect detection, Specifically, it includes obtaining the registered key image, obtaining the corrected test key image, obtaining the test key image category, determining whether the test key is damaged, and completing key identification and defect detection.
[0006] The beneficial effects of the present invention include the following aspects: 1) Improve security: By identifying minor damage to the key, illegal copying and counterfeiting can be effectively prevented, protecting the user's property safety; in the management system, identifying damaged keys can detect abnormalities in a timely manner and prevent unauthorized personnel from entering sensitive areas.
[0007] 2) Improve user experience: Users can quickly detect the condition of keys through the management system, find and replace damaged keys in time, and avoid inconvenience caused by key problems. In actual application areas, automatic identification of damaged keys can simplify management processes and improve work efficiency.
[0008] 3) Reduce maintenance costs: By regularly checking the condition of the key, the key can be replaced before it is seriously damaged, avoiding maintenance costs caused by key failure. The automated recognition system can reduce human misjudgment and reduce maintenance costs caused by human factors. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 is a flow chart of a key identification and damage detection method based on image processing of the present invention; Figure 2 is the registered grayscale original image obtained by the method of the present invention ; Figure 3 is the registered screening image obtained by the method of the present invention ; Figure 4 is the registered binary image obtained by the method of the present invention ; Figure 5 is the registered filling image obtained by the method of the present invention ; Figure 6 is the registered connected domain image obtained by the method of the present invention ; Figure 7 This is the preliminary rotation result diagram obtained by the method of the present invention ; Figure 8 is the registration key image obtained by the method of the present invention ; Fig. 9 The registered special-shaped key image obtained by the method of the present invention is ; Fig.10 The test grayscale original image obtained by the method of the present invention is ; Fig.11 is the image after edge detection obtained by the method of the present invention ; Fig.12 is the effective connected domain image obtained by the method of the present invention ; Fig.13 The connected domain image of the ellipse obtained by the method of the present invention is ; Fig.14 The grayscale image obtained by the method of the present invention with background information removed is ; Fig.15 is the test binary image obtained by the method of the present invention ; Fig.16 is the test filling image obtained by the method of the present invention ; Fig.17a The image of the connected domain of the key test obtained by the method of the present invention is ; Fig.17b The cylinder key test connected domain image obtained by the method of the present invention is ; Fig.17c The large key test connected domain image obtained by the method of the present invention is ; Fig.17d The small key test connected domain image obtained by the method of the present invention is ; Fig.18a The middle key test key image obtained by the method of the present invention ; Fig.18b The cylinder key test key image obtained by the method of the present invention is ; Fig.18c The large key test key image obtained by the method of the present invention is ; Fig.18d The small key test key image obtained by the method of the present invention is ; Fig.19 The registration key image obtained by the method of the present invention is ; Fig. 20 The partial registration key image obtained by the method of the present invention is ; Fig.21 The test grayscale original image obtained in Example 5 of the method of the present invention ; Fig. 22 The test grayscale original image obtained by the method embodiment 6 of the present invention . DETAILED DESCRIPTION
[0010] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0011] Reference Figure 1The key recognition and damage detection method based on image processing of the present invention mainly includes obtaining a plate-removed image, obtaining a connected domain image, obtaining a test key image, predicting the category of the test key, and determining whether the key is damaged. The method is specifically implemented in the following steps: Step 1: Get the registration key dataset. 1.1) Image binarization, First, for the convenience of description, define the input registered color image ,in, Representing images The pixel value is a natural number from 0 to 255. r , c Represents the registered color images The height and width of the image are shown in Figure 3. The number "3" represents the red, green, and blue channels of the image. After grayscale processing, the registered grayscale image is obtained. ,like Figure 2 shown.
[0012] Secondly, select the registered grayscale image The four corners are taken The pixel value of the size is 100 grayscale pixel values. , calculate the mean of the 100 pixel values and standard deviation ; Again, define is the background grayscale pixel value, in the registered grayscale image In, it will satisfy The pixel value of the condition is set to 0 to obtain the registered filter image ,like Figure 3 As shown; Finally, the filtered image will be registered Set the non-zero pixel values in to 1 to obtain the registered binary image ,like Figure 4 As shown; 1.2) Hole filling, Use existing technology to fill holes, such as using a flood filling algorithm or a triangular mesh hole filling algorithm to obtain a registered filled image ,like Figure 5 As shown; 1.3) Obtaining the effective connected domain, First, the registered filling image is Get the connected domain, for example, use the connected region growing algorithm or the 8-connected region marking algorithm. For the convenience of description, define the acquisition The connected domain of is, and its corresponding pixel area is ; Then, if satisfy , then the connected domain is considered to be the key, confirming that it only contains The corresponding connected domain is the registered connected domain image ,like Figure 6 As shown; In this step, The values are 30000 and 200000 respectively.
[0013] 1.4) Get the key image, 1.4.1) Get color features, Based on the registered connected domain image in step 1.3) The non-zero positions in , and the registered color image in step 1.1) The red, green, and blue channel pixel values at the corresponding positions in the calculation are averaged, and are expressed as , , If both , , , then go to step 1.4.3); otherwise, go to step 1.4.2); 1.4.2) Get the universal key rotation angle, A. Initially obtain the rotation angle , A1) Registering connected domain images , rotate from 0 to 180 degrees, with an interval of 10. For the convenience of description, define the rotation angle , define the rotated binary image ; A2) For each rotated binary image , after column superposition according to formula (1), we get the row vector , the expression is: (1) Then use formula (1) to obtain the binary image Corresponding row vector The largest number in is expressed as: ; A3) According to formula (2), obtain the sequence number corresponding to the maximum value , the expression is: (2) A4) According to formula (3), obtain the initial rotation angle , the expression is: (3) B. Fine-tune the rotation angle. B1) Registering connected domain images , according to the angle Rotate to obtain a preliminary rotated image ,like Figure 7 As shown; B2) Preliminary rotation of the image , rotate from -9 to 9 degrees, with an interval of 1. For the convenience of description, define the rotation angle , define the rotated binary image ; B3) For each rotated binary image , the column coordinates of its center of gravity are ,image Horizontally mirrored image , the center of gravity is ; B4) Definition ,like ,but For images Cut off the left side Column images, for Cut off the right side Column images; otherwise, for Cut off the right side Column images, for Cut off the left side Column images; B5) Order According to formula (4), the overlap difference is obtained , the expression is: (4) B6) According to formula (5), obtain the sequence number corresponding to the minimum value , the expression is: (5) B7) Get the rotation angle , First according to Get the fine-tuned rotation angle , and then obtain the registered connected domain image according to formula (6) Rotation angle , the expression is: (6) Rotate the obtained registration key image ,like Figure 8 As shown; Step 1.4.3) Get the rotation angle of the special-shaped key, C. Initially obtain the rotation angle , C1) Registering connected domain images , rotate from 0 to 180 degrees, with an interval of 10. For the convenience of description, define the rotation angle , define the rotated binary image ; C2) For each rotated binary image , get the image Width ; C3) According to formula (7), obtain the sequence number corresponding to the maximum value , the expression is: (7) C4) According to formula (8), obtain the initial rotation angle , the expression is: (8) D. Fine-tune the rotation angle. Fine-tuning the rotation angle is the same as step B in the previous step 1.4.2), and the final rotation angle is obtained. , and then at an angle Rotate to get the registration key image ,like Fig. 9 shown.
[0014] Step 2: Get the test key image. 2.1) Get the image without the plate, First, the input image size is consistent with that in step 1.1). For the convenience of description, the input color image is defined as , grayscale image ,like Fig.10 As shown; Fig.10 In the figure, the four keys from left to right are called the middle key, the cylinder key, the large key, and the small key respectively; using existing technologies, such as the Canny algorithm, the image after edge detection is obtained ,like Fig.11 As shown; Secondly, the image after edge detection , according to the method of obtaining the connected domain in step 1.3), obtain The connected domain of is, and the corresponding number of pixels (perimeter) is ,like satisfy , then it is considered that the shape of the connected domain may be an "ellipse"; for the convenience of description, the connected domain that satisfies the above conditions is defined as , the above connected domains composed of effective connected domains ,like Fig.12 As shown; in this step, The values are 800 and 900 respectively. Much smaller than .
[0015] Again, using existing technology The coordinate positions of the connected domains are fitted with an ellipse, such as a direct calculation method, a quadratic polynomial fitting method or a standard equation fitting method. For the convenience of description, one of the connected domains is taken as an example, and after the ellipse fitting, the 5 parameters; among them, It is expressed as the axis length of the standard ellipse on the x-axis. Expressed as the axis length of the standard ellipse on the y-axis, Expressed as the coordinates of the center of the ellipse, Represents the row information of the image, Represents the column information of the image, Expressed as the rotation angle of the ellipse; for the convenience of description, define , , if both satisfy , , then the connected domain meets the characteristics of the ellipse figure, and the connected domain obtains the connected domain image of the ellipse figure ,like Fig.13 In this step, The values are 83, 157, and 5 respectively.
[0016] Then, if , define the coordinate values of the two points inside and outside the minor axis respectively: and , based on the grayscale image in step 2.1) ,exist , Take around two points Grayscale block , grayscale block The mean pixel values are ,like , the center of the large plate The expression is shown in formula (9); otherwise, the center of the large plate The expression is shown in formula (10); the short axis of the large plate is , the long axis of the large plate is ,in, are the coefficients of the minor axis and the major axis respectively, and the expressions are as follows: (9) (10) Otherwise, define the coordinate values of the two points inside and outside the minor axis: and , based on the grayscale image in step 2.1) ,exist , Take around two points Grayscale block , grayscale block The mean pixel values are ,like , the center of the large plate As shown in formula (11); otherwise, the center of the large plate As shown in formula (12); the long axis of the large plate is , the short axis of the large plate is ,in, are the coefficients of the minor axis and the major axis respectively. In this step, Take 2, Take 3, Take 2.29, the expression is as follows: (11) (12) Finally, according to the above, we can get the data information of the large plate ellipse , remove the grayscale image After removing the background information, the grayscale image with the background information removed is obtained. ,like Fig.14 shown.
[0017] 2.2) Obtaining a valid connected domain image, First, for grayscale images , calculate the mean value according to the method in step 1.1) and standard deviation , will satisfy The grayscale pixel value of the condition is set to 0, and the non-zero pixel value in the image is set to 1 to obtain the test binary image ,like Fig.15 As shown; Secondly, for the test binary image , according to the hole filling method in step 1.2), obtain the test filling image ,like Fig.16 As shown; Finally, according to the effective connected domain method in step 1.3), the test connected domain image is obtained , each target image is as follows Fig.17a , Fig.17b , Fig.17c , Fig.17d shown.
[0018] 2.3) Get the test key image, For testing connected domain images , according to the method of obtaining the key image in step 1.4), obtain the test key image , each target image is as follows Fig.18a , Fig.18b , Fig.18c , Fig.18d .
[0019] Step 3: Key identification and defect detection, 3.1) Get the registration key image, The registration key image obtained in step 1 , for the convenience of description, define Registration images ,in, Represents a natural number from 0 to 255 representing the pixel value of the image. Represented as a registered image of high, Represented as a registered image Width, The number of categories represented as registered keys; 3.2) Get the corrected test key image, For the input color image , according to step 2 to obtain Test key images , all the above parameters are consistent with the settings in step 2; 3.3) Get the test key image category, For the first Test key images For the convenience of description, Fig.18a For example, first obtain the image Width ; Next, according to step 3.1) Registration key images Width , the test key image Width and Registration key images Width Make a difference, get , the expression is: (13) Finally, get the test key image Prediction category , the expression is: (14) 3.4) Determine whether the test key is damaged. First, according to the test key image in step 3.3) Prediction category , find out the corresponding registration key image as ,like Fig.19 In this step, The values are 614 and 262 respectively.
[0020] Next, get the registration key image of high , only keep the lower 1 / 3 of the image, and find the connected domain again to obtain the partial registration key image ,like Fig. 20 Shown; Partial registration key image The number of pixels corresponding to the middle key is In this step, The value is 18128; Again, using existing methods, such as the fixed step size method or the center of gravity positioning method, find the test key image Image with partial registration key The minimum area difference ; Finally, if , then the test key image is considered is relatively complete; otherwise, it is considered a test key image There is a defect problem. In this step, The value is 0.1.
[0021] 3.5) Complete key identification and defect detection, For step 3.2) Test images , repeat steps 3.4) and 3.5) to obtain The predicted category of a test image is determined, and whether there is a defect is determined to obtain a definite result.
[0022] Example 1 Step 1: Obtain the registered key dataset, including image binarization, hole filling, obtaining valid connected domains, and obtaining key images.
[0023] Obtained registration key image , ,like Figure 8 , Fig. 9 In this step, a total of 8 registered key images are obtained.
[0024] Step 2: Obtain a test key image, specifically including obtaining an image with the plate removed, obtaining a valid connected domain image, and obtaining a test key image.
[0025] First, according to step 2.1), remove the "plate" background of the input test image to obtain a grayscale image with background information removed. ,like Fig.14 As shown; then according to step 2.2) obtain the effective connected domain image , including the four connected domain images of the middle key, cylinder key, large key and small key, as shown in Fig.17a , Fig.17b , Fig.17c , Fig.17d shown.
[0026] Again, yes Fig.17a For the image of the middle key connected domain in the image, first obtain the average red, green, and blue channel pixel values according to step 1.4.1), which are 42.5973, 76.6057, and 124.4103 respectively. If the color feature is not satisfied, proceed to step 1.4.2); then, preliminarily obtain the rotation angle is 120 degrees, then calculate the fine-tuning rotation angle The rotation angle is 4 degrees. is 124 degrees; finally, according to the rotation angle Test key image obtained ,like Fig.18a As shown, the size is 603×261.
[0027] Step 3: Key identification and defect detection, Specifically, it includes obtaining the registered key image, obtaining the corrected test key image, obtaining the test key image category, determining whether the test key is damaged, and completing key identification and defect detection.
[0028] The test key image category is the second category of the registered key image, and the registered key image size is 614×262. Finally, according to step 3.4), calculate is 0.094, which meets the conditions of this step and is considered to be a key test key image. This result is consistent with the actual situation, indicating that the method of the present invention has certain effectiveness.
[0029] Example 2 Based on the original image of Example 1, Step 1: Obtain the registered key data set, including image binarization, hole filling, obtaining valid connected domains, and obtaining key images. In this step, a total of 8 registered key images are obtained.
[0030] Step 2: Obtain a test key image, specifically including obtaining an image with the plate removed, obtaining a valid connected domain image, and obtaining a test key image.
[0031] right Fig.17b For the cylinder key connected domain image in the figure, first obtain the average red, green, and blue channel pixel values according to step 1.4.1), which are 108.3992, 108.078, and 75.2933 respectively. If the color feature is satisfied, proceed to step 1.4.3); then, preliminarily obtain the rotation angle is 40 degrees, then calculate the fine-tuning rotation angle The rotation angle is 6 degrees is 46 degrees; finally, according to the rotation angle Test key image obtained ,like Fig.18b As shown, the size is 429×675.
[0032] Step 3, key identification and defect detection, specifically includes obtaining a registered key image, obtaining a corrected test key image, obtaining a test key image category, determining whether the test key is damaged, and completing key identification and defect detection.
[0033] According to step 3.3), the test key image category is the 8th category of the registered key image, and the size of the registered key image is 344×675. According to step 3.4), calculate is 0.097, which meets the conditions of this step and considers the cylinder key test key image This result is consistent with the actual situation, indicating that the method of the present invention has certain effectiveness.
[0034] Example 3 Based on the original image of Example 1, according to the steps of the method of the present invention described above, Step 1: Obtain the registered key data set, including image binarization, hole filling, obtaining valid connected domains, and obtaining key images. In this step, a total of 8 registered key images are obtained.
[0035] Step 2: Obtain a test key image, specifically including obtaining an image with the plate removed, obtaining a valid connected domain image, and obtaining a test key image.
[0036] right Fig.17c For the large key connected domain image in the image, first obtain the average red, green, and blue channel pixel values according to step 1.4.1), which are 114.7048, 114.4157, and 98.0173 respectively. If the color feature is not satisfied, proceed to step 1.4.2); then, preliminarily obtain the rotation angle is 40 degrees, then calculate the fine-tuning rotation angle The rotation angle is 3 degrees. is 43 degrees; finally, according to the rotation angle Test key image obtained ,like Fig.18c As shown, the size is 842×548.
[0037] Step 3, key identification and defect detection, specifically includes obtaining a registered key image, obtaining a corrected test key image, obtaining a test key image category, determining whether the test key is damaged, and completing key identification and defect detection.
[0038] According to step 3.3), the test key image category is the first type of registered key image, and the size of the registered key image is 829×509. According to step 3.4), calculate is 0.088, which meets the conditions of this step and is considered a large key test key image. This result is consistent with the actual situation, indicating that the method of the present invention has certain effectiveness.
[0039] Example 4 Based on the original image of Example 1, the steps of the method of the present invention are described above.
[0040] Step 1: Obtain the registered key data set, including image binarization, hole filling, obtaining valid connected domains, and obtaining key images. In this step, a total of 8 registered key images are obtained.
[0041] Step 2: Obtain a test key image, specifically including obtaining an image with the plate removed, obtaining a valid connected domain image, and obtaining a test key image.
[0042] right Fig.17d For the small key connected domain image in the image, first obtain the average red, green, and blue channel pixel values according to step 1.4.1), which are 99.0933, 100.7700, and 90.4477 respectively. If the color feature is not satisfied, proceed to step 1.4.2); then, preliminarily obtain the rotation angle is -10 degrees, then calculate the fine-tuning rotation angle The rotation angle is -7 degrees. is -17 degrees; finally, according to the rotation angle Test key image obtained ,like Fig.18d As shown, the size is 473×185.
[0043] Step 3, key identification and defect detection, specifically includes obtaining a registered key image, obtaining a corrected test key image, obtaining a test key image category, determining whether the test key is damaged, and completing key identification and defect detection.
[0044] According to step 3.3), the test key image category is the 6th category of the registered key image, and the size of the registered key image is 444×193. According to step 3.4), calculate is 0.087, which meets the conditions of this step and is considered to be a small key test key image. This result is consistent with the actual situation, indicating that the method of the present invention has certain effectiveness.
[0045] Example 5 According to the aforementioned steps of the method of the present invention, Step 1: Obtain the registered key dataset, including image binarization, hole filling, obtaining valid connected domains, and obtaining key images. Obtained registered key images , like Figure 8 , 9 In this step, a total of 8 registered key images are obtained, representing 8 categories respectively.
[0046] Step 2: Obtain a test key image, specifically including obtaining an image with the plate removed, obtaining a valid connected domain image, and obtaining a test key image.
[0047] Step 3: key identification and defect detection, specifically including obtaining the registered key image, obtaining the corrected test key image, obtaining the test key image category, determining whether the test key is damaged, and completing key identification and defect detection. Test grayscale original image like Fig.21 As shown, according to step 3.3), the predicted categories of the four keys from left to right are 2, 7, 1, and 6 respectively; according to step 3.4), Fig.21 The four keys from left to right in the figure are all identified as complete keys. The results show that the four keys are not damaged. This result is consistent with the actual situation, indicating that the method of the present invention has certain effectiveness.
[0048] Example 6 According to the aforementioned steps of the method of the present invention.
[0049] Step 1: Obtain the registered key dataset, including image binarization, hole filling, obtaining valid connected domains, and obtaining key images. Obtained registered key images , ,like Figure 8 , 9 In this step, a total of 8 registered key images are obtained, representing 8 categories respectively.
[0050] Step 2: Obtain a test key image, specifically including obtaining an image with the plate removed, obtaining a valid connected domain image, and obtaining a test key image.
[0051] Step 3: key identification and defect detection, specifically including obtaining the registered key image, obtaining the corrected test key image, obtaining the test key image category, determining whether the test key is damaged, and completing key identification and defect detection. Test grayscale original image like Fig. 22 As shown, according to step 3.3), the predicted categories of the four keys from top to bottom are 5, 1, 7, and 2 respectively; according to step 3.4), Fig. 22 The four keys from top to bottom are judged as damaged, damaged, intact, and damaged. The results show that none of the four keys are damaged. This result is consistent with the actual situation, indicating that the method of the present invention has certain effectiveness.
Claims
1. A key identification and damage detection method based on image processing, characterized in that: Follow these steps to implement: Step 1: Get the registration key dataset. Specifically including image binarization, hole filling, obtaining effective connected domain, and obtaining key image; Step 2: Get the test key image. Specifically, it includes obtaining an image with the plate removed, obtaining an image of a valid connected domain, and obtaining a test key image; Step 3: Key identification and defect detection, Specifically, it includes obtaining the registered key image, obtaining the corrected test key image, obtaining the test key image category, determining whether the test key is damaged, and completing key identification and defect detection.
2. The key identification and damage detection method based on image processing according to claim 1, characterized in that: In step 1, the specific process is: 1.1) Image binarization, First, define the input registered color image ,in, Representing images The pixel value is a natural number from 0 to 255. r , c Represents the registered color images The height and width of the image are shown in Figure 3. The number "3" represents the red, green, and blue channels of the image. After grayscale processing, the registered grayscale image is obtained. ; Secondly, select the registered grayscale image The four corners are taken The pixel value of the size, that is, 100 grayscale pixel values are obtained , calculate the mean of the 100 pixel values and standard deviation ; Again, define is the background grayscale pixel value, in the registered grayscale image In, it will satisfy The pixel value of the condition is set to 0 to obtain the registered filter image ; Finally, the filtered image will be registered Set the non-zero pixel values in to 1 to obtain the registered binary image ; 1.2) Hole filling, Fill holes and obtain registered filled images ; 1.3) Obtaining the effective connected domain, First, register the padded image Get the connected domain and define the acquisition The connected domain of is, and its corresponding pixel area is ; Then, if satisfy , then the connected domain is considered to be the key, confirming that it only contains The corresponding connected domain is the registered connected domain image ; 1.4) Get the key image. The specific process is as follows: 1.4.1) Get color features, Based on the registered connected domain image in step 1.3) The non-zero positions in , and the registered color image in step 1.1) The red, green, and blue channel pixel values at the corresponding positions in the calculation are averaged, and are expressed as , , If both , , , then go to step 1.4.3); otherwise, go to step 1.4.2); 1.4.2) Get the universal key rotation angle, A. Initially obtain the rotation angle , A1) Registering connected domain images , rotate from 0 to 180 degrees, with an interval of 10, to define the rotation angle , define the rotated binary image ; A2) For each rotated binary image , after column superposition according to formula (1), we get the row vector , the expression is: (1) Then use formula (1) to obtain the binary image Corresponding row vector The largest number in is expressed as: ; A3) According to formula (2), obtain the sequence number corresponding to the maximum value , the expression is: (2) A4) According to formula (3), obtain the initial rotation angle , the expression is: (3) B. Fine-tune the rotation angle. B1) Registering connected domain images , according to the angle Rotate to obtain a preliminary rotated image ; B2) Preliminary rotation of the image , rotate from -9 to 9 degrees, with an interval of 1, to define the rotation angle , define the rotated binary image ; B3) For each rotated binary image , the column coordinates of its center of gravity are ,image Horizontally mirrored image , the center of gravity is ; B4) Definition ,like ,but For images Cut off the left side Column images, for Cut off the right side Column images; otherwise, for Cut off the right side Column images, for Cut off the left side Column images; B5) Order According to formula (4), the overlap difference is obtained , the expression is: (4) B6) According to formula (5), obtain the sequence number corresponding to the minimum value , the expression is: (5) B7) Get the rotation angle , First according to Get the fine-tuned rotation angle , and then obtain the registered connected domain image according to formula (6) Rotation angle , the expression is: (6) Rotate the obtained registration key image ; Step 1.4.3) Get the rotation angle of the special-shaped key, C. Initially obtain the rotation angle , C1) Registering connected domain images , rotate from 0 to 180 degrees, with an interval of 10, to define the rotation angle , define the rotated binary image ; C2) For each rotated binary image , get the image Width ; C3) According to formula (7), obtain the sequence number corresponding to the maximum value , the expression is: (7) C4) According to formula (8), obtain the initial rotation angle , the expression is: (8) D. Fine-tune the rotation angle. Fine-tuning the rotation angle is the same as step B in the previous step 1.4.2), and the final rotation angle is obtained. , and then at an angle Rotate to get the registration key image .
3. The key identification and damage detection method based on image processing according to claim 2 is characterized in that: The values are 30000 and 200000 respectively.
4. The key identification and damage detection method based on image processing according to claim 1, characterized in that: In step 2, the image without the plate is obtained. The specific process is: First, define the input color image as the same size as the input image in step 1.1). , grayscale image ; Get the image after edge detection ; Secondly, the image after edge detection , according to the method of obtaining the connected domain in step 1.3), obtain The connected domain of is, and the corresponding number of pixels is ,like satisfy , then it is considered that the shape of the connected domain may be an "ellipse"; the connected domain that satisfies the above conditions is defined as , the above connected domains composed of effective connected domains ; Again, yes The coordinate positions of the connected domains are fitted with ellipses. Taking one of the connected domains as an example, after fitting the ellipse, we obtain 5 parameters; among them, It is expressed as the axis length of the standard ellipse on the x-axis. Expressed as the axis length of the standard ellipse on the y-axis, Expressed as the coordinates of the center of the ellipse, Represents the row information of the image, Represents the column information of the image, Expressed as the rotation angle of the ellipse; definition , , if both satisfy , , then the connected domain meets the characteristics of the ellipse figure, and the connected domain obtains the connected domain image of the ellipse figure ; Then, if , define the coordinate values of the two points inside and outside the minor axis respectively: and , based on the grayscale image in step 2.1) ,exist , Take around two points Grayscale block , grayscale block The mean values of the pixels are ,like , the center of the large plate The expression is shown in formula (9); otherwise, the center of the large plate The expression is shown in formula (10); the short axis of the large plate is , the long axis of the large plate is ,in, are the coefficients of the minor axis and the major axis respectively, and the expressions are as follows: (9) (10) Otherwise, define the coordinate values of the two points inside and outside the minor axis: and , based on the grayscale image in step 2.1) ,exist , Take around two points Grayscale block , grayscale block The mean values of the pixels are ,like , the center of the large plate As shown in formula (11); otherwise, the center of the large plate As shown in formula (12); the long axis of the large plate is , the short axis of the large plate is ,in, are the coefficients of the minor axis and the major axis respectively, and the expressions are as follows: (11) (12) Finally, according to the large plate ellipse data information , remove the grayscale image After removing the background information, the grayscale image with the background information removed is obtained. .
5. The key identification and damage detection method based on image processing according to claim 4 is characterized in that: The parameter settings in step 2.1) are: The values are 800 and 900 respectively.
6. The key identification and damage detection method based on image processing according to claim 4 is characterized in that: The parameter settings in step 2.1) are: The values are 83, 157, and 5 respectively.
7. The key identification and damage detection method based on image processing according to claim 4 is characterized in that: The parameter settings in step 2.1) are: The value is 2. The value is 3. The value is 2.
29.
8. The key identification and damage detection method based on image processing according to claim 1, characterized in that: In step 2, the effective connected domain image is obtained. The specific process is: First, for grayscale images , calculate the mean value according to the method in step 1.1) and standard deviation , will satisfy The grayscale pixel value of the condition is set to 0, and the non-zero pixel value in the image is set to 1 to obtain the test binary image ; Secondly, for the test binary image , according to the hole filling method in step 1.2), obtain the test filling image ; Finally, according to the effective connected domain method in step 1.3), the test connected domain image is obtained ; Also includes getting a test key image, For testing connected domain images , according to the method of obtaining the key image in step 1.4), obtain the test key image .
9. The key identification and damage detection method based on image processing according to claim 1, characterized in that: In step 3, the specific process is: 3.1) Get the registration key image, The registration key image obtained in step 1 ,definition Registration images ,in, Represents a natural number from 0 to 255 representing the pixel value of the image. Represented as a registered image of high, Represented as a registered image Width, The number of categories represented as registered keys; 3.2) Get the test key image, For the input color image , according to step 2 to obtain Test key images , all the above parameters are consistent with the settings in step 2; 3.3) Get the test key image category, For the first Test key images , first obtain the image Width ; Next, according to step 3.1) Registration key images Width , the test key image Width and Registration key images Width Make a difference, get , the expression is: (13) Finally, get the test key image Prediction category , the expression is: (14) 3.4) Determine whether the test key is damaged. First, based on the test key image in step 3.3) Prediction category , find out the corresponding registration key image as ; Next, get the registration key image of high , only keep the lower 1 / 3 of the image, and find the connected domain again to obtain the partial registered key image ; Partially registered key image The number of pixels corresponding to the middle key is ; Again, find the test key image Image with partial registration key The minimum area difference ; Finally, if , then the test key image is considered is relatively complete; otherwise, it is considered a test key image There are defects. 3.5) Complete key identification and defect detection, For step 3.2) Test images , repeat steps 3.4) and 3.5) to obtain The predicted category of a test image is determined, and whether there is a defect is determined to obtain a definite result.
10. The key identification and damage detection method based on image processing according to claim 9, characterized in that: The parameter settings in step 3.4) are: The values are 614 and 262 respectively; The value is 18128; The value is 0.1.