Disclosure of Invention
The invention aims to provide an object edge feature recognition and extraction method so as to obtain a real distinguishable object edge.
The invention discloses an object edge feature recognition and extraction method, which comprises the following steps:
s1: converting the captured original picture of the object into a picture with gradient amplitude;
s2: the picture with gradient amplitude value is thresholded according to the gradient direction;
s3: the pictures obtained after thresholding are mapped into a plurality of edge pictures in different directions according to the corresponding gradient directions;
s4: according to the gradient directions corresponding to the edge diagrams, the angle range of an ideal edge line is defined by taking the vertical direction of the gradient direction as the center, and meanwhile, the minimum threshold value of the length of the edge line is defined; checking pixel points in a certain range around the pixel points through bit operation; if the pixel belongs to an edge pixel and the extension length of the edge line in the ideal angle range meets the minimum length specification through bit operation detection, the pixel is still used as the edge pixel after being processed; otherwise, if the pixel belongs to the edge pixel, but the above condition is not satisfied, the pixel is not used as the edge pixel after being processed;
s5: and carrying out pooling operation on the edges serving as the edge pixel points, and finally identifying the edges of the highlighted objects.
Compared with the prior art, the invention has the following beneficial effects:
(1) Compared with the original scheme, the edge line judgment method not only depends on the amplitude value of the gradient, but also depends on the length of the edge line. When thresholding the gradient magnitude, we can directly use a smaller gradient magnitude thresholding threshold to accommodate the more blurred edges. Therefore, compared with the original CANY technical scheme, the illumination adaptation capability is stronger.
(2) According to the gradient directions corresponding to the edge diagrams, the angle range of an ideal edge line is defined by taking the vertical direction of the gradient direction as the center according to the edge diagrams in different directions, and meanwhile, the minimum threshold value of the length of the edge line is defined; checking pixel points in a certain range around the pixel points through bit operation; if the pixel belongs to an edge pixel and the extension length of the edge line in the ideal angle range meets the minimum length specification through bit operation detection, the pixel is still used as the edge pixel after being processed; on the contrary, if the pixel belongs to the edge pixel, but the above condition is not satisfied, the pixel is not used as the edge pixel after being processed, and the pooling operation is performed on the edge used as the edge pixel, so that the edge of the real distinguishable (with a certain size) object can be obtained, and the edge pixel with small and scattered and light and shade changes, such as branches, leaves, shadows on the ground, and the like, can be perfectly filtered.
(3) Compared with the CANY technical scheme, the result output by the method is not a single dot matrix of edges and non-edges. The edge lattice is classified into a plurality of edge graphs according to the gradient directions, and each edge graph corresponds to a different gradient direction. The operation is favorable for reserving more edges and information of the edge normal direction, and provides more basis for upper-layer operations such as further image contour judgment and the like.
Detailed Description
As shown in fig. 1 and 2, an object edge feature recognition and extraction method includes the following steps:
s1: converting the captured original picture of the object into a picture with gradient amplitude;
s2: the picture with gradient amplitude value is thresholded according to the gradient direction;
s3: the pictures obtained after thresholding are mapped into a plurality of edge pictures in different directions according to the corresponding gradient directions;
s4: according to the gradient directions corresponding to the edge diagrams, the angle range of an ideal edge line is defined by taking the vertical direction of the gradient direction as the center, and meanwhile, the minimum threshold value of the length of the edge line is defined; checking pixel points in a certain range around the pixel points through bit operation; if the pixel belongs to an edge pixel and the extension length of the edge line in the ideal angle range meets the minimum length specification through bit operation detection, the pixel is still used as the edge pixel after being processed; otherwise, if the pixel belongs to the edge pixel, but the above condition is not satisfied, the pixel is not used as the edge pixel after being processed;
s5: and carrying out pooling operation on the edges serving as the edge pixel points, and finally identifying the edges of the highlighted objects.
The edge line judgment of the invention not only depends on the amplitude of the gradient, but also depends on the length of the edge line. When thresholding the gradient magnitude, we can directly use a smaller gradient magnitude thresholding threshold to accommodate the more blurred edges. Therefore, compared with the original CANY technical scheme, the illumination adaptation capability is stronger.
According to the gradient directions corresponding to the edge diagrams, the angle range of an ideal edge line is defined by taking the vertical direction of the gradient direction as the center according to the edge diagrams in different directions, and meanwhile, the minimum threshold value of the length of the edge line is defined; checking pixel points in a certain range around the pixel points through bit operation; if the pixel belongs to an edge pixel and the extension length of the edge line in the ideal angle range meets the minimum length specification through bit operation detection, the pixel is still used as the edge pixel after being processed; on the contrary, if the pixel belongs to the edge pixel, but the above condition is not satisfied, the pixel is not used as the edge pixel after being processed, and the pooling operation is performed on the edge used as the edge pixel, so that the edge of the real distinguishable (with a certain size) object can be obtained, and the edge pixel with small and scattered and light and shade changes, such as branches, leaves, shadows on the ground, and the like, can be perfectly filtered.
Compared with the CANY technical scheme, the result output by the method is not a single dot matrix of edges and non-edges. The edge lattice is classified into a plurality of edge graphs according to the gradient directions, and each edge graph corresponds to a different gradient direction. The operation is favorable for reserving more edges and information of the edge normal direction, and provides more basis for upper-layer operations such as further image contour judgment and the like.
As shown in fig. 3, the captured original image of the object is converted into an image with gradient amplitude, the image with gradient amplitude is subjected to non-maximum suppression according to the gradient direction of the image, the gradient amplitude of the image is thresholded, the thresholded image is mapped into a plurality of edge images in different directions according to the corresponding gradient direction of the image, each pixel point in the edge image is described by a single binary bit, is divided into an edge pixel point and a non-edge pixel point, and then bit operation is performed, so that the operation amount is reduced, the memory access amount is reduced, the current and subsequent access cost of all DDR L2CACHE is reduced, the space occupation of each image is reduced, and the memory bandwidth problem of large-scale full-image operation is thoroughly solved.
According to the gradient direction corresponding to the edge diagram, an angle range of an ideal edge line is defined by taking a perpendicular direction of the gradient direction as a center, and meanwhile, the minimum threshold value of the length of the edge line is defined; checking pixel points in a certain range around the pixel points through bit operation; if the pixel belongs to an edge pixel and the extension length of the edge line in the ideal angle range meets the minimum length specification through bit operation detection, the pixel is still used as the edge pixel after being processed; on the contrary, if the pixel belongs to the edge pixel, but the above condition is not satisfied, the pixel is not used as the edge pixel after being processed.
For example, a single edge map needs to reject pixels with edge line lengths less than 3, as shown in table one:
the first is that the gradient direction is the horizontal direction:
list one
0
|
1[1]
|
0
|
0
|
0
|
0
|
0
|
1[1]
|
0
|
0
|
0
|
0
|
0
|
1[1]
|
0
|
1[2]
|
1[2]
|
1[2]
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1[3]
|
0
|
0
|
0 |
The length of the edge line where the pixel point of annotation [1] is positioned is 3, and the gradient direction meets the requirement, so the pixel point is reserved;
the length of the edge line where the pixel point of annotation [2] is positioned is 3, but the gradient direction does not meet the requirement, so that the pixel point is removed;
the length of the edge line where the annotation [3] pixel point is located is 1, and the annotation is directly removed.
The calculation result table two shows:
watch II
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0 |
For example, when two pixel points are located on an edge line which is not perpendicular to the gradient direction, but has an included angle between 90 degrees and 45 degrees with the gradient direction, the two pixel points need to be kept. Table three shows:
watch III
0
|
0
|
1[1]
|
0
|
0
|
1[2]
|
0
|
1[1]
|
0
|
0
|
1[2]
|
0
|
0
|
1[1]
|
0
|
1[2]
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1[3]
|
1[3]
|
1[3]
|
1[3]
|
0
|
1[3]
|
0
|
0
|
0
|
0 |
The edge lines of the two pixel points of the annotation [1] and the annotation [2] are not perpendicular to the gradient direction, but have an included angle of between 90 degrees and 45 degrees with the gradient direction, so that the two pixel points need to be reserved; the edge line of the pixel point of note [3] is longer, but the included angle between the pixel point and the gradient direction is obviously smaller than 45 degrees, and the pixel point is directly removed.
The calculation results are shown in Table IV:
table four
0
|
0
|
1
|
0
|
0
|
1
|
0
|
1
|
0
|
0
|
1
|
0
|
0
|
1
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0 |
Depending on a plurality of edge graphs, according to the gradient direction corresponding to the edge graphs, an angle range of an ideal edge line is defined by taking a perpendicular direction of the gradient direction as a center, and meanwhile, a minimum threshold value of the length of the edge line is defined; checking pixel points in a certain range around the pixel points through bit operation; if the pixel belongs to an edge pixel and the extension length of the edge line in the ideal angle range meets the minimum length specification through bit operation detection, the pixel is still used as the edge pixel after being processed; on the contrary, if the pixel belongs to the edge pixel, but the above condition is not satisfied, the pixel is not used as the edge pixel after being processed. For example, the gradient directions of the first direction edge map and the second direction edge map are similar, and the first direction edge map and the second direction edge map are combined, when the length of the edge line where the required pixel point is located is calculated to be not less than 5.
A first directional edge map, table five:
TABLE five
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
0
|
1[1]
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0 |
Second directional edge map, table six:
TABLE six
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1[1]
|
0
|
1[2]
|
0
|
0
|
0
|
1
|
0
|
1[2]
|
0
|
0
|
0
|
1
|
0
|
1[2]
|
0
|
0
|
0
|
0
|
0
|
0 |
Annotation one: although the length of the edge line where the pixel point is located in the second direction edge map is only 3, the length of the edge line where the pixel point is located in the first direction edge map is 2, and the length is 5 when the edge lines are combined together, so that the edge line is reserved.
Annotation two: although in the second direction edge map, the length of the edge line where the pixel point is located is only 3, and the first direction edge map is not complemented, so that the pixel point is eliminated.
The specific calculation idea is as follows:
we phase or get the intermediate graph between the first and second directional edge graphs, as shown in table seven:
watch seven
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
1
|
0
|
0
|
0
|
1
|
0
|
1
|
0
|
0
|
0
|
1
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
0 |
The calculation method based on a single edge graph is used for the graph, and the default gradient direction is the gradient direction 2 because we calculate the second direction edge graph.
The results are shown in Table eight:
table eight
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0 |
The original pattern of this pattern and the second directional edge pattern is then summed to obtain the pattern shown in table nine:
table nine
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0 |
This is a method of eliminating insufficiently sharp edges by combining the first direction edge map and the second direction edge map.
According to the gradient direction corresponding to the edge diagram, an angle range of an ideal edge line is defined by taking a perpendicular direction of the gradient direction as a center, and meanwhile, the minimum threshold value of the length of the edge line is defined; checking pixel points in a certain range around the pixel points through bit operation; if the pixel belongs to an edge pixel and the extension length of the edge line in the ideal angle range meets the minimum length specification through bit operation detection, the pixel is still used as the edge pixel after being processed; on the contrary, if the pixel belongs to the edge pixel, but the above condition is not satisfied, the pixel is not used as the edge pixel after being processed. Therefore, the pixel points and the surrounding pixels within a certain range are checked by bit operation; if one or a plurality of non-edge pixel points are found to divide a certain continuous edge line, and the two divided edge lines have a certain length in the extending direction, setting the non-edge pixel points as edges, and recovering the integrity of the edge lines. Table ten shows:
ten meters
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
0[1]
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0 |
Two or more edge pixels in the same direction are arranged above and below the pixel, and are perpendicular to the gradient direction, so that connection can be allowed under severe conditions. The calculation results are shown in Table eleven:
table eleven
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0 |
For both steps S4 and S5, the memory is partitioned by performing bit operation of the edge map by partitioning the memory in the memory, so as to ensure that all the read and operated areas do not exceed the size of the first cache, and complete all the calculation work in the first cache. As shown in fig. 4, assuming that the size of the first level cache is 32KB, the data is returned directly after all pixel operations are completed except for the pooling operation. Pooling would add more space to the 1/4 image size and we can handle 109 rows of pixels at a time (i.e., block size) for an image width of 1920P considering that 32 x 8 x 1024 x 4/5 is equal to (each pixel is represented by one bit) and 109 rows of pixels can be handled at a time as shown in fig. 3, 1. By the operation, data which are frequently operated do not need to be returned to DDR or even to L2-CACHE, the waiting time of memory data transmission is shortened, and the utilization rate of the CPU is greatly improved.
In addition, the SIMD function of the main control chip, such as NEON in ARM, can be utilized to process 16 bytes at a time; since each pixel is represented by a single bit, in practice, we can process 128 pixels in a single core of ARM. Meanwhile, the sequence of the instructions is highly optimized, the inter lock among the CPU instructions is reduced as much as possible, and the pipeline of the CPU is fully utilized. With this premise, extremely high parallel computing capability can be obtained even without using a GPU.
In step S5, after the pooling operation, the angle range of an ideal edge line is regulated by taking the vertical direction of the gradient direction as the center according to the gradient direction corresponding to the edge map, and meanwhile, the minimum threshold value of the length of the edge line is regulated; checking pixel points in a certain range around the pixel points through bit operation; if the pixel belongs to an edge pixel and the extension length of the edge line in the ideal angle range meets the minimum length specification through bit operation detection, the pixel is still used as the edge pixel after being processed; on the contrary, if the pixel belongs to the edge pixel, but the above condition is not satisfied, the pixel is not used as the edge pixel after being processed. Wherein the pooling operation reduces the image size by half, every four pixels by one pixel.
The pooling logic is shown in the following table:
table twelve is the image before pooling:
twelve watches
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
0 |
Table thirteen is the pooled image:
watch thirteen
The image after pooling corresponds to two pixels of the image of the previous layer. Repeatedly performing bit operation after pooling operation, and checking the pixel points and the surrounding pixel points within a certain range; if one or a plurality of non-edge pixel points are found to divide a certain continuous edge line and the two divided edge lines have a certain length in the extending direction, setting the non-edge pixel point as an edge to restore the integrity of the edge line, and
according to the gradient direction corresponding to the edge map, an angle range of an ideal edge line is defined by taking a perpendicular direction of the gradient direction as a center, and meanwhile, the minimum threshold value of the length of the edge line is defined; checking pixel points in a certain range around the pixel points through bit operation; if the pixel belongs to an edge pixel and the extension length of the edge line in the ideal angle range meets the minimum length specification through bit operation detection, the pixel is still used as the edge pixel after being processed; otherwise, if the pixel belongs to the edge pixel, but the above condition is not satisfied, the pixel is not used as the edge pixel after being processed; based on the above operations, pooling is performed again, and so on, an image pyramid is constructed. Equivalent to twice the previous round of image, strictly speaking, with the pooling of the image and edge culling, the higher the level of residual edge, the longer the essence, the more obvious the more likely it is to be our target edge. And the pooled image is greatly reduced, so that the complexity of the subsequent operation and calculation and the memory operation is reduced.
The foregoing is a further detailed description of the invention in connection with the preferred embodiments, and it is not intended that the invention be limited to the specific embodiments described. It will be apparent to those skilled in the art that several simple deductions or substitutions may be made without departing from the spirit of the invention, and these should be considered to be within the scope of the invention.