CN112052909A - Pattern matching method, device, electronic equipment and storage medium - Google Patents

Pattern matching method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112052909A
CN112052909A CN202010981581.7A CN202010981581A CN112052909A CN 112052909 A CN112052909 A CN 112052909A CN 202010981581 A CN202010981581 A CN 202010981581A CN 112052909 A CN112052909 A CN 112052909A
Authority
CN
China
Prior art keywords
contour
point
points
initial
sequence
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.)
Granted
Application number
CN202010981581.7A
Other languages
Chinese (zh)
Other versions
CN112052909B (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.)
iFlytek Co Ltd
Original Assignee
iFlytek Co Ltd
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 iFlytek Co Ltd filed Critical iFlytek Co Ltd
Priority to CN202010981581.7A priority Critical patent/CN112052909B/en
Publication of CN112052909A publication Critical patent/CN112052909A/en
Application granted granted Critical
Publication of CN112052909B publication Critical patent/CN112052909B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/74Image or video pattern matching; Proximity measures in feature spaces
    • G06V10/75Organisation of the matching processes, e.g. simultaneous or sequential comparisons of image or video features; Coarse-fine approaches, e.g. multi-scale approaches; using context analysis; Selection of dictionaries
    • G06V10/752Contour matching
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Abstract

The embodiment of the invention provides a pattern matching method, a device, electronic equipment and a storage medium, wherein the method comprises the following steps: respectively extracting outlines of a first graph and a second graph to be matched to obtain a first outline of the first graph and a second outline of the second graph; determining a graph matching result obtained by comparing the first contour after plane geometric transformation is carried out on the first contour based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour; the object of the plane geometric transformation of the first contour is to minimize the distance between each first contour point and the corresponding second contour point. The pattern matching method, the device, the electronic equipment and the storage medium provided by the embodiment of the invention improve the accuracy of the pattern matching result, and simultaneously reflect the specific difference between the first outline and the second outline more accurately.

Description

Pattern matching method, device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to a method and an apparatus for pattern matching, an electronic device, and a storage medium.
Background
In the field of image processing, it is often necessary to match the graphics depicted in two images to quantify the degree of similarity or difference between the contours of the two graphics.
The current pattern matching method is generally to compare the contour moments of two patterns, so as to determine the similarity or difference of the two pattern contours. However, the quantitative result determined by the contour moment-based pattern matching method is obtained by calculating after accumulating various contour moments, does not have exact geometric meaning, cannot reflect the difference of two pattern contours, and can only reflect partial features of the patterns, so that the accuracy of the matching result is poor.
Disclosure of Invention
The embodiment of the invention provides a pattern matching method, a pattern matching device, electronic equipment and a storage medium, which are used for solving the defect of poor accuracy of a pattern matching result in the prior art.
The embodiment of the invention provides a pattern matching method, which comprises the following steps:
respectively extracting outlines of a first graph and a second graph to be matched to obtain a first outline of the first graph and a second outline of the second graph;
determining a graph matching result obtained by comparing the first contour after plane geometric transformation is carried out on the first contour based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour;
the object of the plane geometric transformation of the first contour is to minimize the distance between each first contour point and the corresponding second contour point.
According to the graph matching method of an embodiment of the present invention, determining a graph matching result obtained by performing plane geometric transformation on the first contour and comparing the first contour with each second contour in the second contour based on a correspondence between each first contour point in the first contour and each second contour point in the second contour specifically includes:
and determining the graph matching result based on the minimum distance between each first contour point and the corresponding second contour point which can be achieved after the first contour is subjected to plane geometric transformation and the coordinate variance of each second contour point.
According to the pattern matching method of an embodiment of the present invention, the extracting contours of the first pattern and the second pattern to be matched respectively to obtain a first contour of the first pattern and a second contour of the second pattern, and then the method further includes:
determining a plane geometric transformation coefficient based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour and a transformation coefficient function;
performing plane-geometric transformation on the first contour based on the plane-geometric transformation coefficient;
the transformation coefficient function is derived based on an extremum condition that needs to be satisfied when the distance between each first contour point and the corresponding second contour point is minimum.
According to the pattern matching method of one embodiment of the present invention, the correspondence between each first contour point in the first contour and each second contour point in the second contour is determined based on the following steps:
screening a plurality of candidate point sequences from the second contour based on a preset number of first contour points on the first contour;
or screening a plurality of candidate point sequences from the second contour based on the initial number of first contour points on the first contour, and expanding the first contour points on the first contour and the second contour points of each candidate point sequence by a preset multiple until the number of the second contour points contained in each candidate point sequence is equal to the preset number;
and taking the second contour point in the candidate point sequence with the maximum similarity to the preset number of first contour points as the second contour point corresponding to each first contour point.
According to the pattern matching method of an embodiment of the present invention, the screening of the plurality of candidate point sequences from the second contour specifically includes:
determining a plurality of initial point sequences corresponding to the second contour; the number of second contour points contained in each initial point sequence is the same as that of the first contour points;
if the discrete degree of the similarity between each initial point sequence and all the first contour points exceeds a preset threshold value, deleting a plurality of initial point sequences with the lowest similarity, and adding a plurality of initial point sequences until the discrete degree of the similarity between each initial point sequence and all the first contour points is smaller than the preset threshold value or reaches a preset iteration number;
and taking each initial point sequence as the candidate point sequence.
According to the pattern matching method of an embodiment of the present invention, the adding of the plurality of initial point sequences includes at least one of the following ways:
randomly extracting two initial point sequences from the rest initial point sequences, and exchanging a plurality of corresponding second contour points in the two initial point sequences with a first probability to serve as a newly added initial point sequence;
randomly extracting an initial point sequence from the rest initial point sequences, and replacing a plurality of second contour points in the extracted initial point sequence with any second contour point on the second contour by a second probability to serve as a newly added initial point sequence;
and randomly extracting an initial point sequence from the rest initial point sequences to serve as a new initial point sequence.
According to an embodiment of the present invention, the method for pattern matching, which expands a first contour point on the first contour and a second contour point of each candidate point sequence by a predetermined multiple, specifically includes:
if the product of the number of the current first contour points and a preset multiple is larger than the preset number, expanding the number of the first contour points to the preset number, randomly selecting second contour points which are not included in any candidate point sequence on the second contour, and expanding the number of the second contour points in any candidate point sequence to the preset number;
otherwise, inserting the preset multiple minus 1 new first contour point between every two adjacent first contour points, and inserting the preset multiple minus 1 new second contour point between every two adjacent second contour points of any candidate point sequence.
An embodiment of the present invention further provides a pattern matching apparatus, including:
the contour extraction unit is used for respectively extracting contours of a first graphic and a second graphic to be matched to obtain a first contour of the first graphic and a second contour of the second graphic;
the image matching unit is used for determining an image matching result obtained by comparing the first contour after plane geometric transformation is carried out on the first contour based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour;
the object of the plane geometric transformation of the first contour is to minimize the distance between each first contour point and the corresponding second contour point.
The embodiment of the present invention further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the steps of any of the above-mentioned pattern matching methods when executing the program.
Embodiments of the present invention further provide a non-transitory computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of any of the above-mentioned pattern matching methods.
According to the graph matching method, the graph matching device, the electronic equipment and the storage medium, after the first graph and the second graph to be matched are subjected to the contour extraction respectively, the graph matching result obtained by comparing the first contour after the plane geometric transformation is carried out on the first contour is determined based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour, and the difference between each first contour point and the corresponding second contour point is fully considered, so that the accuracy of the graph matching result is improved, and meanwhile, the specific difference between the first contour and the second contour is reflected more accurately.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or 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 those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
Fig. 1 is a schematic flow chart of a pattern matching method according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of a planar geometric transformation method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a planar geometric transformation provided by an embodiment of the present invention;
fig. 4 is a schematic flow chart of a method for determining a corresponding relationship of contour points according to an embodiment of the present invention;
FIG. 5 is a schematic flow chart of a candidate point sequence screening method according to an embodiment of the present invention;
FIG. 6 is a flowchart illustrating a pattern matching method according to another embodiment of the present invention;
FIG. 7 is a schematic structural diagram of a pattern matching apparatus according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, 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.
In the field of image processing, such as tasks of image recognition, image matching, etc., it is often necessary to match the graphics depicted in two images to quantify the degree of similarity or difference between the contours of the two graphics.
The current pattern matching method is generally to compare the contour moments of two patterns, so as to determine the similarity or difference of the two pattern contours. For example, the Hu matrix method calculates a two-dimensional multi-order center distance between two graphic outlines, and then defines a series of calculation ways to map the center distance to a real number as a matching result. However, contour moments such as the zero-order moment, the first-order moment, the second-order moment, the HU moment and the like are abstract mathematical concepts, matching results obtained by comprehensively calculating various contour moments are relatively abstract, exact geometric meanings are not achieved, and specific differences of two graphic contours cannot be reflected. Moreover, the contour moment can only reflect partial features of the graph, and the details of each contour point on the contour cannot be reflected, so that the accuracy of the matching result is poor.
In view of the above, the embodiment of the present invention provides a pattern matching method. Fig. 1 is a schematic flow chart of a pattern matching method according to an embodiment of the present invention, as shown in fig. 1, the method includes:
step 110, respectively extracting outlines of a first graph and a second graph to be matched to obtain a first outline of the first graph and a second outline of the second graph;
step 120, determining a graph matching result obtained by comparing the first contour after performing plane geometric transformation on the first contour based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour;
the object of the plane geometric transformation of the first contour is to minimize the distance between each first contour point and its corresponding second contour point.
Specifically, two graphs to be matched are respectively referred to as a first graph and a second graph, where "first" and "second" are only used to distinguish the two graphs and features associated with the two graphs, and any one of the two graphs is the first graph and the other graph is the second graph. And after the first graph and the second graph are subjected to image binarization, respectively extracting the outlines of the first graph and the second graph to obtain a first outline of the first graph and a second outline of the second graph. The first graph and the second graph may be regular graphs or irregular graphs, which is not specifically limited in this embodiment of the present invention.
When judging whether the two graphs are similar or not, the embodiment of the invention simulates human thinking, one graph is overlapped with the other graph as much as possible through plane geometric transformation such as scaling, rotation, translation and the like, and the outlines of the two graphs are compared, so that the specific difference between the two graphs can be determined, and a more accurate image matching result can be obtained. Here, the plane geometric transformation may specifically be at least one of translation, rotation, and scaling.
Further, after the first contour and the second contour are obtained, the embodiment of the present invention may determine a corresponding relationship between a plurality of first contour points on the first contour and a plurality of second contour points in the second contour, so as to obtain each first contour point and a corresponding second contour point thereof. The corresponding relation between the plurality of first contour points on the first contour and the plurality of second contour points in the second contour can meet the requirement that after the first contour is subjected to specific plane geometric transformation, each first contour point and the corresponding second contour point can be superposed to the maximum extent, and the distance between each first contour point and the corresponding second contour point can be minimized.
At this time, if the specific plane geometric transformation is performed on the first contour, and then the first contour points and the corresponding second contour points on the two transformed contours are compared, a pattern matching result can be obtained. The objective of the planar geometric transformation is to minimize the distance between each first contour point and its corresponding second contour point, so that the transformed first contour and second contour can be overlapped to the maximum extent. The obtained graph matching result can comprise the overall similarity degree or difference degree of the first contour and the second contour, and is used for representing the coincidence degree or the offset degree of the contours when one contour is subjected to plane geometric transformation to enable the two contours to be in the maximum coincidence state; the method may further include a degree of similarity or a degree of difference between each first contour point and its corresponding second contour point after the plane geometric transformation, which is not particularly limited in the embodiment of the present invention.
The obtained graph matching result is obtained by comparing the first contour after the plane geometric transformation, and in the process, the difference between each first contour point and the corresponding second contour point is fully considered, so that the accuracy of the graph matching result is improved. Meanwhile, the overall similarity or difference degree between the first contour and the second contour included in the pattern matching result may represent the degree of coincidence or the degree of deviation of the contours when one of the contours is subjected to plane geometric transformation so that the two contours are in a state of maximum coincidence. Therefore, the determined pattern matching result has a more definite geometric meaning than an abstract result obtained in a contour moment mode. In addition, the similarity or difference between each first contour point and the corresponding second contour point in the pattern matching result can more accurately reflect the specific difference between the first contour and the second contour.
It should be noted that, the number of the first contour points and the number of the second contour points may be set in advance according to actual requirements, where the greater the number of the first contour points and the number of the second contour points, the greater the number of contour points that can be compared, and the more accurate the obtained image matching result.
According to the method provided by the embodiment of the invention, after the first graph and the second graph to be matched are respectively subjected to contour extraction, based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour, the graphic matching result obtained by comparing the first contour after plane geometric transformation is determined, and the difference between each first contour point and the corresponding second contour point is fully considered, so that the accuracy of the graphic matching result is improved, and meanwhile, the specific difference between the first contour and the second contour is more accurately reflected.
Based on the above embodiment, step 120 specifically includes:
and determining a graph matching result based on the minimum distance between each first contour point and the corresponding second contour point which can be achieved after the first contour is subjected to plane geometric transformation and the coordinate variance of each second contour point.
Specifically, the first contour and the second contour are placed in the same plane space, and coordinates of each first contour point and each second contour point are obtained. Here, for convenience of calculation, the plane space may be set to a complex plane space, and the obtained coordinates of each first contour point and each second contour point may be complex plane coordinates. Then, the minimum distance between each first contour point and the corresponding second contour point which can be reached after the first contour is subjected to plane geometric transformation is determined.
Here, after the first contour is subjected to the plane geometric transformation, the distance between each first contour point and its corresponding second contour point may be represented as the sum of the distances in the plane space between each transformed first contour point and its corresponding second contour point, or may be represented as the average value of the distances in the plane space between each transformed first contour point and its corresponding second contour point. The average value of the distances between each first contour point and its corresponding second contour point in the planar space can be represented as follows:
Figure BDA0002687711050000081
wherein n is the number of first contour points, QkIs the complex plane coordinate, α Q, of the kth first contour pointk+ beta is the complex plane coordinate after transformation of the first contour point, PkIs the complex plane coordinate, | alpha Q, of the second contour point corresponding to the first contour pointk+β-Pk|2Is the distance of the first contour point and the corresponding second contour point in the plane space,
Figure BDA0002687711050000082
the distance average value of each first contour point and the corresponding second contour point in the plane space is obtained.
In order to determine the minimum distance between each first contour point and the corresponding second contour point, formula (1) can be directly derived according to an extreme value condition by taking the formula as an objective function, and after different plane geometric transformations are performed on the first contour on the basis of the determination of each first contour point and each second contour point, the minimum value which can be reached by the objective function is taken as the minimum distance between each first contour point and the corresponding second contour point:
Figure BDA0002687711050000091
wherein the content of the first and second substances,
Figure BDA0002687711050000092
is QkThe complex number of the conjugate of (a),
Figure BDA0002687711050000093
is PkThe complex conjugate of (a).
After simplification, the following results are obtained:
Figure BDA0002687711050000094
it can be proved that the minimum distance between each first contour point and its corresponding second contour point, which is calculated according to the formula (3), does not change with the translation transformation of the first contour or the second contour, i.e. has translation invariance. However, the minimum distance between each first contour point and the corresponding second contour point determined based on the formula (3) does not change with the rotation scaling transformation of the first contour, but is affected by the scaling factor of the second contour.
When the similarity evaluation is performed, the obtained similarity result should be unchanged no matter whether the first contour is subjected to plane geometric transformation or the second contour is subjected to plane geometric transformation. However, the pattern matching result determined based on only the minimum distance between each first contour point and the corresponding second contour point cannot satisfy the above condition. Therefore, on the basis of the minimum distance between each first contour point and the corresponding second contour point, the coordinate variance of each second contour point is combined to determine the graph matching result, so that the graph matching result is ensured not to change along with different objects of plane geometric transformation, and meanwhile, the rotational translation scaling invariance of the graph matching result is kept. Specifically, the minimum distance between each first contour point and its corresponding second contour point may be divided by the complex plane coordinate variance of each second contour point, so as to determine the pattern matching result. Can be expressed by a mathematical expression as:
Figure BDA0002687711050000101
wherein the content of the first and second substances,
Figure BDA0002687711050000102
is the complex plane coordinate variance of the second contour point.
It can be shown that the result of the above equation remains the same whether the first contour is transformed in a planar geometry or the second contour is transformed in a planar geometry.
In addition, it can also be demonstrated that,
Figure BDA0002687711050000103
and
Figure BDA0002687711050000104
are all greater than 0, and
Figure BDA0002687711050000105
Figure BDA0002687711050000106
therefore, the temperature of the molten metal is controlled,
Figure BDA0002687711050000107
Figure BDA0002687711050000108
on the other hand, in the case of a liquid,
Figure BDA0002687711050000109
thus, it is possible to provide
Figure BDA00026877110500001010
Figure BDA00026877110500001011
In summary, it is possible to obtain:
Figure BDA00026877110500001012
Figure BDA00026877110500001013
therefore, the temperature of the molten metal is controlled,
Figure BDA0002687711050000111
the degree of difference between the first and second contours can be characterized, which when 0 indicates that the two contours can be completely coincident by a plane geometric transformation, the closer they are to 1, the more dissimilar they are.
On this basis, one can obtain:
Figure BDA0002687711050000112
Figure BDA0002687711050000113
wherein, when p is closer to 0, the two contours are more dissimilar, when p is closer to 1, the two contours are more similar, and when p is 1, the two contours can be completely overlapped through plane geometric transformation.
Thus, the quotient of the minimum distance between each first contour point and its corresponding second contour point and the complex plane coordinate variance of each second contour point, for example
Figure BDA0002687711050000114
As a result of pattern matching to represent the degree of difference between the first contour and the second contour as a whole, the difference, for example ρ, between the quotient of the minimum distance between each first contour point and its corresponding second contour point and the complex plane coordinate variance of each second contour point and 1 may also be taken as the difference between ρThe graph matching result is used to represent the similarity between the first contour and the second contour as a whole, which is not specifically limited in the embodiment of the present invention.
The method provided by the embodiment of the invention determines the graph matching result based on the minimum distance between each first contour point and the corresponding second contour point after the first contour is subjected to plane geometric transformation and the coordinate variance of each second contour point, accords with the mathematical statistics rule, and can accurately reflect the difference degree or the similarity degree between the two contours.
Based on any embodiment, any contour point sequence Q on complex plane is subjected tonAfter the plane geometric transformation is carried out, the complex plane coordinates of the obtained contour point sequence can be expressed as alpha Qn+ β, wherein α and β are both complex numbers. This conclusion can be demonstrated in the following way:
suppose Q is to benConversion to Q 'by planar geometric transformation'nWherein Q isnHas a center point coordinate of oQ,Q′nHas a center point coordinate of oQ′Wherein o isQAnd oQ′Are all complex, the relative rotation angle is θ, and the scaling size is r times, the following steps can be taken:
1. will QnFirst, the translation is carried out until QnThe center point of (a) coincides with the origin, and the process expression is: qn-oQ
2. Q obtained after translationn-oQRotating, namely increasing the argument of each point by theta, and then scaling by r times, namely changing the modulus value of each point into r times, wherein the process expression is as follows: re(Qn-oQ);
3. Translating the result to make the central point and oQ′Coincide with then QnAfter conversion will be reacted with Q'nAnd (3) overlapping, wherein the process expression is as follows: re(Qn-oQ)+oQ′=reQn+(oQ′-reoQ)。
Let alpha be re,β=(oQ′-reoQ) Then the above formula can be converted into: alpha Qn+ β, concluding the evidence.
Further, it can be proved that the center point of the rotation zoom can be any contour point on the contour without the center point, and will not be described herein.
The minimum distance between each first contour point and the corresponding second contour point determined according to the formula (3) does not change with the translation transformation of the first contour or the second contour, i.e. has translation invariance. This conclusion can be demonstrated as follows:
suppose that a point sequence PnTranslating by vector v, equation (1) becomes:
Figure BDA0002687711050000121
it can be seen that this form of the formula is equivalent to the following formula:
Figure BDA0002687711050000122
wherein β ═ β - υ
It can be seen that the minimum value corresponding to this equation should be the same as the minimum value corresponding to equation (1).
Assuming that the point sequence Qn is translated by the vector v, equation (1) becomes:
Figure BDA0002687711050000123
for the same reason, the form of this formula is equivalent to the following formula:
Figure BDA0002687711050000124
wherein β' ═ β + α ν
Therefore, the minimum value corresponding to this formula should also be the same as the minimum value corresponding to formula (1).
In summary, no matter the first contour or the second contour is translated, the minimum distance between each first contour point and the corresponding second contour point will not be changed, i.e. the result obtained based on the formula (3) will not be changed.
However, the minimum distance between each first contour point and its corresponding second contour point determined based on equation (3) does not follow QnIs changed by the rotation scaling change of PnThe effect of the scaling factor of (c). This conclusion can be demonstrated as follows:
suppose pair QnPerforming translation operation until the central point O coincides with the origin, and then performing translation operation on QnPerforming a rotation scaling operation, and then QnPerforming a translation operation until the center point O returns to the original position, and the above operation can be expressed by the mathematical expression:
re(Qn-O)+O=reQn+O-reO
q in the formula (1)kBy replacing with the above formula, one can obtain:
Figure BDA0002687711050000131
it can be seen that this formula is equivalent to the following formula:
Figure BDA0002687711050000132
wherein α' ═ α re,β′=αO-αreO+β
Therefore, the minimum value corresponding to the formula should also be the same as the minimum value corresponding to the formula (1), that is, the minimum distance between each first contour point and the corresponding second contour point determined based on the formula (3) does not follow QnIs changed by the rotational scaling transform.
In addition, suppose that P is pairednPerforming a rotary scaling translation operation, i.e. P can be adjustedkSubstitution to alpha' Pk+ β'. From the above conclusions, α' PkAnd alpha' Pk+ β' is equivalent, so P can be directly substitutedkSubstitution to alpha' PkSubstituting equation (3) yields:
Figure BDA0002687711050000133
let α ═ r' eiθ′Wherein r' is PnIs a scaling factor of theta' is PnThe angle of rotation of (c). Thus, the above formula can be further converted into:
Figure BDA0002687711050000141
it can be seen that the minimum distance between each first contour point and the corresponding second contour point determined based on the formula (3) is subject to PnThe scaling factor of (c).
Based on any of the above embodiments, fig. 2 is a schematic flow chart of the planar geometric transformation method according to the embodiment of the present invention, as shown in fig. 2, after step 110, the method further includes:
step 1101, determining a plane geometric transformation coefficient based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour and a transformation coefficient function;
step 1102, performing plane geometric transformation on the first contour based on the plane geometric transformation coefficient;
the transformation coefficient function is derived based on an extremum condition that needs to be satisfied when the distance between each first contour point and the corresponding second contour point is minimum.
Specifically, in order to minimize the distance between each first contour point and its corresponding second contour point, a formula representing the distance between each first contour point and its corresponding second contour point, for example, formula (1), may be derived according to an extremum condition, and a condition that a plane geometric transformation coefficient corresponding to the plane geometric transformation of the first contour should satisfy, i.e., a transformation coefficient function, when the distance in formula (1) takes a minimum value, i.e., the distance between each first contour point and its corresponding second contour point is minimum, is determined. The extremum condition derivation is performed on equation (1), and the obtained transform coefficient function can be expressed as:
Figure BDA0002687711050000142
Figure BDA0002687711050000143
wherein alpha and beta are plane geometric transformation coefficients, and n is the number of first contour points; when Q iskAnd PkWhen the k-th first contour point and the corresponding second contour point are the k-th first contour point, the first contour can be subjected to corresponding plane geometric transformation based on alpha and beta; when Q iskAnd PkFor the kth second contour point and its corresponding first contour point, the second contour may be transformed into a corresponding plane geometry based on α and β. The plane geometry transformation can be performed by substituting alpha, beta, and the first contour into the transformation expression α Dn+ β, resulting in a transformed profile, wherein DnIs a first profile. Fig. 3 is a schematic diagram of plane-geometric transformation according to an embodiment of the present invention, as shown in fig. 3, after the plane-geometric transformation is performed on the first Contour1, the Contour1 and the Contour2 can be overlapped to the maximum extent, and based on the two contours in the maximum overlapping state, the comparison result of the two contours on the shape and the specific difference of the two contours on the shape can be visually seen.
The method provided by the embodiment of the invention determines the plane geometric transformation coefficient based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour and the transformation coefficient function, performs plane geometric transformation on the first contour based on the plane geometric transformation coefficient, and can intuitively embody the specific difference of the two contours in shape according to the shape comparison result of the two contours in the maximum coincidence state.
Based on any of the above embodiments, fig. 4 is a schematic flow chart of the method for determining a corresponding relationship between contour points provided by the embodiments of the present invention, and as shown in fig. 4, a corresponding relationship between each first contour point in a first contour and each second contour point in a second contour is determined based on the following steps:
step 410, screening a plurality of candidate point sequences from the second contour based on a preset number of first contour points on the first contour;
or, step 420, screening a plurality of candidate point sequences from the second contour based on the initial number of first contour points on the first contour, and expanding the first contour points on the first contour and the second contour points of each candidate point sequence by a preset multiple until the number of second contour points included in each candidate point sequence is equal to the preset number;
in step 430, the second contour points in the candidate point sequence with the maximum similarity to the preset number of first contour points are used as the second contour points corresponding to the first contour points.
Specifically, based on the selected plurality of first contour points, a second contour point corresponding to each first contour point needs to be determined, so that after the plane geometric transformation is performed on the first contour, each first contour point and the corresponding second contour point can be maximally overlapped. Wherein, the number of the first contour points is preset. In order to determine the corresponding relationship between each first contour point in the first contour and each second contour point in the second contour, that is, to determine the second contour point corresponding to each first contour point, a plurality of candidate point sequences may be first screened from the second contour based on the selected first contour point, so as to determine the second contour point, which can be maximally overlapped with each first contour point, in the second contour. And the number of the second contour points in each candidate point sequence is the same as that of the first contour points.
When screening candidate point sequences, selecting a preset number of second contour points from the second contour each time based on a preset number of first contour points selected in advance, and screening the candidate point sequences from the selected plurality of point sequences; or selecting an initial number of first contour points, selecting the initial number of second contour points from the second contour each time, and after a plurality of candidate point sequences are screened out, gradually expanding the first contour points on the first contour and the second contour points of each candidate point sequence by a preset multiple until the number of the second contour points included in each candidate point sequence is equal to the preset number, so as to reduce the operation amount in the screening process of each candidate point sequence and be beneficial to improving the operation efficiency of the graph matching method. Wherein the initial number is less than the preset number.
And based on the screened candidate point sequences, calculating the similarity between each candidate point sequence and a preset number of first contour points one by one, and selecting a second contour point in the candidate point sequence with the maximum similarity as a second contour point corresponding to each first contour point. It should be noted that the similarity between any candidate point sequence and the preset number of first contour points may be determined based on formula (4).
According to the method provided by the embodiment of the invention, based on the preset number of first contour points on the first contour, a plurality of candidate point sequences are screened from the second contour, or the number of the first contour points and the number of the second contour points in the candidate point sequences are gradually expanded, so that a plurality of candidate point sequences containing the preset number of second contour points are gradually screened, and then the second contour points in the candidate point sequences with the maximum similarity with the preset number of first contour points are used as the second contour points corresponding to the first contour points, so that the second contour points corresponding to the first contour points can be rapidly screened, and the efficiency of pattern matching is improved.
Based on any of the above embodiments, fig. 5 is a schematic flow chart of a candidate point sequence screening method provided by an embodiment of the present invention, and as shown in fig. 5, screening a plurality of candidate point sequences from a second contour specifically includes:
step 510, determining a plurality of initial point sequences corresponding to the second contour; and the number of the second contour points contained in each initial point sequence is the same as that of the first contour points.
In step 520, if the discrete degree of the similarity between each initial point sequence and all the first contour points exceeds a preset threshold, deleting a plurality of initial point sequences with the lowest similarity, and adding a plurality of initial point sequences until the discrete degree of the similarity between each initial point sequence and all the first contour points is less than the preset threshold or reaches a preset iteration number.
Step 530, each initial point sequence is used as a candidate point sequence.
Specifically, if a plurality of candidate point sequences are screened from the second contour based on a predetermined number of first contour points on the first contour, a predetermined number of second contour points may be randomly selected from the second contour, and the random selection operation is repeated for a predetermined number of times NpopThen, obtain NpopAn initial sequence of points. And the number of the second contour points contained in each initial point sequence is a preset number. Predetermined number of times NpopThe number of the first contour points can be preset according to the actual application scene, for example, 10 times, 15 times, etc.
If a plurality of candidate point sequences are screened from the second contour based on the initial number of first contour points on the first contour, the first contour points on the first contour and the second contour points of each candidate point sequence are expanded by a preset multiple until the number of the second contour points included in each candidate point sequence is equal to the preset number, then when the candidate point sequences are screened for the first time, the initial number of second contour points can be randomly selected from the second contour, and the random selection operation is repeated for a preset number of times NpopThen, obtain NpopAn initial point sequence; and when candidate point sequences are screened subsequently, the plurality of initial point sequences corresponding to the second contour are the results obtained by expanding each candidate point sequence obtained by the last screening by the preset multiple.
Then, the similarity between each initial point sequence and all the first contour points is determined, and the similarity can be calculated based on formula (4), for example. If the degree of dispersion of the similarity between each initial point sequence and all the first contour points exceeds a preset threshold, it indicates that the difference between the current initial point sequences is large, and if some of the initial point sequences are adjusted, it is possible to obtain an initial point sequence with higher overlap ratio with the first contour points. Here, the variance may be obtained from the similarity between each initial point sequence and all the first contour points to obtain the dispersion degree, and the preset threshold may be preset, for example, set to 0.0001. Therefore, the initial point sequence in which the similarity is low may be deleted to exclude the contour point sequence that is completely dissimilar from the first contour point. And then, adjusting part of the initial point sequences to obtain a plurality of newly added initial point sequences so as to find the initial point sequences with higher coincidence degree with the first contour points until the discrete degree of the similarity between each initial point sequence and all the first contour points is smaller than a preset threshold value or reaches a preset iteration number. The number of the added initial point sequences may be greater than or equal to the number of the deleted initial point sequences. At this time, the difference between the initial point sequences is small, and even if a part of the initial point sequences is adjusted, it is difficult to obtain the initial point sequences with higher overlap ratio with the first contour points, so that it is not necessary to update the initial point sequences, and each current initial point sequence can be directly used as a candidate point sequence.
According to the method provided by the embodiment of the invention, based on the plurality of initial point sequences corresponding to the second contour, when the dispersion degree of the similarity between each initial point sequence and all the first contour points exceeds the preset threshold, a plurality of initial point sequences with the lowest similarity are deleted, a plurality of initial point sequences are newly added until the dispersion degree of the similarity between each initial point sequence and all the first contour points is smaller than the preset threshold or reaches the preset iteration times, and each initial point sequence is taken as the candidate point sequence, so that the candidate point sequence with higher coincidence degree with each first contour point can be screened out, and the accuracy of pattern matching is improved.
Based on any of the above embodiments, in step 520, adding a plurality of initial point sequences includes at least one of the following ways:
randomly extracting two initial point sequences from the rest initial point sequences, and exchanging a plurality of corresponding second contour points in the two initial point sequences with a first probability to serve as a newly added initial point sequence;
randomly extracting an initial point sequence from the rest initial point sequences, and replacing a plurality of second contour points in the extracted initial point sequence with any second contour point on a second contour by a second probability to serve as a newly added initial point sequence;
and randomly extracting an initial point sequence from the rest initial point sequences to serve as a new initial point sequence.
Specifically, when an initial point sequence is added, two initial point sequences may be randomly extracted from the remaining initial point sequences that are not deleted
Figure BDA0002687711050000191
Seed of a plant
Figure BDA0002687711050000192
Will be provided with
Figure BDA0002687711050000193
And
Figure BDA0002687711050000194
the second contour points are exchanged with a first probability, and two initial point sequences obtained after the exchange are newly added initial point sequences. The first probability may be preset, and may be set to a value between 30% and 60%, for example. Specifically, traversal can be synchronized
Figure BDA0002687711050000195
And
Figure BDA0002687711050000196
every time t second contour points are traversed, the method will
Figure BDA0002687711050000197
And
Figure BDA0002687711050000198
is to exchange the current second contour point, i.e. is to
Figure BDA0002687711050000199
And
Figure BDA00026877110500001910
and
Figure BDA00026877110500001911
and
Figure BDA00026877110500001912
and (4) exchanging. Here, t is the interval between two exchanged second contour points, and may be set in advance. Or randomly drawing an initial point sequence from the rest of the initial point sequences which are not deleted
Figure BDA00026877110500001913
Will be provided with
Figure BDA00026877110500001914
The plurality of second contour points in the second contour are replaced by any second contour point on the second contour with a second probability, and the initial point sequence obtained after replacement is the newly added initial point sequence. The second probability may be preset, for example, may be set to 1/N, where N is the number of the first contour points. And an initial point sequence can be randomly extracted from the rest of the initial point sequences which are not deleted, and the initial point sequence is directly used as a new initial point sequence.
It should be noted that, each time the initial point sequence is newly added, any one or more of the three new adding manners may be adopted. In addition, when the new initial point sequence is added by combining the three new adding modes, the corresponding selection probability p can be set for the three new adding modes in advancecross、pmutationAnd pcopyAnd selecting the current new adding mode based on the three selection probabilities. Wherein, at setting pcross、pmutationAnd pcopyIn time, three selection probabilities can be set to satisfy p according to actual application requirementscross+pmutation+pcopy1 and pmutation<pcross<pcopyThe numerical values under the conditions are not particularly limited to these values in the examples of the present invention.
Based on any of the above embodiments, in step 420, expanding the first contour point on the first contour and the second contour point of each candidate point sequence by a preset multiple specifically includes:
if the product of the number of the current first contour points and the preset multiple is larger than the preset number, expanding the number of the first contour points to the preset number, randomly selecting second contour points which are not included in any candidate point sequence on the second contour, and expanding the number of the second contour points in any candidate point sequence to the preset number;
otherwise, a preset multiple minus 1 new first contour point is inserted between every two adjacent first contour points, and a preset multiple minus 1 new second contour point is inserted between every two adjacent second contour points of any candidate point sequence.
Specifically, if the product of the number of the current first contour points and the preset multiple is greater than the preset number, it indicates that if the first contour points are expanded by the preset multiple, the number of the expanded first contour points will be greater than the preset number, at this time, the number of the first contour points can be directly expanded to the preset number, and N is randomly selected on the second contourD-N second contour points not included in any of the candidate point sequences, wherein NDAnd N is the number of second contour points in the current candidate point sequence, so that the number of the second contour points in any candidate point sequence is expanded to be the preset number. For each selected second contour point, it is determined which two second contour points of the sequence of candidate points it lies between on the second contour and inserted between these two second contour points.
Otherwise, a preset multiple minus 1 new first contour point is inserted between every two adjacent first contour points. The new first contour point can be selected from contour points between every two adjacent first contour points on the first contour. And then inserting a preset multiple minus 1 new second contour point between every two adjacent second contour points of any candidate point sequence. The new second contour point may be selected from contour points between every two adjacent second contour points on the second contour.
Based on any of the above embodiments, fig. 6 is a schematic flow chart of a pattern matching method according to another embodiment of the present invention, as shown in fig. 6, the method includes:
and 610, respectively extracting outlines of the two graphs to be matched to obtain a first outline and a second outline. Specifically, after contour extraction, the perimeters of the contours of the two figures may be compared, and the contour having the smaller perimeter may be used as the first contour and the contour having the larger perimeter may be used as the second contour. Contour points of the first contour and the second contour may then be extracted using a contour point extraction tool, such as the findcontours function provided by opencv. Then, a unified complex plane coordinate system is established, the first contour and the second contour are placed in the coordinate system, and complex plane coordinates of contour points on the first contour and the second contour are obtained.
Step 620, obtaining a preset number of first contour points in the first contour. When the first contour point is obtained, the contour points capable of representing the graphic features need to be obtained as much as possible, so that after the original contour is removed, the whole contour can be approximately restored through simple interpolation according to the obtained first contour point, and the restored contour can approach the original contour as much as possible.
The first contour point may be specifically obtained as follows: assuming that the predetermined number is N, the number of contour points on the first contour is NDThe contour points of the first contour may be traversed every N in either a clockwise or counterclockwise directionDTaking one contour point as a first contour point, and returning to the starting point to continue traversing if the number of the first contour points does not reach N after traversing; or the shortest interval distance d can be predetermined, the first contour is traversed by taking a certain contour point in the first contour as a starting point, and one contour point is taken as the first contour point every Euclidean distance d; and manually labeling and screening contour points in the first contour, and taking the contour point which can express the contour feature most as the first contour point.
Step 630, determining a corresponding relationship between each first contour point in the first contour and each second contour point in the second contour, to obtain a second contour point corresponding to each first contour point in the first contour. The corresponding relationship between each first contour point and each second contour point can be determined by the contour point corresponding relationship determination method provided in any of the above embodiments, and details are not repeated here.
Step 640, determining a plane geometric transformation coefficient based on each first contour point and the corresponding second contour point, and the transformation coefficient function, and performing plane geometric transformation on the first contour based on the plane geometric transformation coefficient. After the plane geometric transformation, the first contour and the second contour are overlapped to the maximum extent, so that the specific difference of the two contours in shape is visually displayed.
Step 650, determining a graph matching result obtained by comparing the first contour after the plane geometric transformation is performed on the first contour based on each first contour point and the corresponding second contour point.
It should be noted that, in the embodiment of the present invention, the execution sequence of step 640 and step 650 is not specifically limited, and step 640 may be executed before or after step 650, or may be executed synchronously with step 650.
The following describes the pattern matching apparatus provided in the embodiment of the present invention, and the pattern matching apparatus described below and the pattern matching method described above may be referred to correspondingly.
Based on any of the above embodiments, fig. 7 is a schematic structural diagram of a pattern matching apparatus according to an embodiment of the present invention, and as shown in fig. 7, the apparatus includes a contour extraction unit 710 and a pattern matching unit 720.
The contour extraction unit 710 is configured to perform contour extraction on a first graphic and a second graphic to be matched, respectively, to obtain a first contour of the first graphic and a second contour of the second graphic;
the graph matching unit 720 is configured to determine a graph matching result obtained by performing plane geometric transformation on the first contour and then comparing the first contour with each second contour in the second contour based on a correspondence between each first contour point in the first contour and each second contour point in the second contour;
the object of the plane geometric transformation of the first contour is to minimize the distance between each first contour point and its corresponding second contour point.
According to the device provided by the embodiment of the invention, after the first graph and the second graph to be matched are respectively subjected to contour extraction, based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour, the graphic matching result obtained by comparing the first contour after plane geometric transformation is determined, and the difference between each first contour point and the corresponding second contour point is fully considered, so that the accuracy of the graphic matching result is improved, and meanwhile, the specific difference between the first contour and the second contour is more accurately reflected.
Based on any of the above embodiments, the pattern matching unit 720 is specifically configured to:
and determining a graph matching result based on the minimum distance between each first contour point and the corresponding second contour point which can be achieved after the first contour is subjected to plane geometric transformation and the coordinate variance of each second contour point.
The device provided by the embodiment of the invention determines the graph matching result based on the minimum distance between each first contour point and the corresponding second contour point after the first contour is subjected to plane geometric transformation and the coordinate variance of each second contour point, accords with the mathematical statistics rule, and can accurately reflect the difference degree or the similarity degree between the two contours.
Based on any of the above embodiments, the apparatus further comprises a plane geometry transformation unit, specifically configured to:
determining a plane geometric transformation coefficient based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour and a transformation coefficient function;
performing plane geometric transformation on the first contour based on the plane geometric transformation coefficient;
the transformation coefficient function is derived based on an extremum condition that needs to be satisfied when the distance between each first contour point and the corresponding second contour point is minimum.
The device provided by the embodiment of the invention determines the plane geometric transformation coefficient based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour and the transformation coefficient function, performs plane geometric transformation on the first contour based on the plane geometric transformation coefficient, and can intuitively embody the specific difference of the two contours in shape according to the shape comparison result of the two contours in the maximum coincidence state.
Based on any of the above embodiments, the apparatus further includes a contour point correspondence determining unit, specifically configured to:
screening a plurality of candidate point sequences from the second contour based on a preset number of first contour points on the first contour;
or screening a plurality of candidate point sequences from the second contour based on the initial number of first contour points on the first contour, and expanding the first contour points on the first contour and the second contour points of each candidate point sequence by preset multiples until the number of the second contour points contained in each candidate point sequence is equal to the preset number;
and taking the second contour point in the candidate point sequence with the maximum similarity with the preset number of first contour points as the second contour point corresponding to each first contour point.
The device provided by the embodiment of the invention screens a plurality of candidate point sequences from the second contour based on the preset number of first contour points on the first contour, or gradually expands the number of the first contour points and the number of the second contour points in the candidate point sequences to gradually screen a plurality of candidate point sequences containing the preset number of second contour points, and then takes the second contour point in the candidate point sequence with the maximum similarity with the preset number of first contour points as the second contour point corresponding to each first contour point, so that the second contour point corresponding to each first contour point can be quickly screened and obtained, and the efficiency of pattern matching is improved.
Based on any of the above embodiments, the screening of the plurality of candidate point sequences from the second contour specifically includes:
determining a plurality of initial point sequences corresponding to the second contour; and the number of the second contour points contained in each initial point sequence is the same as that of the first contour points.
And if the discrete degree of the similarity between each initial point sequence and all the first contour points exceeds a preset threshold, deleting a plurality of initial point sequences with the lowest similarity, and adding a plurality of initial point sequences until the discrete degree of the similarity between each initial point sequence and all the first contour points is less than the preset threshold or reaches a preset iteration number.
And taking each initial point sequence as a candidate point sequence.
The device provided by the embodiment of the invention is based on a plurality of initial point sequences corresponding to the second contour, when the dispersion degree of the similarity between each initial point sequence and all the first contour points exceeds a preset threshold, a plurality of initial point sequences with the lowest similarity are deleted, a plurality of initial point sequences are newly added until the dispersion degree of the similarity between each initial point sequence and all the first contour points is less than the preset threshold or reaches a preset iteration number, and each initial point sequence is taken as the candidate point sequence, so that the candidate point sequence with higher coincidence degree with each first contour point can be screened out, and the accuracy of pattern matching is improved.
Based on any embodiment of the above, adding a plurality of initial point sequences, including at least one of the following ways:
randomly extracting two initial point sequences from the rest initial point sequences, and exchanging a plurality of corresponding second contour points in the two initial point sequences with a first probability to serve as a newly added initial point sequence;
randomly extracting an initial point sequence from the rest initial point sequences, and replacing a plurality of second contour points in the extracted initial point sequence with any second contour point on a second contour by a second probability to serve as a newly added initial point sequence;
and randomly extracting an initial point sequence from the rest initial point sequences to serve as a new initial point sequence.
Based on any of the above embodiments, the expanding the first contour point on the first contour and the second contour point of each candidate point sequence by a preset multiple specifically includes:
if the product of the number of the current first contour points and the preset multiple is larger than the preset number, expanding the number of the first contour points to the preset number, randomly selecting second contour points which are not included in any candidate point sequence on the second contour, and expanding the number of the second contour points in any candidate point sequence to the preset number;
otherwise, a preset multiple minus 1 new first contour point is inserted between every two adjacent first contour points, and a preset multiple minus 1 new second contour point is inserted between every two adjacent second contour points of any candidate point sequence.
Fig. 8 illustrates a physical structure diagram of an electronic device, and as shown in fig. 8, the electronic device may include: a processor (processor)810, a communication Interface 820, a memory 830 and a communication bus 840, wherein the processor 810, the communication Interface 820 and the memory 830 communicate with each other via the communication bus 840. Processor 810 may call logic instructions in memory 830 to perform a pattern matching method comprising: respectively extracting outlines of a first graph and a second graph to be matched to obtain a first outline of the first graph and a second outline of the second graph; determining a graph matching result obtained by comparing the first contour after plane geometric transformation is carried out on the first contour based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour; the object of the plane geometric transformation of the first contour is to minimize the distance between each first contour point and the corresponding second contour point.
In addition, the logic instructions in the memory 830 may be implemented in software functional units and stored in a computer readable storage medium when the logic instructions 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.
In another aspect, an embodiment of the present invention further provides a computer program product, where the computer program product includes a computer program stored on a non-transitory computer-readable storage medium, the computer program includes program instructions, and when the program instructions are executed by a computer, the computer can execute the graph matching method provided by the above-mentioned method embodiments, where the method includes: respectively extracting outlines of a first graph and a second graph to be matched to obtain a first outline of the first graph and a second outline of the second graph; determining a graph matching result obtained by comparing the first contour after plane geometric transformation is carried out on the first contour based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour; the object of the plane geometric transformation of the first contour is to minimize the distance between each first contour point and the corresponding second contour point.
In yet another aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium, on which a computer program is stored, where the computer program is implemented by a processor to perform the graph matching method provided in the foregoing embodiments, and the method includes: respectively extracting outlines of a first graph and a second graph to be matched to obtain a first outline of the first graph and a second outline of the second graph; determining a graph matching result obtained by comparing the first contour after plane geometric transformation is carried out on the first contour based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour; the object of the plane geometric transformation of the first contour is to minimize the distance between each first contour point and the corresponding second contour point.
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 can be implemented by software plus a necessary general hardware platform, and certainly can 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, but 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 (10)

1. A method of pattern matching, comprising:
respectively extracting outlines of a first graph and a second graph to be matched to obtain a first outline of the first graph and a second outline of the second graph;
determining a graph matching result obtained by comparing the first contour after plane geometric transformation is carried out on the first contour based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour;
the object of the plane geometric transformation of the first contour is to minimize the distance between each first contour point and the corresponding second contour point.
2. The pattern matching method according to claim 1, wherein the determining, based on a correspondence between each first contour point in the first contour and each second contour point in the second contour, a pattern matching result obtained by performing plane geometric transformation on the first contour and then comparing the first contour with the second contour point comprises:
and determining the graph matching result based on the minimum distance between each first contour point and the corresponding second contour point which can be achieved after the first contour is subjected to plane geometric transformation and the coordinate variance of each second contour point.
3. The pattern matching method according to claim 1, wherein the extracting contours of the first pattern and the second pattern to be matched are performed separately to obtain a first contour of the first pattern and a second contour of the second pattern, and then further comprising:
determining a plane geometric transformation coefficient based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour and a transformation coefficient function;
performing plane-geometric transformation on the first contour based on the plane-geometric transformation coefficient;
the transformation coefficient function is derived based on an extremum condition that needs to be satisfied when the distance between each first contour point and the corresponding second contour point is minimum.
4. The pattern matching method according to any one of claims 1 to 3, wherein the correspondence between each first contour point in the first contour and each second contour point in the second contour is determined based on:
screening a plurality of candidate point sequences from the second contour based on a preset number of first contour points on the first contour;
or screening a plurality of candidate point sequences from the second contour based on the initial number of first contour points on the first contour, and expanding the first contour points on the first contour and the second contour points of each candidate point sequence by a preset multiple until the number of the second contour points contained in each candidate point sequence is equal to the preset number;
and taking the second contour point in the candidate point sequence with the maximum similarity to the preset number of first contour points as the second contour point corresponding to each first contour point.
5. The pattern matching method according to claim 4, wherein the step of screening a plurality of candidate point sequences from the second contour comprises:
determining a plurality of initial point sequences of the second contour; the number of second contour points contained in each initial point sequence is the same as that of the first contour points;
if the discrete degree of the similarity between each initial point sequence and all the first contour points exceeds a preset threshold value, deleting a plurality of initial point sequences with the lowest similarity, and adding a plurality of initial point sequences until the discrete degree of the similarity between each initial point sequence and all the first contour points is smaller than the preset threshold value or reaches a preset iteration number;
and taking each initial point sequence as the candidate point sequence.
6. The pattern matching method of claim 5, wherein the adding of the plurality of initial point sequences comprises at least one of:
randomly extracting two initial point sequences from the rest initial point sequences, and exchanging a plurality of corresponding second contour points in the two initial point sequences with a first probability to serve as a newly added initial point sequence;
randomly extracting an initial point sequence from the rest initial point sequences, and replacing a plurality of second contour points in the extracted initial point sequence with any second contour point on the second contour by a second probability to serve as a newly added initial point sequence;
and randomly extracting an initial point sequence from the rest initial point sequences to serve as a new initial point sequence.
7. The pattern matching method according to claim 4, wherein the expanding the first contour points on the first contour and the second contour points of each candidate point sequence by a predetermined multiple specifically comprises:
if the product of the number of the current first contour points and a preset multiple is larger than the preset number, expanding the number of the first contour points to the preset number, randomly selecting second contour points which are not included in any candidate point sequence on the second contour, and expanding the number of the second contour points in any candidate point sequence to the preset number;
otherwise, inserting the preset multiple minus 1 new first contour point between every two adjacent first contour points, and inserting the preset multiple minus 1 new second contour point between every two adjacent second contour points of any candidate point sequence.
8. A pattern matching apparatus, comprising:
the contour extraction unit is used for respectively extracting contours of a first graphic and a second graphic to be matched to obtain a first contour of the first graphic and a second contour of the second graphic;
the image matching unit is used for determining an image matching result obtained by comparing the first contour after plane geometric transformation is carried out on the first contour based on the corresponding relation between each first contour point in the first contour and each second contour point in the second contour;
the object of the plane geometric transformation of the first contour is to minimize the distance between each first contour point and the corresponding second contour point.
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 steps of the pattern matching method according to any of claims 1 to 7 are implemented when the processor executes the program.
10. A non-transitory computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the pattern matching method according to any one of claims 1 to 7.
CN202010981581.7A 2020-09-17 2020-09-17 Pattern matching method, device, electronic equipment and storage medium Active CN112052909B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010981581.7A CN112052909B (en) 2020-09-17 2020-09-17 Pattern matching method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010981581.7A CN112052909B (en) 2020-09-17 2020-09-17 Pattern matching method, device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112052909A true CN112052909A (en) 2020-12-08
CN112052909B CN112052909B (en) 2023-12-01

Family

ID=73603895

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010981581.7A Active CN112052909B (en) 2020-09-17 2020-09-17 Pattern matching method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112052909B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030198388A1 (en) * 2002-04-10 2003-10-23 Lothar Wenzel Pattern matching system utilizing discrete curve matching with a mapping operator
CN101770582A (en) * 2008-12-26 2010-07-07 鸿富锦精密工业(深圳)有限公司 Image matching system and method
JP2012088796A (en) * 2010-10-15 2012-05-10 Kddi Corp Image area division device, image area division method, and image area division program
CN108830312A (en) * 2018-06-01 2018-11-16 苏州中科天启遥感科技有限公司 A kind of integrated learning approach adaptively expanded based on sample
JP2019106184A (en) * 2017-12-11 2019-06-27 韓國電子通信研究院Electronics and Telecommunications Research Institute Method of recognizing attitude of plane object, and apparatus therefor
CN110309338A (en) * 2018-07-25 2019-10-08 浙江大华技术股份有限公司 One kind is to scheme to search drawing method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030198388A1 (en) * 2002-04-10 2003-10-23 Lothar Wenzel Pattern matching system utilizing discrete curve matching with a mapping operator
CN101770582A (en) * 2008-12-26 2010-07-07 鸿富锦精密工业(深圳)有限公司 Image matching system and method
JP2012088796A (en) * 2010-10-15 2012-05-10 Kddi Corp Image area division device, image area division method, and image area division program
JP2019106184A (en) * 2017-12-11 2019-06-27 韓國電子通信研究院Electronics and Telecommunications Research Institute Method of recognizing attitude of plane object, and apparatus therefor
CN108830312A (en) * 2018-06-01 2018-11-16 苏州中科天启遥感科技有限公司 A kind of integrated learning approach adaptively expanded based on sample
CN110309338A (en) * 2018-07-25 2019-10-08 浙江大华技术股份有限公司 One kind is to scheme to search drawing method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
E. SHARON等: ""2D-Shape Analysis Using Conformal Mapping"", 《INTERNATIONAL JOURNAL OF COMPUTER VISION》, vol. 70 *
邓宝松等: ""图像匹配中具有仿射不变性特征的定量分析"", 《信号处理》, vol. 24, no. 2 *

Also Published As

Publication number Publication date
CN112052909B (en) 2023-12-01

Similar Documents

Publication Publication Date Title
US11120254B2 (en) Methods and apparatuses for determining hand three-dimensional data
EP3111422B1 (en) System and method for auto-contouring in adaptive radiotherapy
Fan et al. Robust feature-preserving mesh denoising based on consistent subneighborhoods
CN108229301B (en) Eyelid line detection method and device and electronic equipment
CN113160257B (en) Image data labeling method, device, electronic equipment and storage medium
CN107784321B (en) Method and system for quickly identifying digital picture books and computer readable storage medium
CN107038432B (en) Fingerprint image direction field extraction method based on frequency information
CN113095333B (en) Unsupervised feature point detection method and unsupervised feature point detection device
CN111223128A (en) Target tracking method, device, equipment and storage medium
CN109685805B (en) Image segmentation method and device
CN112651389A (en) Method and device for training, correcting and identifying correction model of non-orthoptic iris image
CN111598087A (en) Irregular character recognition method and device, computer equipment and storage medium
CN112488067A (en) Face pose estimation method and device, electronic equipment and storage medium
CN106600587A (en) Lung CT image auxiliary detection processing device
CN111898408B (en) Quick face recognition method and device
CN110929731B (en) Medical image processing method and device based on pathfinder intelligent search algorithm
EP3018626B1 (en) Apparatus and method for image segmentation
CN112052909A (en) Pattern matching method, device, electronic equipment and storage medium
CN114723973A (en) Image feature matching method and device for large-scale change robustness
Chen et al. Pulmonary nodule segmentation in computed tomography with an encoder-decoder architecture
CN113177602A (en) Image classification method and device, electronic equipment and storage medium
CN111681270A (en) Method, device and storage medium for realizing registration between image frames
CN114119446A (en) Image processing method and device, and medical image processing method and device
Si et al. LBF: learnable bilateral filter for point cloud denoising
JP7344916B2 (en) Information processing device, information processing method and program

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