An object recognition method based on edge vectorization coding
Through the edge -based coding object recognition method, the problem of complex image recognition algorithm and high hardware requirements in existing technologies have been solved, and the lightweight image recognition process is realized, and efficiency and accuracy are improved.
Patent Information
- Application Number
- CN202411507527.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-10-28
AI Technical Summary
The existing neural network-based image recognition technology has the problem that the weight files of complex algorithms are too large and the hardware computing power is required.
Using an object recognition method based on edge -based coding, the edge detection, pruning processing, line encoding, decoding, rotation, thumbnail, and re -fitting are performed through the Sobel operator, combining the image matching according to position or operation.
The lightweight requirements of image recognition are implemented, the calculation steps and calculations are reduced, the computing efficiency and recognition speed are improved, and the accuracy of identification is guaranteed.
Smart Images

Figure CN119027748B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an image processing method, and in particular to an image recognition method. Background Art
[0002] Image recognition technology is an important technology in the information age. Its purpose is to allow computers to process large amounts of physical information instead of humans. With the development of computer technology, humans have a deeper understanding of image recognition technology. The process of image recognition technology is divided into information acquisition, preprocessing, feature extraction and selection, classifier design and classification decision.
[0003] Image recognition based on neural network is an image processing method based on traditional image recognition methods and effectively integrates neural network algorithms. Among the image recognition technologies based on neural networks, the effective combination of genetic algorithm and BP neural network is the most classic model, which can be applied in many fields. For example, in the camera recognition technology used in intelligent car monitoring, when a car passes by, the detection equipment starts the image acquisition device to obtain the characteristic images of the front and back of the car. In the process of recognizing the license plate characters, two types of algorithms based on neural networks and fuzzy matching can be used. However, the current technology of neural network recognition of objects still has some shortcomings, mainly reflected in the fact that the weight files of complex algorithms are too large and the hardware computing power requirements are high. Summary of the invention
[0004] Purpose of the invention: In view of the above-mentioned prior art, an object recognition method based on edge vectorization coding is proposed to achieve the lightweight requirements of image recognition and ensure the accuracy of recognition.
[0005] Technical solution: An object recognition method based on edge vectorization coding, comprising:
[0006] Step 1: Use the Sobel operator to detect the edge of the image and prune the detected edges;
[0007] Step 2: Encode the pruned edges as line segments based on edge vectorization encoding;
[0008] Step 3: each line segment code obtained in step 2 is decoded once, each line segment code obtained by the decoding is converted into an image, and then the converted images are rotated, abbreviated, and re-fitted in sequence;
[0009] Step 4: performing secondary encoding on each line segment obtained by processing in step 3 based on the edge vectorization encoding method;
[0010] Step 5: Perform bitwise XOR operation on each line segment code obtained by secondary encoding and each model line segment code of the standard edge model, and determine whether the line segments corresponding to the two codes match according to the proportion of 0 bits in the operation result; when the majority of all line segments have matching model line segments, the edge detected in the image is considered to be the object corresponding to the standard edge model.
[0011] Furthermore, in step 1, the pruning method is to perform the following processing on each edge pixel in sequence: if there are two or more edge pixels in the D neighborhood of the current edge pixel, remove the pixels in the 4 neighborhood of the current edge pixel that are adjacent to the edge pixels in the D neighborhood.
[0012] Furthermore, step 2 includes the following steps: separately encoding the line segment between the edge starting point and the multi-node and the line segment between two multi-nodes, the line segment encoding is composed of the encoding sequence of each edge pixel on the line segment; wherein, if there are more than two edge pixels in the 8-neighborhood of an edge pixel, this edge pixel is called a multi-node; in each line segment, there are only two edge pixels in the 8-neighborhood of each edge pixel except the two endpoints;
[0013] For any line segment, the encoding of each edge pixel except the two endpoints is composed of the vector encoding of the two edge pixels pointing to it in the 8-neighborhood, and the encoding of the endpoint edge pixel is composed of the pixel coordinates and the vector encoding of the adjacent edge pixels in the line segment pointed to by the endpoint; the vector encoding corresponding to each direction of the edge pixel pointing to the 8-neighborhood is specifically: top - 000, top right - 001, right - 010, bottom right - 011, bottom - 111, bottom left - 110, left - 101, top left - 100.
[0014] Furthermore, in step 3, the method of one-stage decoding is: taking the vector code in the code of one of the endpoints of the line segment as a reference, the adjacent next edge pixel as the current edge pixel, performing a bitwise XOR operation on the upper three bits of the current edge pixel code and the reference, if the result is not 111, then performing a transposition operation on the upper three bits of the current edge pixel code and the lower three bits, and obtaining a new code as the code of the current edge pixel, and then performing a bitwise XOR operation on the upper three bits of the new code and the reference again, if the result is still not 111, it means that the line segment code is incorrect, and the decoding of the line segment is terminated; if the result of the bitwise XOR operation is 111, then taking the lower three bits of the current edge pixel code as the reference, continue to decode the adjacent next edge pixel until the other endpoint is reached.
[0015] Furthermore, in step 3, when the decoded line segment code is converted into an image, the starting endpoint of the line segment is set at the origin, that is, the coordinates of the starting endpoint of the line segment are (0,0); each pixel of the converted image is rotated according to the following formula, and the coordinates of the pixel are (xi , yi ) is converted to ( si , ti ):
[0016] ; Among them, the rotation angle ; Each pixel is abbreviated according to the following formula, and the pixel coordinates are given by ( si , ti ) is converted to ( ssi , tsi ):
[0017] ;in, M is the preset line segment reference length; the re-fitting process for each pixel is as follows: the horizontal coordinate of the pixel ssi and vertical coordinate tsi Divide them by the length of the image unit grid, and then round the results so that the fitted edge pixels are located on the unit grid points of each pixel in the image.
[0018] Furthermore, in step 5, in the result of the bitwise XOR operation, if the proportion of the number of bits of 0 is greater than threshold A, the line segments corresponding to the two codes of the operation are determined to be matched, where the value of threshold A is 85-95%; when the ratio of the number of line segments matched to the model line segments to the total number of line segments is greater than threshold B, the edge detected in the image is considered to be the object corresponding to the standard edge model, where the value of threshold B is 85-95%.
[0019] Furthermore, on the basis of step 5, the step of verifying whether the positions of the coded matching line segments are consistent is also included; when verifying the positions, position encoding is performed on each line segment of the edge and each model line segment respectively, and whether the positions of the corresponding line segments are consistent is determined based on the comparison of the position encodings; when the positions of more than 85% of the line segments matched to the model line segments are judged to be consistent, the position verification is considered successful, and the recognition result is finally output.
[0020] Beneficial effects: This method greatly strengthens the relationship between points in the image through edge vectorization coding. The obtained line segment coding has a strong ability to self-check coding errors, effectively avoiding recognition errors caused by coding errors; the detection and segmentation of line segments can be completed in the process of edge vectorization coding, effectively reducing the calculation steps; vectorization coding is essentially a kind of binary coding, and its decoding and object recognition processes mainly use basic bit operations, reducing the use of adders and multipliers, and significantly improving the machine operation efficiency; edge pruning is used to effectively reduce the use of non-essential parameters and the amount of calculation in the recognition process; each line segment coding is templated, which greatly speeds up the verification accuracy and rate. At the same time, the model weight file only contains the arrangement of the line segment coding serial numbers, which successfully greatly reduces the parameters contained in the weight file. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 is a flow chart of the method of the present invention;
[0022] Figure 2 : The images before and after edge pruning in the embodiment, wherein the left image is the image before pruning, and the right image is the image after pruning;
[0023] Figure 3 Schematic diagram of edge segmentation in an embodiment. DETAILED DESCRIPTION
[0024] The present invention will be further explained below in conjunction with the accompanying drawings.
[0025] An object recognition method based on edge vectorization coding, the specific steps are as follows:
[0026] Step 1: Get an image and use the Sobel operator to perform edge detection on the image.
[0027] Step 2: The pixel points located on the edge are called edge pixels. The points in the 8-neighborhood of the edge pixel are detected, and the vector encoding of the edge pixel pointing to each direction in the 8-neighborhood is defined as shown in the following table:
[0028] Table 1 Vector encoding of each direction in 8-neighborhood
[0029]
[0030] Step 3: Before encoding, prune the edges, that is, reduce the number of edge pixels as much as possible without affecting the edge trend. This is to reduce unnecessary calculations during encoding and avoid misjudgment during encoding.
[0031] In image processing methods, pixel adjacency refers to the adjacency property between the current pixel and the surrounding pixels, usually referred to as the neighborhood of the pixel. According to different adjacency properties, it is usually divided into 4-neighborhood, 8-neighborhood, and D-neighborhood. Taking the current pixel as the center, the four pixels above, below, left, and right are the 4-neighborhood of the current pixel; taking the current pixel as the center, the eight pixels above, below, left, right, upper left, upper right, lower left, and lower right are the 8-neighborhood of the current pixel; taking the current pixel as the center, the pixels on the four diagonals of the upper left, upper right, lower left, and lower right are the D-neighborhood of the current pixel.
[0032] When edge pruning, each edge pixel is processed in turn as follows: for the current edge pixel, if there are two or more edge pixels in the D neighborhood of the current edge pixel, remove the pixels in the 4 neighborhood of the current edge pixel that are adjacent to the edge pixels in the D neighborhood. Figure 2 As shown, taking a simple multi-node edge segment on the left as an example, edge pruning is performed on it, and the shape on the right is obtained after pruning.
[0033] Step 4: Define edge pixel encoding rules based on vector encoding.
[0034] For any edge pixel, when it is detected that there are only two edge pixels in the 8-neighborhood, the code of the edge pixel is composed of the vector code pointing to the other two edge pixels in the 8-neighborhood. For example, for an edge pixel A, there are only edge pixels above and below the right edge, so the code of edge pixel A is composed of vector codes with directions of "up" and "lower right", specifically expressed as 000011 or 011000.
[0035] When there is only one edge pixel or more than two edge pixels in the 8-neighborhood of edge pixel A, the encoding of the edge pixel needs to record the coordinates of edge pixel A, and the encoding is performed separately according to the direction when there are more than two edge pixels. For example, if the coordinates of edge pixel A in the image are (1,2) and there is only one edge pixel directly below it in the 8-neighborhood, it is encoded as #(1,2)111#.
[0036] If the coordinates of edge pixel B in the image are (10,15) and there are edge pixels in the lower left, lower right and above of its 8-neighborhood, it will be encoded in three directions respectively, namely #(10,15)110#, #(10,15)011#, and #(10,15)000#.
[0037] Step 5: According to the encoding rules defined above, encode the pruned edges as line segments.
[0038] The line segments from the edge start point to the multi-nodes and the line segments between two multi-nodes are encoded separately. That is, from one point to another point, each line segment has only two endpoints, and except for the endpoints, there are only two edge pixels in the 8-neighborhood of each edge pixel on the line segment.
[0039] by Figure 3 Take the simple multi-node edge after edge pruning as an example, the coordinates of the origin in the image are (0,0), and the simple multi-node edge is encoded. For each line segment in the figure, starting from one end point of the line segment, the 8-neighborhood of each edge pixel is scanned to obtain the encoding of the edge pixel, until the other end point of the line segment is scanned, and the line segment encoding is completed. Among them, if the endpoint is a multi-node, the encoding of the endpoint in the line segment consists of the endpoint pixel coordinates and the vector encoding of the adjacent edge pixels in the line segment. Figure 3 The edge pixels contained in each line segment are selected with a rectangular frame, and the encoding results corresponding to each line segment are as follows:
[0040] Line segment 1:
[0041] #(6,2)000#001111-000110-001111-110011-100010-101011-001100-110011-100001-110010-101010#(16,5)101#
[0042] Line segment 2:
[0043] #(14,1)010#101001-001110-000110-100111#(16,5)101#
[0044] Line segment 3:
[0045] #(16,5)001#110010-010101-101011-100010#(21,5)101#
[0046] Line segment 4:
[0047] #(21,5)011#100011-100011-100011-100010#(26,1)101#
[0048] Line segment 5:
[0049] #(12,15)011#100011-100010-101010-101011-001100-110000-111000-111000-100111-100011-100011-000011-111000-001111-010110-101010-101001-110010-101010 -101011-100111-000011-100111-000110-001111-000011-100111-000110-001111-000111-000111-000011-100011-100111-000110-101001-110010#(21,5)001#
[0050] Line segment 6:
[0051] #(1,25)011#100111-000111-000011-100011-100010-101011-100011-100011-100011-100010-101010-101011#(12,15)100#
[0052] Line segment 7:
[0053] #(6,7)110#101001-101010-100010-100011-001011-001110-001110-001110-010110-010101-010101-001101-001110-001110#(12,15)110#.
[0054] Step 6: Perform a decoding on the obtained codes of each line segment.
[0055] Take line segment 7 as an example. The edge pixel with coordinates (6,7) is selected as the starting endpoint, and the edge pixel with coordinates (12,15) is selected as the ending endpoint. The vector code in the starting endpoint code is used as the reference, and the next edge pixel is used as the current edge pixel. The upper three bits of the current edge pixel code are bitwise XORed with the reference. If the result is not 111, the upper three bits of the current edge pixel code are transposed with the lower three bits, and the new code is used as the code of the current edge pixel. The upper three bits of the new code are bitwise XORed with the reference again. If the result is still not 111, it means that the line segment code is incorrect, and the decoding of the line segment is terminated. If the result of the bitwise XOR operation is 111, the lower three bits of the current edge pixel code are used as the reference to continue decoding the next adjacent edge pixel until the ending endpoint is reached. After one decoding, the code of line segment 7 is updated as follows:
[0056] #(6,7)110#001101-010101-010100-011100-011001-110001-110001-110001-110010-101010-101010-101010-110001-110001#(12,15)110#.
[0057] Step 7: For each line segment, perform image conversion on the decoded code, that is, convert the decoded line segment code into an image in a region. The starting endpoint is set as the origin, that is, the coordinate is (0,0), the new coordinate of the ending endpoint is the original ending endpoint coordinate minus the original starting endpoint coordinate, and the new coordinates of all edge pixels in the line segment are calculated ( xi , yi ).
[0058] Step 8: With the origin as the center, perform coordinate rotation processing on each edge pixel in the new line segment obtained in step 7, so that the coordinates of each edge pixel on the new line segment are ( xi , yi ) is converted to ( si , ti ), the conversion formula is as follows:
[0059]
[0060] The rotation angle .
[0061] Step 9: Perform abbreviated processing on the rotated line segment so that the coordinates of each edge pixel are ( si , ti ) is converted to ( ssi , tsi ), the abbreviated formula is as follows:
[0062]
[0063] in, M is the preset line segment base length, and the reduction ratio is M / √( xi 2 + yi 2 ).
[0064] Step 10: Refit the edge pixels of the new line segments obtained by abbreviating so that the fitted edge pixels are located on the unit grid points of each pixel in the image, that is, the new coordinates of the fitted edge pixels are integers. Then, according to steps 3 to 5, the new fitted edge pixels are re-encoded, and finally all line segments will have the following encoding format: #(0,0)xxx#xxxxxx-xxxxxx-...-xxxxxx-xxxxxx#( M ,0)xxx#.
[0065] The fitting process is as follows: for each edge pixel of the new line segment obtained in step 9, its horizontal coordinate ssi and vertical coordinate tsi Divide them by the length of the unit grid, and then round the results so that the coordinate points of the new line segments are aligned with the grid points.
[0066] Step 11: For the object to be identified through the image, a corresponding standard edge model is pre-set. The standard edge model is also composed of a number of model segments, and each model segment is numbered and sorted in a certain order.
[0067] Among them, the standard edge model can be obtained by learning a neural network, or by using a traditional image processing method on a standard image. The specific method is not described here. The sorting method of each model segment can be sorted from the lower left corner to the upper right corner of the image according to the position of each segment in the image, or counterclockwise according to the position of the segment, or according to other executable rules. When sorting, each model segment is marked with a digital serial number that increases from small to large. Figure 3 One of the rules is cited, that is, the line segment located at the lower left of the image is taken as the starting line segment, its serial number is set to 1, and the remaining line segments are numbered in sequence in a counterclockwise order.
[0068] Step 12: Perform bitwise XOR operations on each line segment code obtained by the secondary encoding and each model line segment code of the standard edge model in turn. If the proportion of 0 bits in the result of a certain bitwise XOR operation is greater than 85-95% of the total number of bits, the line segment corresponding to the secondary encoding is considered to match the model line segment corresponding to the operation, and the serial number of the model line segment is recorded. If a line segment code obtained by the operation matches multiple model line segment codes, the model line segment corresponding to the maximum proportion of 0 bits in the bitwise XOR operation result is taken as the model line segment corresponding to the encoding line segment.
[0069] According to the above method, when the majority of the secondary codes can find matching model line segment codes, the edge detected in the image can be considered to be the object corresponding to the standard edge model, and the recognition result can be output. Among them, the majority means that the total number of line segments accounts for more than 85%-95%.
[0070] Step 13: Further, in order to improve the recognition accuracy, a step of checking the position of the matching line segments is also included based on step 12. When the positions of most of the secondary encoded line segments with matching model line segments are consistent with the positions of the model line segments in the image, it is considered that the position check has passed, and the recognition result is finally output; if it does not meet the requirements, it is considered that the corresponding object has not been recognized.
[0071] Method 1 for determining whether the positions of the majority of line segments are consistent with the positions of the model line segments in the figure: number and sort the line segments after the secondary encoding according to the same rules as in step 11; among all the successfully matched line segments, if the sequence numbers of the line segments in the secondary encoding are consistent with the sequence numbers of the model line segments in the matched standard edge model, and the number of consistent lines accounts for more than 85%-95% of the total number of all successfully matched line segments, the position verification is considered successful.
[0072] Method 2 for determining whether the positions of most line segments are consistent with the positions of model line segments in the figure: first, number and sort the line segments after secondary coding according to the same rules as in step 11; for each secondary coding, delete the coding that has not been successfully matched, and the line segment that is ranked after the deleted line segment is ranked one higher in sequence, thereby obtaining a new sequence of the remaining line segments after deleting several line segments; compare the sequence number of each line segment in the newly formed sequence with the sequence number of the matching line segment in the standard edge model, and if the difference in the sequence numbers is within 3, it is considered that this line segment has achieved a final match with the model line segment; when the proportion of the number of line segments that have achieved a final match in the new sequence accounts for more than 85-95% of the total number of line segments, it is considered that the position verification is successful.
[0073] When the method of the present invention is used to identify an object, it effectively shortens the identification steps, reduces the amount of calculation and the required computing power, and significantly improves the calculation speed and efficiency. In addition, it is recommended to include a database of standard edge models of multiple objects, and match the results obtained in step 10 with each standard edge model in turn, so as to achieve the identification of multiple objects.
[0074] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. An object recognition method based on edge vectorization coding, characterized in that: include: Step 1: Use the Sobel operator to detect the edge of the image and prune the detected edges; Step 2: Encode the pruned edges as line segments based on edge vectorization encoding; Step 3: each line segment code obtained in step 2 is decoded once, each line segment code obtained by the decoding is converted into an image, and then the converted images are rotated, abbreviated, and re-fitted in sequence; Step 4: performing secondary encoding on each line segment obtained by processing in step 3 based on the edge vectorization encoding method; Step 5: For the object to be identified through the image, a corresponding standard edge model is pre-set, which is composed of a number of model line segments, and each model line segment is numbered and sorted in a certain order; each line segment code obtained by the secondary encoding is subjected to a bitwise XOR operation with each model line segment code of the standard edge model, and the line segments corresponding to the two codes of the operation are determined to match according to the proportion of the number of 0 bits in the operation result; when most of all the line segments have matching model line segments, the edge detected in the image is considered to be the object corresponding to the standard edge model; The step 2 comprises the following steps: separately encoding the line segment between the edge starting point and the multi-node and the line segment between two multi-nodes, wherein the line segment encoding is composed of the encoding sequence of each edge pixel on the line segment; wherein, if there are more than two edge pixels in the 8-neighborhood of an edge pixel, this edge pixel is called a multi-node; in each line segment, there are only two edge pixels in the 8-neighborhood of each edge pixel except the two endpoints; For any line segment, the coding of each edge pixel except the two endpoints is composed of the vector coding of the two edge pixels in the 8-neighborhood pointed to by it, and the coding of the endpoint edge pixel is composed of the pixel coordinates and the vector coding of the adjacent edge pixels in the line segment pointed to by the endpoint; the vector coding corresponding to each direction of the edge pixel pointing to the 8-neighborhood is specifically: top - 000, top right - 001, right - 010, bottom right - 011, bottom - 111, bottom left - 110, left - 101, top left - 100; In the step 3, the method of one-stage decoding is as follows: taking the vector code in the code of one of the endpoints of the line segment as a reference, the adjacent next edge pixel as the current edge pixel, performing a bitwise XOR operation on the upper three bits of the current edge pixel code and the reference, if the result is not 111, performing a transposition operation on the upper three bits of the current edge pixel code and the lower three bits, and obtaining a new code as the code of the current edge pixel, and then performing a bitwise XOR operation on the upper three bits of the new code and the reference again, if the result is still not 111, it means that the line segment code is incorrect, and the decoding of the line segment is terminated; if the result of the bitwise XOR operation is 111, taking the lower three bits of the current edge pixel code as a reference, continue to decode the adjacent next edge pixel until the other endpoint is reached; In step 3, when the decoded line segment code is converted into an image, the starting endpoint of the line segment is set at the origin, that is, the coordinates of the starting endpoint of the line segment are (0,0); each pixel of the converted image is rotated according to the following formula, and the coordinates of the pixel are ( xi , yi ) is converted to ( si , ti ): ; Among them, the rotation angle ; Each pixel is abbreviated according to the following formula, and the pixel coordinates are given by ( si , ti ) is converted to ( ssi , tsi ): ;in, M is the preset line segment reference length; the re-fitting process for each pixel is as follows: the horizontal coordinate of the pixel ssi and vertical coordinate tsi Divide them by the length of the image unit grid, and then round the results so that the fitted edge pixels are located on the unit grid points of each pixel in the image.
2. The object recognition method based on edge vectorization coding according to claim 1 is characterized in that: In step 1, the pruning method is to perform the following processing on each edge pixel in sequence: if there are two or more edge pixels in the D neighborhood of the current edge pixel, remove the pixels in the 4 neighborhood of the current edge pixel that are adjacent to the edge pixels in the D neighborhood.
3. The object recognition method based on edge vectorization coding according to claim 1 is characterized in that: In step 5, in the result of the bitwise XOR operation, if the proportion of the number of 0 bits is greater than threshold A, the line segments corresponding to the two codes of the operation are determined to be matched, where the value of threshold A is 85-95%; when the ratio of the number of line segments matched to the model line segments to the total number of line segments is greater than threshold B, the edge detected in the image is considered to be the object corresponding to the standard edge model, where the value of threshold B is 85-95%.
4. The object recognition method based on edge vectorization coding according to any one of claims 1 to 3, characterized in that: On the basis of step 5, it also includes the step of verifying whether the positions of the coded matching line segments are consistent; when verifying the positions, the positions of the edge line segments and the model line segments are respectively encoded, and whether the positions of the corresponding line segments are consistent is determined based on the comparison of the position codes; when the positions of more than 85% of the line segments matched to the model line segments are judged to be consistent, the position verification is considered successful, and the recognition result is finally output.
Citation Information
Patent Citations
Phase-grouping line extraction method based on image processing unit
CN102496136A
Method for configuring video encoding quality and transmitting video data in classified mode
CN103414900A