CN112801865A - Rotation-invariant template image generation method, device, equipment and storage medium - Google Patents
Rotation-invariant template image generation method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN112801865A CN112801865A CN202110303906.0A CN202110303906A CN112801865A CN 112801865 A CN112801865 A CN 112801865A CN 202110303906 A CN202110303906 A CN 202110303906A CN 112801865 A CN112801865 A CN 112801865A
- Authority
- CN
- China
- Prior art keywords
- rotation
- template image
- image
- invariant
- angle
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 58
- 230000006870 function Effects 0.000 claims description 50
- 239000011159 matrix material Substances 0.000 claims description 35
- 238000012935 Averaging Methods 0.000 claims description 14
- 238000004364 calculation method Methods 0.000 claims description 10
- 125000004122 cyclic group Chemical group 0.000 claims description 9
- 230000008859 change Effects 0.000 abstract description 9
- 230000008569 process Effects 0.000 description 12
- 238000010586 diagram Methods 0.000 description 10
- 238000000354 decomposition reaction Methods 0.000 description 6
- 238000012545 processing Methods 0.000 description 5
- 238000004891 communication Methods 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 3
- 238000000605 extraction Methods 0.000 description 3
- 230000009466 transformation Effects 0.000 description 3
- 230000004044 response Effects 0.000 description 2
- 238000010276 construction Methods 0.000 description 1
- 230000007423 decrease Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 239000000284 extract Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
- 238000012216 screening Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T3/00—Geometric image transformations in the plane of the image
- G06T3/04—Context-preserving transformations, e.g. by using an importance map
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T3/00—Geometric image transformations in the plane of the image
- G06T3/60—Rotation of whole images or parts thereof
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Image Analysis (AREA)
Abstract
The invention discloses a rotation-invariant template image generation method, a rotation-invariant template image generation device and a rotation-invariant template image generation storage medium, wherein the rotation-invariant template image generation method comprises the following steps: obtaining an original template image, and performing rotation operation and average operation on the original template image to obtain an angle average image; and generating a template image with unchanged rotation based on the angle average image so as to match the template image with the image to be searched based on the template image with unchanged rotation. The invention utilizes the rotation invariance of the angle average image to generate the template image with unchanged rotation, and the template image with unchanged rotation directly ignores the rotation change to be matched on the image to be searched.
Description
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to a method, an apparatus, a device, and a computer-readable storage medium for generating a rotation-invariant template image.
Background
With the rapid development of science and technology, more and more technologies are applied to the field of image processing. At present, image template matching is widely applied to image calibration, object identification, navigation positioning and the like. Usually, a template image is given for finding a position on the image to be searched that is most similar to its content. However, when there is a difference in rotation angle between the template image and the image to be searched, a rotation-invariant template matching algorithm needs to be used for matching.
Currently, rotation invariant template matching can be performed by feature point matching. The characteristic point matching is to extract a series of characteristic points from the image, then calculate a coordinate transformation matrix by estimating the corresponding relation of points between the template image and the image to be searched, and further obtain the position relation of the two. For example, the SIFT (Scale-invariant feature transform) algorithm extracts an extreme point on a Scale space as a significant feature point, calculates a gradient direction histogram in a neighborhood range of each feature point as a descriptor of the feature point, determines a relationship of the point pair by comparing similarities between the descriptors between the template image and the image to be searched, and further obtains a transformation relationship between the template image and the image to be searched to solve a position of the template image on the image to be searched. In addition, the SURF (Speeded Up Robust Features) algorithm constructs an image pyramid using an approximate expression of Hessian matrix on the basis of the SIFT algorithm. Meanwhile, a descriptor is generated using Haar (wavelet feature) features instead of gradient histograms to speed up the extraction of the features. The ORB (feature extraction algorithm) generates feature points by judging a plurality of continuous bright and dark points, further accelerates the extraction of the feature points, and learns the point pair rule construction descriptor using the database. However, the above method is limited by the reliability of the local feature points and their descriptors, and is easily affected by noise and similar points in practical applications, resulting in failure of template matching.
Second, rotation invariant template matching can also be performed by pixel-by-pixel sliding matching. The core idea of the pixel-by-pixel sliding matching is to slide the template image on the image to be searched pixel by pixel, calculate the correlation between the template image and the corresponding area at a position every time the template image slides to the position, and take the position with the maximum correlation as the final matching position. However, when there is a rotation change between the template image and the image to be searched, the template image needs to be rotated to a different angle so that the template image is searched for an angle space at each position, which results in a great reduction in matching speed.
In addition, rotation-invariant template matching is also possible by the circular projection algorithm. Specifically, the local area is subjected to template matching by calculating the average gray value according to a circular ring to generate a rotation-invariant feature. In the matching process, each time the image is slid to a position, the rotation invariant feature at the position on the image to be searched needs to be calculated, so that the calculation amount is huge, and the matching speed is low. In addition, the circular projection algorithm directly utilizes the average gray value on the circular ring to generate the rotation-invariant feature, so that the feature is not obvious enough, and mismatching is easy to occur.
In summary, how to improve the accuracy of image template matching and how to improve the rate of image template matching are problems that need to be solved urgently at present.
Disclosure of Invention
The invention mainly aims to provide a template image generation method, a template image generation device, a template image generation equipment and a computer readable storage medium, aiming at improving the accuracy rate of image template matching and improving the rate of image template matching.
In order to achieve the above object, the present invention provides a rotation-invariant template image generation method, including the steps of:
obtaining an original template image, and performing rotation operation and average operation on the original template image to obtain an angle average image;
and generating a template image with unchanged rotation based on the angle average image so as to match the template image with the image to be searched based on the template image with unchanged rotation.
Optionally, the step of performing a rotation operation and an averaging operation on the original template image to obtain an angle-averaged image includes:
acquiring a central point of the original template image, and taking the central point as a rotation point;
sequentially rotating the original template image according to a preset rotation angle to obtain a rotated image based on the rotation point and the preset rotation times, wherein the number of the rotated images is the same as the preset rotation times;
and carrying out averaging operation on the rotating image to obtain an angle average image.
Optionally, the step of generating a rotation-invariant template image based on the angle-averaged image includes:
decomposing the angle-averaged image into a set of orthogonal bases;
obtaining a basis coefficient based on the original template image and the group of orthogonal bases;
and generating a rotation-invariant template image based on the basis coefficients and the set of orthogonal bases.
Optionally, the step of decomposing the angle-averaged image into a set of orthogonal bases comprises:
decomposing the angle average image based on the constructed Gaussian weight matrix to obtain a group of orthogonal bases, wherein the Gaussian weight matrix is
Wherein,,representing the coordinates of the center point of the original template image, (x, y) representing the coordinates of the current point,representing the radius of the circle in the angle-averaged image,is a preset gaussian variance.
Optionally, the step of obtaining a basis coefficient based on the original template image and the set of orthogonal bases includes:
based on the original template image and the group of orthogonal bases, solving the constructed objective function to obtain a base coefficient, wherein the objective function is
Wherein G is a Gaussian matrix generated by a predetermined two-dimensional Gaussian function,representing the ith orthogonal image in the set of orthogonal bases,representing the base coefficient corresponding to the ith orthogonal image, M being the original template image and symbolRepresenting a circular shift correlation operation, the original template image having a size of。
Optionally, the rotation-invariant template image generation method further includes:
expanding the Gaussian matrix G according to columns to obtain a first expansion result according to columnsAnd expanding the results of the calculation of the cyclic shift correlation between the group of orthogonal bases and the original template image M in columns to obtain a second expanded result in columns;
Based on the first column-wise expansion resultAnd said second column-wise expansion resultThe objective function is calculatedIs transformed intoWhereinrepresents a base coefficient;
Optionally, the step of generating a rotation-invariant template image based on the basis coefficients and the set of orthogonal bases includes:
based on the basis coefficient and the group of orthogonal bases, generating a rotation-invariant template image through a constructed template generating function, wherein the template generating function is
Whereinrepresents the ith coefficient of the base coefficients,represents the ith orthogonal image in the set of orthogonal bases, and r +1 represents the number of the set of orthogonal bases.
In order to achieve the above object, the present invention also provides a rotation-invariant template image generation apparatus including:
the image acquisition module is used for acquiring an original template image and carrying out rotation operation and average operation on the original template image to obtain an angle average image;
and the template generating module is used for generating a template image with unchanged rotation based on the angle average image so as to match the template image with the image to be searched based on the template image with unchanged rotation.
Further, to achieve the above object, the present invention also provides a rotation-invariant template image generation apparatus including: a memory, a processor and a rotation invariant template image generation program stored on the memory and executable on the processor, the rotation invariant template image generation program when executed by the processor implementing the steps of the rotation invariant template image generation method as described above.
Further, to achieve the above object, the present invention also provides a computer-readable storage medium having stored thereon a rotation-invariant template image generation program which, when executed by a processor, implements the steps of the rotation-invariant template image generation method as described above.
The invention provides a template image generation method, a device and equipment with unchanged rotation and a computer readable storage medium, wherein an original template image is obtained, and the original template image is subjected to rotation operation and average operation to obtain an angle average image; and generating a rotation-invariant template image based on the angle average image so as to match the rotation-invariant template image on the image to be searched. Through the mode, the template image with unchanged rotation is generated by utilizing the rotation invariance of the angle average image, and the template image with unchanged rotation is matched on the image to be searched by directly neglecting the rotation change based on the template image with unchanged rotation, namely, even if the rotation change exists between the template image and the image to be searched, the template image does not need to be rotated to different angles for matching, so that the rate of image template matching is improved. Meanwhile, in the template matching process, the rotation invariant feature at the position on the image to be searched does not need to be calculated when the image to be searched slides to one position, so that the calculation amount in the matching process can be reduced, and the rate of image template matching is improved. In addition, compared with the characteristic that the rotation is not changed by directly utilizing the average gray value on the circular ring, the method can improve the accuracy of image template matching. In conclusion, the invention improves the accuracy of image template matching and improves the rate of image template matching.
Drawings
Fig. 1 is a schematic terminal structure diagram of a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a first embodiment of a rotation-invariant template image generation method according to the present invention;
FIG. 3 is a schematic diagram of an original template image according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of an angle-averaged image according to an embodiment of the present invention;
FIG. 5 is a flowchart illustrating a second embodiment of a rotation-invariant template image generation method according to the present invention;
FIG. 6 is a schematic diagram of an orthogonal image according to an embodiment of the present invention;
fig. 7 is a functional block diagram of a first embodiment of a rotation-invariant template image generation apparatus according to the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a schematic terminal structure diagram of a hardware operating environment according to an embodiment of the present invention.
The terminal in the embodiment of the present invention is a template image generating device with no change in rotation, and the template image generating device with no change in rotation may be a terminal device with a processing function, such as a PC (personal computer), a microcomputer, a notebook computer, and a server.
As shown in fig. 1, the terminal may include: a processor 1001, such as a CPU (Central Processing Unit), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the terminal structure shown in fig. 1 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a rotation-invariant template image generation program.
In the terminal shown in fig. 1, the processor 1001 may be configured to call a rotation-invariant template image generation program stored in the memory 1005, and perform the following operations:
obtaining an original template image, and performing rotation operation and average operation on the original template image to obtain an angle average image;
and generating a template image with unchanged rotation based on the angle average image so as to match the template image with the image to be searched based on the template image with unchanged rotation.
Further, the processor 1001 may be configured to call the rotation-invariant template image generation program stored in the memory 1005, and further perform the following operations:
acquiring a central point of the original template image, and taking the central point as a rotation point;
sequentially rotating the original template image according to a preset rotation angle to obtain a rotated image based on the rotation point and the preset rotation times, wherein the number of the rotated images is the same as the preset rotation times;
and carrying out averaging operation on the rotating image to obtain an angle average image.
Further, the processor 1001 may be configured to call the rotation-invariant template image generation program stored in the memory 1005, and further perform the following operations:
decomposing the angle-averaged image into a set of orthogonal bases;
obtaining a basis coefficient based on the original template image and the group of orthogonal bases;
and generating a rotation-invariant template image based on the basis coefficients and the set of orthogonal bases.
Further, the processor 1001 may be configured to call the rotation-invariant template image generation program stored in the memory 1005, and further perform the following operations:
decomposing the angle average image based on the constructed Gaussian weight matrix to obtain a group of orthogonal bases, wherein the Gaussian weight matrix is
Wherein,,representing the coordinates of the center point of the original template image, (x, y) representing the coordinates of the current point,representing the radius of the circle in the angle-averaged image,is a preset gaussian variance.
Further, the processor 1001 may be configured to call the rotation-invariant template image generation program stored in the memory 1005, and further perform the following operations:
based on the original template image and the group of orthogonal bases, solving the constructed objective function to obtain a base coefficient, wherein the objective function is
Wherein G is a Gaussian matrix generated by a predetermined two-dimensional Gaussian function,representing the ith orthogonal image in the set of orthogonal bases,representing the base coefficient corresponding to the ith orthogonal image, M being the original template image and symbolRepresenting a circular shift correlation operation, the original template image having a size of。
Further, the processor 1001 may be configured to call the rotation-invariant template image generation program stored in the memory 1005, and further perform the following operations:
expanding the Gaussian matrix G according to columns to obtain a first expansion result according to columnsAnd expanding the results of the calculation of the cyclic shift correlation between the group of orthogonal bases and the original template image M in columns to obtain a second expanded result in columns;
Based on the first column-wise expansion resultAnd said second column-wise expansion resultThe objective function is calculatedIs transformed intoWhereinrepresents a base coefficient;
Further, the processor 1001 may be configured to call the rotation-invariant template image generation program stored in the memory 1005, and further perform the following operations:
based on the basis coefficient and the group of orthogonal bases, generating a rotation-invariant template image through a constructed template generating function, wherein the template generating function is
Whereinrepresents the ith coefficient of the base coefficients,represents the ith orthogonal image in the set of orthogonal bases, and r +1 represents the number of the set of orthogonal bases.
Based on the hardware structure, the invention provides various embodiments of the template image generation method with unchanged rotation.
The invention provides a template image generation method with unchanged rotation.
Referring to fig. 2, fig. 2 is a flowchart illustrating a first embodiment of a rotation-invariant template image generation method according to the present invention.
In this embodiment, the rotation-invariant template image generation method includes:
step S10, obtaining an original template image, and carrying out rotation operation and average operation on the original template image to obtain an angle average image;
in this embodiment, an original template image is acquired, and the original template image is subjected to a rotation operation and an averaging operation to obtain an angle average image, so that the original template image is processed to obtain the angle average image with rotation invariance. The original template image is a predetermined template image, which is usually a small image, and is used to find an area on the image to be searched, which is most similar to the content of the image.
The rotation operation is to rotate the original template image and sequentially obtain the respective rotated images. The averaging operation is to average each rotated image and take the average value as an angle average image.
Specifically, in the step S10, the rotating operation and the averaging operation are performed on the original template image to obtain an angle-averaged image, and the method includes the following steps a11-a 13:
a11, acquiring the central point of the original template image, and taking the central point as a rotation point;
first, a center point of an original template image is acquired, and the center point of the original template image is taken as a rotation point of a rotation operation. For example, when the coordinates of the original template image are discrete coordinates, if the size of the original template image is (2 r + 1) × (2 r + 1), the point (r +1 ) is taken as the center point of the original template image, that is, the rotation point of the rotation operation, and it can be understood that the upper left corner of the original template image is (1, 1) coordinates. When the coordinates of the original template image are continuous coordinates, if the size of the original template image is 2r, the point (r, r) is set as the center point of the original template image, that is, the rotation point of the rotation operation.
It can be understood that, in the embodiment of the present invention, the size of the original template image is (2 r + 1) × (2 r + 1), and the upper left corner of the original template image is the (1, 1) coordinate, which are used as examples for description, and other size forms or different central coordinate positions of the original template image are substantially the same as those in the embodiment of the present invention, and are not described here again.
Step a12, based on the rotation point and the preset rotation times, sequentially rotating the original template image according to a preset rotation angle to obtain a rotation image, wherein the number of the rotation images is the same as the preset rotation times;
and then, sequentially rotating the original template image according to a preset rotation angle to obtain a rotated image based on the rotation point and the preset rotation frequency of the rotation operation, wherein the number of the rotated images is the same as the preset rotation frequency.
In one embodiment, the predetermined number of rotations is 360, and the predetermined rotation angle is 1 degree. That is, the original template image is rotated by an angle θ = 0, 1, 2,. to., 358, 359 degrees, resulting in 360 rotated images.
In some embodiments, if the preset rotation angle is 1 degree, the preset rotation number is 360 times; if the preset rotation angle is 2 degrees, the preset rotation times are 180 times; if the predetermined rotation angle is 0.5 degrees, the predetermined number of rotations is 720.
The preset rotation times and the preset rotation angle can be set according to actual needs, and are not particularly limited herein.
And a step a13, averaging the rotation images to obtain angle average images.
And finally, averaging all the rotated images to obtain angle average images, namely taking the average value of all the rotated images as the angle average image. In particular, the function is generated from the angle-averaged image
And presetting the rotation times N and the original template image M to generate an angle average image, wherein,the rotation image is generated by rotating the center point of the original template image M by a predetermined rotation angle θ.
In one embodiment, the predetermined number of rotations is 360, and the predetermined rotation angle is 1 degree. That is, the angle-averaged image generation function is
For easy understanding, referring to fig. 3, fig. 3 is a schematic diagram of an original template image according to an embodiment of the present invention, and referring to fig. 4, fig. 4 is a schematic diagram of an angle-averaged image according to an embodiment of the present invention. The angle-averaged image of fig. 4 can be obtained by performing the rotation operation and the averaging operation on the original template image of fig. 3.
And step S20, generating a rotation-invariant template image based on the angle average image, so as to match the rotation-invariant template image on the image to be searched.
In this embodiment, a rotation-invariant template image is generated based on the angle-averaged image, so as to be matched on the image to be searched based on the rotation-invariant template image. The template image with unchanged rotation has rotation invariance, and even if the template image with unchanged rotation and the image to be searched have rotation change, the template image does not need to be rotated to different angles.
In one embodiment, since the angle-averaged image has rotation invariance, the angle-averaged image can be directly used as a rotation-invariant template image. In other embodiments, the template image with unchanged rotation may be generated by further processing based on the angle average image, and the specific execution flow refers to the following second embodiment, which is not described herein again.
It should be noted that the template matching method for matching on the image to be searched based on the rotation-invariant template image includes methods such as direct sliding matching, multi-stage matching, pyramid matching, and frequency domain matching. The direct sliding matching is carried out by calculating the correlation of the rotation invariant template on the image to be searched pixel by pixel and taking the position with the maximum correlation as the optimal matching position. The execution process of the multi-stage matching is as follows: the method comprises the steps of preliminarily selecting a small radius to generate a rotation invariant template with a small size, performing sliding matching on an image to be searched, extracting the first n points with a large matching response, wherein a parameter n can be set by a user, preliminarily screening a small number of candidate areas by using the small template image, then selecting a large radius to generate a rotation invariant template with a large size, and calculating correlation at the n candidate positions to select a position with a maximum matching response as a final matching result, so that the matching speed of the image template can be further improved. The execution process of the frequency domain matching is to convert the generated rotation-invariant template and the image to be searched into a frequency domain space, and solve the optimal matching position by using the dot product of the two.
The embodiment of the invention provides a template image generation method with unchanged rotation, which comprises the steps of obtaining an original template image, and carrying out rotation operation and average operation on the original template image to obtain an angle average image; and generating a rotation-invariant template image based on the angle average image so as to match the rotation-invariant template image on the image to be searched. Through the mode, the template image with unchanged rotation is generated by utilizing the rotation invariance of the angle average image, and the template image with unchanged rotation is matched on the image to be searched by directly neglecting the rotation change based on the template image with unchanged rotation, namely, even if the template image and the image to be searched have rotation change, the template image does not need to be rotated to different angles for matching, so that the rate of image template matching is improved. Meanwhile, in the template matching process, the rotation invariant feature at the position on the image to be searched does not need to be calculated when the image to be searched slides to one position, so that the calculation amount in the matching process can be reduced, and the rate of image template matching is improved. In addition, compared with the characteristic that the rotation is not changed by directly utilizing the average gray value on the circular ring, the embodiment of the invention can improve the accuracy of image template matching. In summary, the embodiment of the invention improves the accuracy of image template matching and improves the rate of image template matching.
Further, based on the first embodiment described above, a second embodiment of the rotation-invariant template image generation method of the present invention is proposed.
Referring to fig. 5, fig. 5 is a flowchart illustrating a second embodiment of a rotation-invariant template image generation method according to the present invention.
In this embodiment, the step S20 includes:
step S21, decomposing the angle average image into a set of orthogonal bases;
in this embodiment, since the angle average image is an average value in the angle space, the information value is seriously lost, so as to further improve the accuracy of image template matching. Firstly, decomposing the angle average image into a group of orthogonal bases, and projecting the original template image in the base space to solve a group of base coefficients corresponding to the orthogonal bases.
It should be noted that any two orthogonal images in a set of orthogonal bases are orthogonal to each other, that is, the inner product of the two orthogonal images is equal to 0. Therefore, the angle-averaged image only needs to be decomposed into a set of orthogonal bases which are orthogonal pairwise, and how to perform orthogonal decomposition is not particularly limited herein.
In an embodiment, the angle averaged image may be decomposed into different circular rings such that each circular ring retains only a portion of the angle averaged image.
Specifically, step S21 includes:
step a211, decomposing the angle average image based on the constructed Gaussian weight matrix to obtain a group of orthogonal bases, wherein the Gaussian weight matrix is
Wherein,,representing the coordinates of the center point of the original template image, (x, y) representing the coordinates of the current point,representing a ring in said angle-averaged imageThe radius of the beam is the radius of the beam,is a preset gaussian variance.
In this embodiment, the gaussian weight matrix is a matrix constructed in advance, and is acquired and used when orthogonal decomposition of the angle-averaged image is required. In particular, according to a Gaussian weight matrix
And orthogonal image generation function
A set of orthogonal bases is generated.
Wherein,d represents the Euclidean distance from the current point to the center point of the original template image,representing the coordinates of the center point of the original template image, (x, y) representing the coordinates of the current point,representing the radius of the circle in the angle-averaged image,is a preset Gaussian varianceDetermining the smoothness of the ring obtained by the current decomposition, the preset Gaussian varianceThe concentration can be set according to actual needs, and is between 0.1 and 0.5, and is not particularly limited herein.Represents the value of the current point (x, y) in the angle-averaged image a.
In one embodiment, if the size of the angle-averaged image is (2 r + 1) × (2 r + 1), that is, the size of the original template image is also (2 r + 1) × (2 r + 1), the number of gaussian weight matrices to be constructed is r + 1. And then, multiplying the r +1 Gaussian weight matrixes by the value of each current point of the angle average image A respectively to obtain r +1 orthogonal images. For example, r is 20, refer to fig. 6, fig. 6 is a schematic diagram of orthogonal images according to an embodiment of the present invention, fig. 6 includes 21 orthogonal images, any two orthogonal images are orthogonal to each other, that is, an angle-averaged image is decomposed into a set of orthogonal bases (21 orthogonal images) shown in fig. 6.
Step S22, obtaining a basis coefficient based on the original template image and the group of orthogonal basis;
in this embodiment, based on the original template image and a set of orthogonal bases, the base coefficients corresponding to the set of orthogonal bases are obtained. Wherein the number of basis coefficients is the same as the number of a set of orthogonal bases.
In one embodiment, the step S22 includes:
step a221, based on the original template image and the group of orthogonal bases, solving a constructed objective function to obtain a base coefficient, wherein the objective function is
Wherein G is a Gaussian matrix generated by a predetermined two-dimensional Gaussian function,representing the ith orthogonal image in the set of orthogonal bases,representing the base coefficient corresponding to the ith orthogonal image, M being the original template image and symbolRepresenting a circular shift correlation operation, the original template image having a size of。
In the present embodiment, a two-dimensional gaussian matrix G is set in advance to indicate that the correlation is maximum at the true position, and the correlation gradually decreases as the distance from the true position increases. In order to solve a set of basis coefficients, the correlation result between the orthogonal image in a set of orthogonal basis and the original template image needs to be a two-dimensional gaussian matrix G. Therefore, to confirm the relationship between the two, an objective function is constructed
Wherein G is a Gaussian matrix generated by a preset two-dimensional Gaussian function,representing the ith orthogonal image in a set of orthogonal bases,representing the base coefficient corresponding to the ith orthogonal image, M is the original template image and symbolRepresenting cyclic shift correlation operation, original template image M, Gaussian matrix G, orthogonal imageAll sizes of (A) and (B) are。
It will be appreciated that if the original template is usedImage M, Gaussian matrix G, orthogonal imageIf the values of (1) are all 2r × 2r, r +1 of the objective function is changed to r.
Further, the rotation-invariant template image generation method further includes:
step A, expanding the Gaussian matrix G according to columns to obtain a first column-by-column expansion resultAnd expanding the results of the calculation of the cyclic shift correlation between the group of orthogonal bases and the original template image M in columns to obtain a second expanded result in columns;
In this embodiment, to further simplify the objective function to solve a set of basis coefficients, first, the gaussian matrix G is expanded in columns to obtain a first column-wise expansion resultAnd a group of orthogonal bases (the 1 st to r +1 st orthogonal images) and the calculation result of the cyclic shift correlation of the original template image M are expanded in columns to obtain a second expansion result in columns。
Wherein, the original size of the Gaussian matrix G is (2 r + 1) × (2 r + 1), and after the operation of expanding by columns, a first expansion result by columns is obtainedIs of a size ofI.e. by. Can be used forTo combine the ith orthogonal image in a set of orthogonal basesThe calculation result of the cyclic shift correlation with the original template image M is recorded as a matrixThen, matrixThe column expansion results to obtain a second column expansion result,Is of a size ofI.e. by. In addition, the original template image M is developed in columns and recorded as,Is of a size ofI.e. by。
Step B, based on the first column-by-column expansion resultAnd said second column-wise expansion resultThe objective function is calculatedIs transformed intoWhereinrepresents a base coefficient;
then, based on the first column-wise expansion resultAnd a second column-wise expansion resultAn objective functionIs transformed into. Wherein,a set of base coefficients representing a set of orthogonal bases, the set of base coefficients forming a matrix of base coefficients,Has a size of (r + 1) × 1, i.e.。
Finally, based on the objective function by least squaresSolving to obtain the basis coefficients. Wherein,representing the basis coefficients corresponding to a set of orthogonal bases.
Step S23, based on the basis coefficients and the set of orthogonal bases, generates a rotation-invariant template image.
In this embodiment, a rotation invariant template image is generated based on the basis coefficients and a set of orthogonal bases. It should be noted that, each orthogonal image in a set of orthogonal bases is multiplied by the corresponding base coefficient, and then all multiplication results are accumulated to obtain a rotation-invariant template image.
Specifically, step S23 includes:
step a231, based on the basis coefficient and the set of orthogonal bases, generating a rotation-invariant template image through a constructed template generating function, wherein the template generating function is
Whereinrepresents the ith coefficient of the base coefficients,represents the ith orthogonal image in the set of orthogonal bases, and r +1 represents the number of the set of orthogonal bases.
In this embodiment, all orthogonal images in a set of orthogonal bases are combinedAll base coefficients corresponding toThe template images with unchanged rotation can be generated by substituting the constructed template generation function.
Wherein the template generation function is
Representing the ith basis coefficient in a set of basis coefficients,represents the ith orthogonal image in a set of orthogonal bases, and r +1 represents the number of the set of orthogonal bases and the number of the set of base coefficients.
It is understood that if r +1 represents the number of a set of orthogonal bases, and if the number of a set of orthogonal bases is r, r +1 in the template generating function may be converted to r.
In this embodiment, the angle average image is decomposed into a group of orthogonal bases, and the corresponding base coefficients are solved, so that the problem that the information value of the angle average image is seriously lost is solved, the success rate of image template matching is improved, and the accuracy rate of image template matching is further improved.
The invention also provides a template image generation device with unchanged rotation.
Referring to fig. 7, fig. 7 is a functional block diagram of a first embodiment of a rotation-invariant template image generation apparatus according to the present invention.
In this embodiment, the rotation-invariant template image generation apparatus includes:
the image obtaining module 10 is configured to obtain an original template image, and perform rotation operation and averaging operation on the original template image to obtain an angle average image;
and a template generating module 20, configured to generate a rotation-invariant template image based on the angle-averaged image, so as to perform matching on an image to be searched based on the rotation-invariant template image.
Wherein, each virtual function module of the rotation-invariant template image generation apparatus is stored in the memory 1005 of the rotation-invariant template image generation device shown in fig. 1, and is used for implementing all functions of the rotation-invariant template image generation program; when executed by the processor 1001, the modules may perform a rotation invariant template image generation function.
Further, the image acquisition module 10 includes:
a central point obtaining unit, configured to obtain a central point of the original template image, and use the central point as a rotation point;
the image rotation unit is used for sequentially rotating the original template image according to a preset rotation angle to obtain a rotation image based on the rotation point and the preset rotation times, wherein the number of the rotation images is the same as the preset rotation times;
and the image averaging unit is used for carrying out averaging operation on the rotating image to obtain an angle average image.
Further, the template generating module 20 includes:
an image decomposition unit for decomposing the angle-averaged image into a set of orthogonal bases;
a coefficient obtaining unit, configured to obtain a basis coefficient based on the original template image and the set of orthogonal bases;
and the template generating unit is used for generating a rotation-invariant template image based on the basis coefficient and the group of orthogonal bases.
Further, the image decomposition unit includes:
an image decomposition subunit, configured to decompose the angle-averaged image based on a constructed gaussian weight matrix to obtain a set of orthogonal bases, where the gaussian weight matrix is
Wherein,,representing the coordinates of the center point of the original template image, (x, y) representing the coordinates of the current point,representing the radius of the circle in the angle-averaged image,is a preset gaussian variance.
Further, the coefficient acquisition unit includes:
a coefficient solving subunit, configured to solve the constructed objective function based on the original template image and the set of orthogonal bases to obtain a base coefficient, where the objective function is
Wherein G is a Gaussian matrix generated by a predetermined two-dimensional Gaussian function,representing the ith orthogonal image in the set of orthogonal bases,representing the base coefficient corresponding to the ith orthogonal image, M being the original template image and symbolIndicating cyclic shift correlation operationsThe size of the original template image is。
Further, the coefficient acquisition unit further includes:
a column-wise expansion subunit for expanding the Gaussian matrix G by columns to obtain a first column-wise expansion resultAnd expanding the results of the calculation of the cyclic shift correlation between the group of orthogonal bases and the original template image M in columns to obtain a second expanded result in columns;
A function transformation subunit for expanding the result based on the first columnAnd said second column-wise expansion resultThe objective function is calculatedIs transformed intoWhereinrepresents a base coefficient;
a function acquisition subunit for acquiring the target function based on the target functionSolving to obtain the basis coefficients。
Further, the template generating unit includes:
a template generating subunit, configured to generate a rotation-invariant template image through a constructed template generating function based on the basis of the basis coefficients and the set of orthogonal bases, where the template generating function is
Whereinrepresents the ith coefficient of the base coefficients,represents the ith orthogonal image in the set of orthogonal bases, and r +1 represents the number of the set of orthogonal bases.
The function implementation of each module in the rotation-invariant template image generation device corresponds to each step in the rotation-invariant template image generation method embodiment, and the functions and implementation processes are not described in detail here.
The present invention also provides a rotation-invariant template image generation apparatus including: a memory, a processor and a rotation invariant template image generation program stored on the memory and executable on the processor, the rotation invariant template image generation program when executed by the processor implementing the steps of the rotation invariant template image generation method as described in any of the above embodiments.
The specific embodiment of the rotation-invariant template image generation device of the present invention is substantially the same as the embodiments of the rotation-invariant template image generation method, and is not described herein again.
The present invention also provides a computer-readable storage medium having stored thereon a rotation-invariant template image generation program which, when executed by a processor, implements the steps of the rotation-invariant template image generation method as described in any one of the above embodiments.
The specific embodiment of the computer-readable storage medium of the present invention is substantially the same as the embodiments of the above-mentioned rotation-invariant template image generation method, and will not be described herein again.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. 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 (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.
Claims (10)
1. A rotation-invariant template image generation method, characterized by comprising:
obtaining an original template image, and performing rotation operation and average operation on the original template image to obtain an angle average image;
and generating a template image with unchanged rotation based on the angle average image so as to match the template image with the image to be searched based on the template image with unchanged rotation.
2. The method for generating a rotation-invariant template image according to claim 1, wherein the step of performing a rotation operation and an averaging operation on the original template image to obtain an angle-averaged image comprises:
acquiring a central point of the original template image, and taking the central point as a rotation point;
sequentially rotating the original template image according to a preset rotation angle to obtain a rotated image based on the rotation point and the preset rotation times, wherein the number of the rotated images is the same as the preset rotation times;
and carrying out averaging operation on the rotating image to obtain an angle average image.
3. The rotation-invariant template image generation method of claim 1, wherein the generating of the rotation-invariant template image based on the angle-averaged image comprises:
decomposing the angle-averaged image into a set of orthogonal bases;
obtaining a basis coefficient based on the original template image and the group of orthogonal bases;
and generating a rotation-invariant template image based on the basis coefficients and the set of orthogonal bases.
4. The rotation-invariant template image generation method of claim 3, wherein said decomposing the angle-averaged image into a set of orthogonal bases comprises:
decomposing the angle average image based on the constructed Gaussian weight matrix to obtain a group of orthogonal bases, wherein the Gaussian weight matrix is
5. The rotation-invariant template image generation method of claim 3, wherein the step of obtaining a basis coefficient based on the original template image and the set of orthogonal bases comprises:
based on the original template image and the group of orthogonal bases, solving the constructed objective function to obtain a base coefficient, wherein the objective function is
Wherein G is a Gaussian matrix generated by a predetermined two-dimensional Gaussian function,representing the ith orthogonal image in the set of orthogonal bases,representing the base coefficient corresponding to the ith orthogonal image, M being the original template image and symbolRepresenting a circular shift correlation operation, the original template image having a size of。
6. The rotation-invariant template image generation method of claim 5, further comprising:
expanding the Gaussian matrix G according to columns to obtain a first expansion result according to columnsAnd expanding the results of the calculation of the cyclic shift correlation between the group of orthogonal bases and the original template image M in columns to obtain a second expanded result in columns;
Based on the first column-wise expansion resultAnd said second column-wise expansion resultThe objective function is calculatedIs transformed intoWhereinrepresents a base coefficient;
7. The rotation-invariant template image generation method of claim 3, wherein the step of generating a rotation-invariant template image based on the basis coefficients and the set of orthogonal bases comprises:
based on the basis coefficient and the group of orthogonal bases, generating a rotation-invariant template image through a constructed template generating function, wherein the template generating function is
8. A rotation-invariant template image generation apparatus, characterized by comprising:
the image acquisition module is used for acquiring an original template image and carrying out rotation operation and average operation on the original template image to obtain an angle average image;
and the template generating module is used for generating a template image with unchanged rotation based on the angle average image so as to match the template image with the image to be searched based on the template image with unchanged rotation.
9. A rotation-invariant template image generation apparatus, characterized in that the rotation-invariant template image generation apparatus comprises: memory, a processor and a rotation-invariant template image generation program stored on the memory and executable on the processor, which when executed by the processor implements the steps of the rotation-invariant template image generation method of any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that a rotation-invariant template image generation program is stored on the computer-readable storage medium, which when executed by a processor implements the steps of the rotation-invariant template image generation method of any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110303906.0A CN112801865B (en) | 2021-03-22 | 2021-03-22 | Rotation-invariant template image generation method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110303906.0A CN112801865B (en) | 2021-03-22 | 2021-03-22 | Rotation-invariant template image generation method, device, equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112801865A true CN112801865A (en) | 2021-05-14 |
CN112801865B CN112801865B (en) | 2021-08-06 |
Family
ID=75815607
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110303906.0A Active CN112801865B (en) | 2021-03-22 | 2021-03-22 | Rotation-invariant template image generation method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112801865B (en) |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1327569A (en) * | 1999-08-04 | 2001-12-19 | 皇家菲利浦电子有限公司 | System and method for rotation invariant representation of textures in images |
CN103632132A (en) * | 2012-12-11 | 2014-03-12 | 广西工学院 | Face detection and recognition method based on skin color segmentation and template matching |
CN103778619A (en) * | 2012-10-17 | 2014-05-07 | 华中科技大学 | Image matching method based on Zernike matrix |
CN104281845A (en) * | 2014-10-29 | 2015-01-14 | 中国科学院自动化研究所 | Face recognition method based on rotation invariant dictionary learning model |
CN108764249A (en) * | 2018-04-23 | 2018-11-06 | 云南民族大学 | A kind of invariable rotary multi-source image method for describing local characteristic, system and device |
CN110136160A (en) * | 2019-05-13 | 2019-08-16 | 南京大学 | A kind of rapid image matching method based on circular projection |
CN110211178A (en) * | 2019-06-10 | 2019-09-06 | 重庆邮电大学 | A kind of pointer instrument recognition methods calculated using projection |
CN111445480A (en) * | 2020-03-23 | 2020-07-24 | 南京理工大学 | Image rotation angle and zoom coefficient measuring method based on novel template |
-
2021
- 2021-03-22 CN CN202110303906.0A patent/CN112801865B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1327569A (en) * | 1999-08-04 | 2001-12-19 | 皇家菲利浦电子有限公司 | System and method for rotation invariant representation of textures in images |
CN103778619A (en) * | 2012-10-17 | 2014-05-07 | 华中科技大学 | Image matching method based on Zernike matrix |
CN103632132A (en) * | 2012-12-11 | 2014-03-12 | 广西工学院 | Face detection and recognition method based on skin color segmentation and template matching |
CN104281845A (en) * | 2014-10-29 | 2015-01-14 | 中国科学院自动化研究所 | Face recognition method based on rotation invariant dictionary learning model |
CN108764249A (en) * | 2018-04-23 | 2018-11-06 | 云南民族大学 | A kind of invariable rotary multi-source image method for describing local characteristic, system and device |
CN110136160A (en) * | 2019-05-13 | 2019-08-16 | 南京大学 | A kind of rapid image matching method based on circular projection |
CN110211178A (en) * | 2019-06-10 | 2019-09-06 | 重庆邮电大学 | A kind of pointer instrument recognition methods calculated using projection |
CN111445480A (en) * | 2020-03-23 | 2020-07-24 | 南京理工大学 | Image rotation angle and zoom coefficient measuring method based on novel template |
Also Published As
Publication number | Publication date |
---|---|
CN112801865B (en) | 2021-08-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8416982B2 (en) | Image processing apparatus, image processing method and program | |
CN105701766B (en) | Image matching method and device | |
US8009879B2 (en) | Object recognition device, object recognition method, object recognition program, feature registration device, feature registration method, and feature registration program | |
JP5714599B2 (en) | Fast subspace projection of descriptor patches for image recognition | |
US8515177B2 (en) | Image processing apparatus, image processing method, and program | |
US9619733B2 (en) | Method for generating a hierarchical structured pattern based descriptor and method and device for recognizing object using the same | |
CN111291753B (en) | Text recognition method and device based on image and storage medium | |
CN111783770B (en) | Image correction method, device and computer readable storage medium | |
CN110807110B (en) | Image searching method and device combining local and global features and electronic equipment | |
CN110717497A (en) | Image similarity matching method and device and computer readable storage medium | |
CN112613506A (en) | Method and device for recognizing text in image, computer equipment and storage medium | |
CN110210480A (en) | Character recognition method, device, electronic equipment and computer readable storage medium | |
JP6736988B2 (en) | Image retrieval system, image processing system and image retrieval program | |
CN110827301A (en) | Method and apparatus for processing image | |
CN114511865A (en) | Method and device for generating structured information and computer readable storage medium | |
CN112801865B (en) | Rotation-invariant template image generation method, device, equipment and storage medium | |
JP5500404B1 (en) | Image processing apparatus and program thereof | |
CN114170229B (en) | Method, device and equipment for registering defect images of printed circuit board and storage medium | |
CN113033640B (en) | Template matching method, device, equipment and computer readable storage medium | |
CN114399495A (en) | Image definition calculation method, device, equipment and storage medium | |
TWI814483B (en) | Method and system for identifying metal billet | |
CN115423855B (en) | Template matching method, device, equipment and medium for image | |
JP7478628B2 (en) | Image processing device, control method, and control program | |
CN114627182B (en) | Positioning method and device of robot, electronic equipment and storage medium | |
CN112884048B (en) | Method for determining registered image in input image, related device and 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 |