CN114387292B - Image edge pixel point optimization method, device and equipment - Google Patents

Image edge pixel point optimization method, device and equipment Download PDF

Info

Publication number
CN114387292B
CN114387292B CN202210298433.4A CN202210298433A CN114387292B CN 114387292 B CN114387292 B CN 114387292B CN 202210298433 A CN202210298433 A CN 202210298433A CN 114387292 B CN114387292 B CN 114387292B
Authority
CN
China
Prior art keywords
edge
image
point
points
edge pixel
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210298433.4A
Other languages
Chinese (zh)
Other versions
CN114387292A (en
Inventor
王书锋
王开义
刘忠强
王晓锋
潘守慧
韩焱云
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Research Center of Information Technology of Beijing Academy of Agriculture and Forestry Sciences
Original Assignee
Research Center of Information Technology of Beijing Academy of Agriculture and Forestry Sciences
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Research Center of Information Technology of Beijing Academy of Agriculture and Forestry Sciences filed Critical Research Center of Information Technology of Beijing Academy of Agriculture and Forestry Sciences
Priority to CN202210298433.4A priority Critical patent/CN114387292B/en
Publication of CN114387292A publication Critical patent/CN114387292A/en
Application granted granted Critical
Publication of CN114387292B publication Critical patent/CN114387292B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • G06T5/90
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20172Image enhancement details
    • G06T2207/20192Edge enhancement; Edge preservation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30204Marker
    • G06T2207/30208Marker matrix

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)

Abstract

The invention provides an image edge pixel point optimization method, device and equipment, comprising the following steps: acquiring all edge pixel points of a target image; deleting all pixels to be optimized in the edge pixels; when the pixel point to be optimized is deleted, the number of 8 connected links corresponding to any adjacent point in 8 adjacent domains corresponding to the pixel point to be optimized is unchanged, the number of 8 connected links represents the number of the 8 connected links which are not connected with each other, and the 8 connected links represent the pixel points which are connected with each other in the 8 adjacent domains. The invention realizes whether the edge points are redundantly judged according to a single judgment condition, greatly improves the optimization efficiency, realizes the optimization of the edge m path, simultaneously avoids the problem of edge shortening, and lays a good foundation for further edge repair and shortest path search application.

Description

Image edge pixel point optimization method, device and equipment
Technical Field
The invention relates to the technical field of image processing, in particular to an image edge pixel point optimization method, device and equipment.
Background
The edge in the image is one of the most essential features of the image, and the principle of image edge detection is to detect all points with large gray value variation in the image, and the points are connected to form a plurality of lines, which can be called as the edge of the image. Common edge detection algorithms include cable edge detection, laplacian edge detection, and Canny edge detection. The obtained edge image contains a large amount of redundant information, occupies a large amount of storage resources and calculation resources, and is not beneficial to feature extraction. The purpose of the graphic thinning processing is to search the skeleton of the image and remove redundant pixels on the image, so that the information content of the image is reduced on the premise of not changing the main features of the image. The good refinement algorithm needs to meet the requirements of connectivity, convergence, topology, retentivity, directionality, refinement, mesoaxiality and rapidity.
The typical refining algorithms at present comprise algorithms such as Hilditch, Morph, Zhang-Suen and Gou-Hall, and various algorithms have the problems of low speed, breakpoints, burrs, shortening, center offset, line width larger than 1 and the like to a certain extent. In the aspect of connectivity, the above algorithms are all 8 connected, m connected (mixed connected) cannot be guaranteed, and ambiguity exists. M connectivity needs to be realized in the problems of shortest path search, contour tracking and the like, otherwise, the problems of path non-uniqueness, path circulation and the like can occur.
At present, there is no technical scheme capable of solving the above technical problems, and specifically, there is no method, apparatus and device for optimizing image edge pixel points.
Disclosure of Invention
The invention provides an image edge pixel point optimization method, device and equipment, which are used for solving the technical defects that redundant information in an edge image obtained by edge detection in the prior art is too much, contains a large amount of redundant information, occupies a large amount of storage resources and calculation resources, and cannot ensure m-connectivity (mixed connectivity) due to the redundant information in the edge, so that when path search is carried out along the edge, ambiguity exists, a unique path cannot be found, and dead cycle may occur. The invention greatly improves the optimization efficiency, realizes the optimization of the edge m path, avoids the problem of edge shortening, and lays a good foundation for further application of edge repair, shortest path search and the like.
The invention provides an image edge pixel point optimization method, which comprises the following steps:
acquiring all edge pixel points of a target image;
deleting all pixels to be optimized in the edge pixels;
when the pixel point to be optimized is deleted, the number of 8 connected links corresponding to any adjacent point in 8 adjacent domains corresponding to the pixel point to be optimized is unchanged, the number of 8 connected links represents the number of the 8 connected links which are not connected with each other, and the 8 connected links represent the pixel points which are connected with each other in the 8 adjacent domains.
According to the image edge pixel point optimization method provided by the invention, the obtaining of all edge pixel points of the target image comprises the following steps:
performing graying processing on a target image to obtain a two-dimensional grayscale image matrix of the target image;
carrying out edge detection processing on the gray level image matrix to obtain the image edge matrix;
determining an image edge matrix with a background pixel value of 0 and an edge pixel value of 255, expanding the image edge matrix, filling rows or columns with a numerical value of 0, and taking all points in the expanded image edge matrix as edge pixel points.
According to the image edge pixel point optimization method provided by the invention, the deleting of all the pixels to be optimized in the edge pixel points comprises the following steps:
judging whether any edge pixel point simultaneously meets the D adjacent point judgment standard and the 4 adjacent point judgment standard;
under the condition of meeting, determining any edge pixel point as a pixel point to be optimized, and deleting the pixel point to be optimized;
and traversing all the edge pixel points until all the pixel points to be optimized in all the edge pixel points are deleted.
According to the method for optimizing the image edge pixel point provided by the invention, the step of judging whether the edge pixel point simultaneously meets the D adjacent point judgment standard and the 4 adjacent point judgment standard so as to determine whether the edge pixel point is a pixel point to be optimized comprises the following steps:
establishing a rectangular coordinate system by taking the edge pixel points as an origin, and marking 8 neighborhoods corresponding to the edge pixel points as: d8(P) = { P =x|x∈{1,2,3,4,5,6,7,8}}={P1,P2,P3,P4,P5,P6,P7,P8Wherein P1 is A [ x ]][y+1]And P2 is A [ x-1 ]][y+1]And P3 is A [ x-1 ]][y]And P4 is A [ x-1 ]][y-1]P5 is A [ x ]][y-1]And P6 is A [ x +1 ]][y-1]And P7 is A [ x +1 ]][y]And P8 is A [ x +1 ]][y+1];
Marking D adjacent points of any edge pixel point as P2, P4, P6 and P8;
at the judgment of Fx=Px+1||Px-1X ∈ {2,4,6,8}, and FxWhen the value is 1, determining that any edge pixel point meets the judgment standard of the D adjacent point;
marking 4 adjacent points of any edge pixel point as P1, P3, P5 and P7;
at the judgment of Fx=Px+2||Px-2X ∈ {1,3,5,7}, and FxAnd when the value is 1, determining that any edge pixel point meets the judgment standard of 4 adjacent points.
According to the image edge pixel point optimization method provided by the invention, before deleting all pixel points to be optimized in the edge pixel points, the method also comprises deleting isolated points, and deleting pixel points of which the adjacent point values of 8 neighborhoods corresponding to the edge pixel points are 0 as isolated points.
According to the method for optimizing the image edge pixel points, the two-dimensional gray image matrix is processed to obtain the image edge matrix with the background pixel value of 0 and the edge pixel value of 255, and the method comprises the following steps:
judging whether the two-dimensional image edge matrix meets an image edge width processing strategy or not;
if the maximum width of the pixel points is not satisfied, marking pixel points with the width of M on the outermost layer of the two-dimensional image edge matrix as iteration results, sequentially iterating layer by layer from outside to inside to obtain multiple iteration results, and taking the multiple iteration results as the image edge matrix, wherein M is more than or equal to 2.
According to the image edge pixel point optimization method provided by the invention, when or after the image edge matrix is determined, the {0,255} in the image edge matrix in the binary representation is converted into the {0,1} in the binary representation.
The invention also provides an image edge pixel point optimization device, which comprises:
an acquisition device: acquiring all edge pixel points of a target image;
a deleting device: deleting all pixels to be optimized in the edge pixels;
according to the image edge pixel point optimization device provided by the invention, the obtaining device comprises:
a processing device: performing graying processing on a target image to obtain a two-dimensional grayscale image matrix of the target image;
the determination means: determining an image edge matrix with a background pixel value of 0 and an edge pixel value of 255, expanding the image edge matrix, filling rows or columns with a numerical value of 0, and taking all points in the expanded image edge matrix as edge pixel points.
The invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the optimization method as described in any one of the above when executing the program.
The invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the optimization method as described in any one of the above.
The invention provides an image edge pixel point optimization method, device and equipment, which are used for obtaining all edge pixel points of a target image; deleting all pixels to be optimized in the edge pixels; the pixel point to be optimized is the edge pixel point, when the edge pixel point is deleted, the number of 8 connected links corresponding to any adjacent point in 8 adjacent domains corresponding to the pixel point to be optimized is not changed, the number of 8 connected links represents the number of 8 connected links which are not connected with each other, and the 8 connected links represents pixel points which are connected with each other in 8 adjacent domains.
Drawings
In order to more clearly illustrate the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a schematic flow chart of a method for optimizing image edge pixel points according to the present invention;
FIG. 2 is a schematic flow chart of acquiring all edge pixel points of a target image according to the present invention;
FIG. 3 is a schematic diagram illustrating the identification of 4 neighborhoods of edge pixels P according to the present invention;
FIG. 4 is a schematic diagram illustrating the identification of the D neighborhood of the edge pixel P according to the present invention;
FIG. 5 is a schematic diagram illustrating the identification of 8 neighborhoods of edge pixels P according to the present invention;
FIG. 6 is a schematic representation of the inter-pixel 4 connectivity provided by the present invention;
FIG. 7 is a schematic representation of the inter-pixel 8 connectivity provided by the present invention;
FIG. 8 is a schematic representation of the identification of m-connectivity between pixels provided by the present invention;
FIG. 9 is a schematic representation of the non-m-connectivity between pixels provided by the present invention;
FIG. 10 is a schematic diagram of the mark with 18 connected links after the pixel P is removed according to the present invention;
FIG. 11 is a schematic diagram of the mark with 2 connected links 8 after removing the pixel P according to the present invention;
FIG. 12 is one of the schematic diagrams of the identifier that the removal of the pixel P in the D adjacent point judgment criterion does not affect the 8-way connection number according to the present invention;
FIG. 13 is a second schematic diagram of the present invention for removing the mark whose number of 8-way junctions is not affected by the pixel P in the D-adjacent point judgment criterion;
FIG. 14 is a third schematic diagram of the identifier that the elimination of the pixel P in the D adjacent point judgment criterion does not affect the 8-way connection number according to the present invention;
FIG. 15 is a schematic diagram of the identifier according to the present invention, wherein the removal of the pixel P in the D adjacency point determination criterion affects the number of 8-way junctions;
FIG. 16 is one of the schematic diagrams of the marks provided by the present invention, in which the removal of the pixel point P in the 4-adjacent point criterion does not affect the 8-connected link number;
FIG. 17 is a second schematic diagram of the present invention, which illustrates that removing the second mark that the pixel P does not affect the 8-way connection number in the 4-way point judgment criterion;
FIG. 18 is a third schematic diagram of the mark provided by the present invention, in which the removal of the pixel point P in the 4-adjacent point criterion does not affect the 8-connected link number;
FIG. 19 is a schematic diagram of the mark of the present invention, in which the removal of the pixel point P in the 4-adjacent point judgment criterion affects the 8-connected link number;
FIG. 20 is a second schematic flowchart of an image edge pixel optimization method according to the present invention;
FIG. 21 is a schematic diagram of the identifier provided by the present invention that simultaneously satisfies the criteria for determining D neighbor points and the criteria for determining 4 neighbor points;
FIG. 22 is a schematic structural diagram of an image edge pixel optimization apparatus according to the present invention;
fig. 23 is a schematic structural diagram of an electronic device provided by the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The invention discloses an image edge pixel point optimization method, which is different from multi-condition iteration thinning methods such as zhang-suen and hilditch in the prior art based on 8 neighborhood connection conditions of edge pixel points and efficiently realizes image edge m path optimization by adopting a single-cycle single judgment condition based on the standard that whether deletion of the edge pixel points changes the connection conditions of peripheral edge pixels or not.
Fig. 1 is a schematic flow chart of an image edge pixel point optimization method provided by the present invention, as shown in fig. 1, including:
firstly, step S101 is entered to obtain all edge pixel points of a target image, where the target image is an initial image that needs to be subjected to pixel point optimization, and all edge pixel points need to be determined through graying conversion, image edge pixel point determination, and the like, and the edge pixel points are to-be-processed pixel points that can be directly subjected to pixel point optimization.
Then, step S102 is carried out, and all pixels to be optimized in the edge pixels are deleted;
when the pixel point to be optimized is deleted, the number of 8 connected links corresponding to any adjacent point in 8 adjacent domains corresponding to the pixel point to be optimized is unchanged, the number of 8 connected links represents the number of the 8 connected links which are not connected with each other, and the 8 connected links represent the pixel points which are connected with each other in the 8 adjacent domains.
Further, the 8 neighborhoods represent pixels in upper, lower, left, right and four diagonal directions adjacent to one pixel, the 8 connected connection number represents the number of the 8 connected connections which are not connected with each other, and the 8 connected connections represent pixels which are connected with each other in the 8 neighborhoods.
Further, the 8 neighborhoods represent pixels in the upper, lower, left, right, and four diagonal directions to which a pixel is adjacent, and show identification diagrams of the edge pixel P in the 4 neighborhoods, the D neighborhoods, i.e., adjacent pixels in the upper, lower, left, and right four directions of the pixel, and the 8 neighborhoods, i.e., the sum of pixels in the 4 neighborhoods and the D neighborhoods, respectively, in combination with fig. 3 to 5 of the present invention.
In such an embodiment, it is first understood that 4 connected, 8 connected and m connected are given, as in fig. 6 to 9, respectively, the identification diagrams of 4 connected, 8 connected and m connected and non-m connected are given, more specifically, in a preferred embodiment, if for pixels P and q with a value of 255, if q is in the 4 neighborhood of pixel point P, then these two pixels are said to be 4 connected, correspondingly, for pixels P and q with a value of 255, if q is in the 8 neighborhood of pixel point P, then these two pixels are said to be 8 connected, correspondingly, for pixels P and q with a value of 255, if q is in the 4 neighborhood of pixel point P or q is in the D neighborhood of pixel point P, and the intersection of the 4 neighborhood of pixel point P and the 4 neighborhood of pixel point q is empty (there is no pixel with a value of 255), then these two pixels are said to be m connected, that is, a mixed connection of 4 connected and D connected, i.e. there is only one path between p and q.
Further, the present invention aims to realize m connectivity, and in order to realize m connectivity, it is necessary to determine whether deletion of an edge pixel point P affects a change in the number of 8 connectivity connections of 8 adjacent points around each of the edge pixel points. If the change of each adjacent point is not caused, the adjacent point can be deleted, and if the change is caused, the edge pixel point P cannot be deleted.
Further, the number of 8 connected links represents the number of 8 connected links that are not connected to each other, and the 8 connected links represents pixels that are connected together in the 8 neighborhoods, as shown in fig. 10 to 11, which respectively show an identification schematic diagram that 1 connected link number of 8 exists after the pixel P is removed and an identification schematic diagram that 2 connected link numbers exist after the pixel P is removed, in fig. 10, when the pixel P is removed, the number represented by a dotted line is 1 connected link number of 8, and in fig. 12, when the pixel P is removed, the number represented by a dotted line is 2 connected link numbers of 8.
Further, any one of the adjacent points may be in any direction of the upper, lower, left, right, and four opposite angles of the edge pixel point P, and then any one of the adjacent points is used as a determination basis point to determine whether the 8-way connection number has changed, so as to traverse all the adjacent points to determine whether the edge pixel point P can be deleted.
Further, the pixel points to be optimized are the pixel points to be processed, and the processing mode is preferably deletion, but in other embodiments, the pixel points may be replaced or marked, which do not affect the implementation of the specific scheme of the present invention and are not described herein.
Further, the deleting all the pixels to be optimized in the edge pixels includes: judging whether the edge pixel points simultaneously meet a D adjacent point judgment standard and a 4 adjacent point judgment standard so as to determine whether the edge pixel points are pixel points to be optimized;
deleting the pixel points to be optimized;
and traversing all the edge pixel points until all the pixel points to be optimized in all the edge pixel points are deleted.
Firstly, judging whether any edge pixel point simultaneously meets a D adjacent point judgment standard and a 4 adjacent point judgment standard, determining any edge pixel point as a pixel point to be optimized and deleting the pixel point to be optimized under the condition of meeting the judgment standards, in the embodiment, establishing a rectangular coordinate system by taking the edge pixel point as an original point, and marking an 8 neighborhood corresponding to the edge pixel point as D8(P) = { P) = P =x|x∈{1,2,3,4,5,6,7,8}}={P1,P2,P3,P4,P5,P6,P7,P8Wherein P1 is A [ x ]][y+1]And P2 is A [ x-1 ]][y+1]And P3 is A [ x-1 ]][y]And P4 is A [ x-1 ]][y-1]And P5 is A [ x ]][y-1]And P6 is A [ x +1 ]][y-1]And P7 is A [ x +1 ]][y]And P8 is A [ x +1 ]][y+1]It is to be noted that fig. 3 to 19 are all labels of the technical solution of the present invention established in a frame of a rectangular coordinate system, and further, the direction from top to bottom is the X-axis direction, and the direction from left to right is the Y-axis direction, that is, the adjacent pixels from the edge pixel P (X, Y) along the Y-axis forward direction are set as P1, the edge pixel P (X, Y) is taken as the center of a circle, and the adjacent pixels to the edge pixel P (X, Y) which are rotated counterclockwise by taking the connecting line of the P1 and the center of a circle as the radius are respectively P3535322,P3,P4,P5,P6,P7,P8I.e. using a rectangular coordinate system, it can also be expressed as: p1 is A [ x ]][y+1]And P2 is A [ x-1 ]][y+1]And P3 is A [ x-1 ]][y]And P4 is A [ x-1 ]][y-1]And P5 is A [ x ]][y-1]And P6 is A [ x +1 ]][y-1]And P7 is A [ x +1 ]][y]And P8 is A [ x +1 ]][y+1]。
Further, if the adjacent points on the diagonal of the edge pixel point are D adjacent points, which are marked as P2, P4, P6 and P8, F isx=Px+1||Px-1X ∈ {2,4,6,8}, when FxWhen the value is 1, the judgment standard of the D adjacent point is met; if the adjacent points in the four directions of the edge pixel point are 4 adjacent points marked as P1, P3, P5 and P7, F isx=Px+2||Px-2X ∈ {1,3,5,7}, when FxWhen the value is 1, the judgment standard of 4 adjacent points is satisfied.
The 8 connected join number corresponding to any one adjacency point in the corresponding 8-neighborhood can be understood separately, that is, when the D adjacency point criterion is satisfied and the 4 adjacency point criterion is satisfied, the 8 connected join number corresponding to any one adjacency point in the 8-neighborhood corresponding to the edge pixel point P (x, y) is not changed. The invention can be judged by combining the following two aspects:
one isThe aspect is that the D neighbor point determination criterion: if the diagonal adjacent point of the edge pixel point P (x, y) is designated as D adjacent point, and the D adjacent points are marked as P2, P4, P6 and P8, F isx=Px+1||Px-1X ∈ {2,4,6,8}, when FxWhen the value is 1, the D adjacency point determination criterion is satisfied, in such an embodiment, as shown in fig. 12 to fig. 14, three identification schematics that the removal of the edge pixel point P in the D adjacency point determination criterion does not affect the 8-connected junction number and an identification schematic diagram that the removal of the pixel point P in the D adjacency point determination criterion affects the 8-connected junction number are respectively shown in fig. 15, where in the D adjacency point, x is an even number, and when the edge pixel point P is removed, the 8-connected junction number depends on the values of 2 4 adjacent points adjacent thereto, as shown in fig. 12 or fig. 13 or fig. 14, 1 or both 1 in P3 or P5 is 1, and the change of the edge pixel point P does not affect the 8-connected junction number of P4, and can be deleted, and as shown in fig. 15, the values of 2 adjacent points 4 adjacent thereto are all 0, that is, since both P3 and P5 are 0, the number of 1-8 connected links of P4 is decreased when the edge pixel P changes from 1 to 0, and thus the flag F cannot be deleted, that is, determinedx=Px+1||Px-1X ∈ {2,4,6,8}, when FxAnd when the value is 1, the judgment standard of the D adjacent point is met, and then the deletion can be carried out.
Another aspect is the 4 adjacency point judgment criterion: if the adjacent points of the edge pixel points P (x, y) in the up, down, left and right directions are 4 adjacent points marked as P1, P3, P5 and P7, F is obtainedx=Px+2||Px-2X ∈ {1,3,5,7}, when FxWhen the value is 1, the 4-adjacency point judgment criterion is satisfied, in such an embodiment, as shown in fig. 16 to fig. 18, three identification schematics that the removal of the edge pixel point P in the 4-adjacency point judgment criterion does not affect the 8-connected junction number and an identification schematic diagram that the removal of the edge pixel point P in the 4-adjacency point judgment criterion provided by the present invention does affect the 8-connected junction number are respectively shown in fig. 19, in the 4-adjacency point, x is an odd number, and when the edge pixel point P is removed, the 8-connected junction number depends on the values of 2 4-adjacency points adjacent to the edge pixel point P, as shown in fig. 16 or fig. 17 or fig. 18, the identification schematic diagrams are respectively shown in fig. 19As shown in fig. 18, if 1 of P1 or P5 is 1 or both are 1, then the change of the edge pixel point P does not affect the 8-connected links number of P3, and it can be deleted, and as shown in fig. 19, the values of the 2 adjacent 4 adjacent points are all 0, that is, since both P1 and P5 are 0, when the edge pixel point P changes from 1 to 0, the 1-8 connected links number of P3 is reduced, and thus it cannot be deleted, that is, it is determined that the flag F is determinedx=Px+2||Px-2X ∈ {1,3,5,7}, when FxAnd when the value is 1, the judgment standard of 4 adjacent points is met, and then the deletion can be carried out.
Further, the condition that both the D adjacency point judgment criterion and the 4 adjacency point judgment criterion are satisfied is determined by the following formula:
F=|
Figure 384543DEST_PATH_IMAGE001
1-P1(P7||P3)|&|
Figure 643486DEST_PATH_IMAGE001
2-P2(P1||P3)|&|
Figure 575977DEST_PATH_IMAGE001
3-P3(P1||P5)|&|
Figure 719514DEST_PATH_IMAGE001
4-P4(P3||P5)|&|
Figure 695429DEST_PATH_IMAGE001
5-P5(P3||P7)|&|
Figure 62956DEST_PATH_IMAGE001
6-P6(P5||P7)|&|
Figure 225953DEST_PATH_IMAGE001
7-P7(P5||P1)|&|
Figure 828973DEST_PATH_IMAGE001
8-P8(P7||P1) And l, wherein when F =1, the edge pixel point is to be used as a pixel point to be optimized.
As shown in fig. 21, fig. 21 is an identification schematic diagram of the edge pixel point P that simultaneously satisfies the D adjacency point determination criterion and the 4 adjacency point determination criterion, where 8 neighborhoods of the edge pixel point P are P1, P2, P3, P4, P5, P6, P7, and P8, where it can be seen from the diagram that when the edge pixel point P is deleted, the 8-connected connections of the P1, P3, P4, P5, and P7 will be affected, and the 8-connected connections of the P2, P6, and P8 will not be affected, and for the edge pixel point P that needs to simultaneously satisfy the D adjacency point determination criterion and the 4 adjacency point determination criterion, the edge pixel point P cannot be used as the pixel point to be optimized.
And then, deleting the pixel points to be optimized, wherein the pixel points to be optimized are image edge redundant pixel points and need to be deleted.
Finally, all the edge pixel points are traversed until all the pixel points to be optimized in all the edge pixel points are deleted, and the skilled person understands that the invention traverses all the edge pixel points and deletes the determined one or more pixel points to be optimized after the steps are completed.
Further, before deleting all the pixels to be optimized in the edge pixels, deleting isolated points, and deleting pixels with adjacent point values of 8 neighborhoods corresponding to the edge pixels being 0 as isolated points, wherein when the adjacent point values of 8 neighborhoods corresponding to the edge pixels P (x, y) being 0, the pixels are isolated pixels, that is, there is no actual meaning and visual display of the image cannot be influenced, and deleting isolated points can be executed before determining the pixels to be optimized or during determining the pixels to be optimized.
Further, the processing of the two-dimensional grayscale image matrix to obtain an image edge matrix with a background pixel value of 0 and an edge pixel value of 255 includes:
judging whether the two-dimensional gray level image matrix meets an image edge width processing strategy or not;
if the maximum width of the pixel points is not satisfied, marking pixel points with the width of M on the outermost layer of the two-dimensional gray image matrix as iteration results, sequentially iterating layer by layer from outside to inside to obtain multiple iteration results, and taking the multiple iteration results as the image edge matrix, wherein M is larger than or equal to 2.
Those skilled in the art understand that in the edge detection obtained by the Canny edge detection shown in the present invention, only the edge detection with the maximum width of 2 can be processed, and if the target image with the width less than 2 is processed, iteration is not needed; for other scenes with edge widths larger than 2, an iteration mode can be adopted, namely, the peripheral edge points are marked according to the deletion standard each time, the edge points marked by the iteration of this time are deleted uniformly at the end of each iteration, then the next layer of iteration is carried out, the iteration is promoted layer by layer from outside to inside to obtain a plurality of iteration results, the sum of all the iteration results is the image edge matrix, in other embodiments, with the continuous progress of the era and other edge detection means possibly adopted, the maximum width selection value in the iteration is not taken as a limiting basis, and can be 3,5, 10 or even higher, which is not repeated herein.
Further, after determining the image edge matrix, the {0,255} in the image edge matrix is transformed into {0,1} in the binary representation, and after determining the image edge matrix, the {0,255} in the image edge matrix is transformed into {0,1} in the binary representation for the purpose of further facilitating the logic operation, while in other embodiments, the following scheme may be implemented: upon determining the image edge matrix, {0,255} in the binarized representation of the image edge matrix is converted to {0,1} in the binarized representation, and this process is faster on the basis of convenient logic operations.
The invention provides an image edge pixel point optimization method, which adopts the basic principle that whether the deletion of a target edge point affects the respective 8-connected connection numbers of edge points in an 8-neighborhood is taken as a standard, and whether each edge point is redundant is judged one by one from top to bottom and from left to right. In the invention, 20% of the edge points are optimized, thereby saving a large amount of storage and calculation resources; the invention has strong intelligibility and greatly improves the efficiency of realizing the optimization of the edge m path.
Compared with 5-6 judgment conditions of Hilditch and Zhang-Suen algorithms in the prior art, the method has the advantages that the efficiency is greatly improved, m-connection optimization of image edge pixel points is realized under the condition of meeting the requirements of connectivity, convergence, topology, retentivity, directivity, refinement, mesoaxiality and rapidity, meanwhile, the problems of breakpoints, burrs, shortening, center offset, line width larger than 1 and the like do not occur, a large number of redundant pixel points are deleted, a large number of storage resources and calculation resources are saved, the ambiguity of path finding is eliminated, path finding local circulation is avoided, and a good foundation is laid for subsequent processing such as subsequent edge repair, edge fitting, optimal path searching and the like. The method can delete about 20% of redundant information, simultaneously reduces about 30% of the time consumption compared with the Hilditch algorithm, has good economic and social benefits in the field of image preprocessing, and has wide application prospect.
Fig. 2 is a schematic flow chart of acquiring all edge pixel points of a target image according to the present invention, as shown in fig. 2, including:
firstly, step S201 is entered, a target image is grayed to obtain a two-dimensional grayscale image matrix of the target image, the target image is determined, and the two-dimensional grayscale image matrix is determined based on image grayscale conversion, as understood by those skilled in the art, the present invention mainly aims to reduce redundant pixel points at the edge of the image, and to better highlight each pixel point, so a grayscale mode is selected for processing, but in actual operation, the present invention can also be converted into images of other modes for processing, as long as the technical scheme for distinguishing whether the pixel point of the image is 0 is the technical scheme intended to be protected by the present invention, and the grayscale mode adopted in fig. 2 shows a preferred scheme for solving the problem of distinguishing whether different pixel points have values of 0 or not.
Then, step S202 is performed to determine an image edge matrix with a background pixel value of 0 and an edge pixel value of 255, expand the image edge matrix, fill rows or columns with a value of 0, and use all points in the expanded image edge matrix as edge pixel points, the present invention preferably determines a two-dimensional matrix with a background pixel value of 0 and an edge pixel value of 255 based on CANNY algorithm, and expands the two-dimensional matrix to fill rows or columns with a value of 0, where the CANNY algorithm is CANNY edge detection algorithm, which is a common technical means in the field of image processing, and in other embodiments, Sobel operator, Laplacian operator, and the like may also be used, and further, in order to provide a processing space for traversing processing of 8 neighborhoods of edge pixel points in step S101, preferably filling rows or columns with a value of 0 before and after the two-dimensional matrix as an optimization processing scheme, to enable easier and more intuitive processing of step S101.
Further, the edge pixel points must be pixel points whose gray values of pixels are greater than 0, and step S102 is executed after all the edge pixel points are determined, while in other variations, step S102 may be executed while determining the edge pixel points, for example, step S101 may be executed for a first line of edge pixel points when a line of edge pixel points is determined and a next line is skipped, or step S101 may be executed for a specified threshold number of edge pixel points after a specified threshold number of edge pixel points are completed when a plurality of initial images are processed in batch.
Fig. 22 is a schematic structural diagram of an image edge pixel point optimization apparatus provided in the present invention, as shown in fig. 22, including:
the acquisition device 1: all edge pixel points of the target image are obtained, and the working principle of the obtaining device 1 refers to the step S101, which is not described herein again.
The deleting device 2: deleting all the pixels to be optimized in the edge pixels, and the working principle of the deleting device 2 refers to the step S102, which is not described herein again.
Further, the acquisition device 1 comprises a processing device 11: the graying processing is performed on the target image to obtain the two-dimensional grayscale image matrix of the target image, and the working principle of the processing device 11 refers to the foregoing step S201, which is not described herein again.
Further, the acquiring apparatus 1 further includes a determining apparatus 12: determining an image edge matrix with a background pixel value of 0 and an edge pixel value of 255, expanding the image edge matrix, filling rows or columns with a value of 0, and using all non-zero points in the expanded image edge matrix as edge pixel points, where the working principle of the determining device 12 refers to the foregoing step S202, and is not described herein again.
Fig. 23 illustrates a physical structure diagram of an electronic device, and as shown in fig. 23, the electronic device may include: a processor (processor)310, a communication Interface (Communications Interface)320, a memory (memory)330 and a communication bus 340, wherein the processor 310, the communication Interface 320 and the memory 330 communicate with each other via the communication bus 340. The processor 310 may call logic instructions in the memory 330 to perform a method for image edge pixel point optimization, comprising: acquiring all edge pixel points of a target image; deleting all pixels to be optimized in the edge pixels; when the pixel point to be optimized is deleted, the number of 8 connected links corresponding to any adjacent point in 8 adjacent domains corresponding to the pixel point to be optimized is unchanged, the number of 8 connected links represents the number of the 8 connected links which are not connected with each other, and the 8 connected links represent the pixel points which are connected with each other in the 8 adjacent domains.
In addition, the logic instructions in the memory 330 may be implemented in the form of software functional units and stored in a computer readable storage medium when the software functional units are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment may be implemented by software plus a necessary general hardware platform, and may also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, and not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (9)

1. An image edge pixel point optimization method is characterized by comprising the following steps:
acquiring all edge pixel points of a target image;
deleting all pixels to be optimized in the edge pixels;
when the pixel point to be optimized is deleted, the 8-connection number corresponding to any adjacent point in the 8 adjacent domains corresponding to the pixel point to be optimized is unchanged; the number of 8 connected links represents the number of 8 connected links which are not connected with each other, and the 8 connected links represents pixel points which are connected with each other in an 8-neighborhood;
the deleting all pixels to be optimized in the edge pixels includes:
judging whether any edge pixel point simultaneously meets the judgment standard of the D adjacent point and the judgment standard of the 4 adjacent point;
under the condition of meeting, determining any edge pixel point as a pixel point to be optimized, and deleting the pixel point to be optimized;
and traversing all the edge pixel points until all the pixel points to be optimized in all the edge pixel points are deleted.
2. The optimization method according to claim 1, wherein the obtaining all edge pixel points of the target image comprises:
performing graying processing on a target image to obtain a two-dimensional grayscale image matrix of the target image;
processing the two-dimensional gray image matrix to obtain an image edge matrix with a background pixel value of 0 and an edge pixel value of 255;
and expanding the image edge matrix, and taking all non-zero points in the expanded image edge matrix as edge pixel points.
3. The optimization method according to claim 1, wherein the determining whether any edge pixel point satisfies both the D adjacency point determination criterion and the 4 adjacency point determination criterion comprises:
establishing a rectangular coordinate system by taking any edge pixel point as an origin, and marking 8 neighborhoods corresponding to the edge pixel points as labels
Figure DEST_PATH_IMAGE002
Wherein P1 is A [ x ]][y+1]And P2 is A [ x-1 ]][y+1]And P3 is A [ x-1 ]][y]And P4 is A [ x-1 ]][y-1]And P5 is A [ x ]][y-1]And P6 is A [ x +1 ]][y-1]And P7 is A [ x +1 ]][y]And P8 is A [ x +1 ]][y+1];
Marking D adjacent points of any edge pixel point as P2, P4, P6 and P8;
at the moment of judging
Figure DEST_PATH_IMAGE003
X is ∈ {2,4,6,8}, and
Figure DEST_PATH_IMAGE004
when the value is 1, determining that any edge pixel point meets the judgment standard of the D adjacent point;
marking 4 adjacent points of any edge pixel point as P1, P3, P5 and P7;
at the moment of judging
Figure DEST_PATH_IMAGE005
X ∈ {1,3,5,7}, and
Figure 490261DEST_PATH_IMAGE004
and when the value is 1, determining that any edge pixel point meets the judgment standard of 4 adjacent points.
4. The optimization method according to claim 1, further comprising deleting isolated points before deleting all the pixels to be optimized in the edge pixels, and deleting pixels with adjacent point values of 0 in 8 neighborhoods corresponding to the edge pixels as isolated points.
5. The optimization method according to claim 2, wherein the processing of the two-dimensional grayscale image matrix to obtain an image edge matrix with a background pixel value of 0 and an edge pixel value of 255 comprises:
judging whether the two-dimensional gray level image matrix meets an image edge width processing strategy or not;
if the maximum width of the pixel points is not satisfied, marking pixel points with the width of M on the outermost layer of the two-dimensional gray image matrix as iteration results, sequentially iterating layer by layer from outside to inside to obtain multiple iteration results, and taking the multiple iteration results as the image edge matrix, wherein M is larger than or equal to 2.
6. The optimization method according to claim 2, characterized in that after determining the image edge matrix, {0,255} of the binarized representation in the image edge matrix is converted into {0,1} of the binarized representation.
7. An image edge pixel optimization device, comprising:
an acquisition device: acquiring all edge pixel points of a target image;
a deleting device: deleting all pixels to be optimized in the edge pixels;
the deleting all pixels to be optimized in the edge pixels includes:
judging whether any edge pixel point simultaneously meets the D adjacent point judgment standard and the 4 adjacent point judgment standard;
under the condition of meeting, determining any edge pixel point as a pixel point to be optimized, and deleting the pixel point to be optimized;
and traversing all the edge pixel points until all the pixel points to be optimized in all the edge pixel points are deleted.
8. The optimization apparatus according to claim 7, wherein the obtaining means comprises:
a processing device: performing graying processing on a target image to obtain a two-dimensional grayscale image matrix of the target image;
the determination means: determining an image edge matrix with a background pixel value of 0 and an edge pixel value of 255, expanding the image edge matrix, filling rows or columns with a numerical value of 0, and taking all points in the expanded image edge matrix as edge pixel points.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the optimization method according to any one of claims 1 to 6 when executing the program.
CN202210298433.4A 2022-03-25 2022-03-25 Image edge pixel point optimization method, device and equipment Active CN114387292B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210298433.4A CN114387292B (en) 2022-03-25 2022-03-25 Image edge pixel point optimization method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210298433.4A CN114387292B (en) 2022-03-25 2022-03-25 Image edge pixel point optimization method, device and equipment

Publications (2)

Publication Number Publication Date
CN114387292A CN114387292A (en) 2022-04-22
CN114387292B true CN114387292B (en) 2022-07-01

Family

ID=81206256

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210298433.4A Active CN114387292B (en) 2022-03-25 2022-03-25 Image edge pixel point optimization method, device and equipment

Country Status (1)

Country Link
CN (1) CN114387292B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105869122A (en) * 2015-11-24 2016-08-17 乐视致新电子科技(天津)有限公司 Image processing method and apparatus
CN107492094A (en) * 2017-07-21 2017-12-19 长安大学 A kind of unmanned plane visible detection method of high voltage line insulator
CN111784722A (en) * 2020-07-15 2020-10-16 山东派蒙机电技术有限公司 Improved Canny lane line edge detection algorithm

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4791676A (en) * 1985-09-12 1988-12-13 International Business Machines Corporation Method and means for efficiently handling boundary conditions in connected component labeling
US7983446B2 (en) * 2003-07-18 2011-07-19 Lockheed Martin Corporation Method and apparatus for automatic object identification
CN104700418A (en) * 2015-03-24 2015-06-10 江南大学 Method for estimating precise circumferences of target boundaries based on gray level information
CN113095327B (en) * 2021-03-16 2022-10-14 深圳市雄帝科技股份有限公司 Method and system for positioning optical character recognition area and storage medium thereof

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105869122A (en) * 2015-11-24 2016-08-17 乐视致新电子科技(天津)有限公司 Image processing method and apparatus
CN107492094A (en) * 2017-07-21 2017-12-19 长安大学 A kind of unmanned plane visible detection method of high voltage line insulator
CN111784722A (en) * 2020-07-15 2020-10-16 山东派蒙机电技术有限公司 Improved Canny lane line edge detection algorithm

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于视觉图像边缘特征的灌木丛或高草识别;赵一兵等;《大连理工大学学报》;20110131;第51卷(第01期);正文第127-131页 *

Also Published As

Publication number Publication date
CN114387292A (en) 2022-04-22

Similar Documents

Publication Publication Date Title
JP6705912B2 (en) Method and apparatus for recognizing character areas in an image
CN105528614B (en) A kind of recognition methods of the cartoon image space of a whole page and automatic recognition system
CN107045634B (en) Text positioning method based on maximum stable extremum region and stroke width
US7848571B2 (en) Computer-implemented method for efficient image segmentation using automated saddle-point detection
CN109697717B (en) Lining crack identification method based on image automatic search
CN108445009B (en) Crack detection method for solar cell panel
JP3026698B2 (en) Image processing method and apparatus
CN101106716A (en) A shed image division processing method
CN110060260B (en) Image processing method and system
CN111161288B (en) Image processing method and device
Jagna et al. New parallel binary image thinning algorithm
CN110570445A (en) Image segmentation method, device, terminal and readable medium
CN102663814A (en) Automatic modeling method utilizing two dimensional image to generate three dimensional geometric model
CN116222381A (en) Electrode coating size measurement method and device
CN114387292B (en) Image edge pixel point optimization method, device and equipment
Huang et al. Extraction of vectorized graphical information from scientific chart images
CN111179289A (en) Image segmentation method suitable for webpage length and width images
CN116737301A (en) Alignment method and device for layer elements
CN114511862B (en) Form identification method and device and electronic equipment
CN109785353A (en) A kind of secondary traversal binarization method, device and the storage medium of two dimensional code
Mahmoudpour et al. Superpixel-based depth map estimation using defocus blur
CN113139975B (en) Road feature-based pavement segmentation method and device
CN108109150B (en) Image segmentation method and terminal
Zhang et al. A line labeling and region growing based algorithm for binary image connected component labeling
CN116152382B (en) Digital representation conversion method and device of structural floor plan and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant