Embodiment
The present invention relates to a kind of search method and system of similar shape.A shape database is arranged in the system, comprise several shapes in this database, these shapes are to wait for the shape (being designated hereinafter simply as " shape to be retrieved ") of the output that is retrieved.In addition, as the input of system, an inquiry shape is arranged, the shape to be retrieved in the database can be respectively be carried out similarity relatively with this input inquiry shape, thereby determines which shape to be retrieved is enough similar to the input inquiry shape and export as result for retrieval.
Retrieval work receives the input inquiry shape from system, returns the SOME RESULTS shape that draws by retrieval with system and finishes.
A given shape database, an inquiry shape and a shape distance function, it needs not to be a tolerance, the present invention learns a distance function, and this distance function obtains by the shortest path on the stream shape of the similarity formation between any two of the shape to be retrieved in inquiry shape and the database.The present invention does not need this stream shape of dominance ground study.Experiment showed, that the distance function of new study can integrate the knowledge of inner shape difference.This learning process is non-supervision.
In the method that the present invention proposes, on shape similarity basis, further calculate new similarity according to existing shape description and the acquisition of form fit algorithm computation.Say intuitively, for a given shape S
1Even, shape S
3With shape S
1Dissmilarity, but if with shape S
3Similar shapes S
2Similar in appearance to S
1, shape S so
1With shape S
3Similarity also can be very high.Yet, even shape S
1With shape S
3Very similar, if but with shape S
3Similar shapes S
2With shape S
1And dissmilarity, shape S so
1With shape S
3Similarity will be very low.Therefore, the new similarity that obtains is to content erotic, and the content of given shape is exactly and its similar shapes here.
Even shape S
1With shape S
3Differ greatly, but a shape S is arranged
2All very little with their difference, still think shape S
1With shape S
3Similar.This situation is possible for most shapes distance, because they do not satisfy the relation of triangle inequality, i.e. and d (S
1, S
3)≤d (S
1, S
2)+d (S
2, S
3) be not to set up always.If to some shape S
1, S
2, S
3,, satisfy d (S
1, S
3)>d (S
1, S
2)+d (S
2, S
3) this situation, the method for this chapter proposition can be acquired one newly apart from d ' (S so
1, S
3) satisfy d ' (S
1, S
3)≤d (S
1, S
2)+d (S
2, S
3).Equally, if in metric space, exist a paths to make d (S
1, S
3)>d (S
1, S
2,1)+...+d (S
2, u, S
3), wherein u is the quantity of shape on this path, so this method obtain one new for d ' (S
1, S
3)≤d (S
1, S
2,1)+...+d (S
2, u, S
3).Because this paths is represented one from shape S
1To shape S
3The process of minimal distortion distortion, can ignore the shape difference that is not very crucial, and concentrate on the crucial shape difference, so just obtained one new for d '.The present invention has promoted the accuracy of shape retrieval by this new distance metric.
Below in conjunction with accompanying drawing and example the inventive method is described in further detail.
As shown in Figure 8, the inventive method comprises the steps:
(1) profile of image to be retrieved in extraction input inquiry image and the database.The query image of input and the image to be retrieved in the database all are bianry images.If the query image of input is not a bianry image, convert thereof into bianry image earlier.The method of conversion comprises artificial manual mark or image partition method (for example, figure normalization cutting scheduling algorithm) etc.As shown in Figure 1, the shape shown in the figure is an input picture of the present invention.From the query image and the image to be retrieved of database of input, obtain the shape profile by the profile extraction algorithm.
The shape profile that extracts from the query image of input is called the inquiry shape, and the shape profile that image to be retrieved extracted from database is called shape to be retrieved.Because the shape profile has comprised the key message of bianry image, profile extracts and is very easy to realize simultaneously, so the query image of input also can be described as the input inquiry shape, the binary image data storehouse also can be described as shape database, and the image to be retrieved in the database also can be described as shape to be retrieved.The back is adopted the saying of " inquiry shape ", " shape database " and " shape to be retrieved " respectively in the literary composition.
For the image to be retrieved in the database, obtain the work of treatment of corresponding shape profile from bianry image, not be used in retrieval phase and carry out, can finish in advance.For the query image of input, its work of extracting the shape profile can only be finished in retrieval phase.
(2) on the basis of inquiry shape that step (1) is extracted and shape to be retrieved, calculate the feature of each shape profile, just descriptor.Distance was in shape hereinafter as the descriptor of shape in the present invention used.Specific practice is as follows:
(2.1) each shape profile is carried out uniform sampling.N point of each profile up-sampling, the value of N are set in different applied environments as required, as N=100.See shown in Fig. 2 (A) that the circular solids point on the outline of scissors is the sampled point on the profile in the figure.
(2.2) for each the sampled point p on each shape profile
i, i represents the sequence number of sampled point, i=1 ..., N, in using distance in shape hereinafter descriptor be described.For certain shape, all N sampled point on its shape profile interior apart from shape description formed the feature of this shape jointly.
The interior distance of calculating each sampled point is descriptor hereinafter in shape, and specific practice is as follows:
(2.2.1) calculate interior distance.Interior distance between the definition sampled point is in the inner length that connects the shortest path of two sampled points of shape.Use shortest path first to calculate certain sampled point p
iInterior distance on the shape border between other sampled point, computing method are as follows: 1. at first construct a graph structure, in this graph structure, each sampled point p
iAs the summit of figure, establishing wherein any two sampled points is p
1And p
2, judge whether the limit that connects these two summits drops on the inside of shape, if drop on the inside of shape, so just between these two summits, keep the connection on a limit, the limit weight equals the Euclidean distance between them || p
1-p
2||.If the inside of shape is not dropped on this limit fully, then there is not a limit directly to link to each other between these two summits.2. use shortest path first (as enlightening Coase thorough (Dijkstra) algorithm) on whole weight map, obtain the shortest connection between any two points, this bee-line is interior distance.It in Fig. 2 (C) the shortest path line segment on the shape local detail.
(2.2.2) calculate interior angle.Define a sampled point p
1With respect to another sampled point p
2Interior angle be configuration sampling point p
1Tangential direction and from a p
1The p that sets out
1, p
2Between the shortest path direction between angle.In Fig. 3, p
1And p
2Be two sampled points on the profile, the angle θ shown in the figure is p
1And p
2Between interior angle.
(2.2.3) calculate in distance descriptor hereinafter in shape.The concentric circles that uses the division of band direction among the present invention is as the instrument that calculates descriptor, and so-called band direction is divided and is meant with sampled point p
iTangential direction be the zero angle direction, with 360 the degree spaces evenly be divided into G the interval, as shown in Figure 4, the concentrically ringed center of circle is in certain configuration sampling point p
i, each radius of a circle of concentric circles and concentrically ringed orientation angle are divided according to the concrete occasion of using and are decided, and suppose that the zero degree direction is sampled point p
iTangential direction, suppose angular divisions be G interval, use in this example be with 360 degree be divided into G=12 interval, each zone is 30 to spend.Hypothesis has R concentric circles again, R=5 in this example, and then R concentric circles and G angular interval combine and have constituted (R+1) * G interval.Then in conjunction with (2.2.1) and (2.2.2) the interior distance and the interior angle of acquisition, the point of determining on the profile other is with a p
iFor the band direction in the center of circle apart from the distribution of dividing in concentrically ringed (R+1) * G interval, obtain a statistic histogram, this histogram is seen shown in Fig. 7 right side.Distance descriptor hereinafter in shape in this statistic histogram is.Its mathematical definition is:
h
i(k)=#{p
j:1≤j≤N,j≠i,p
j-p
i∈bin(k)}
In following formula, h
iThe interior distance of i sampled point statistic histogram hereinafter in shape on the expression profile, h
i(k) expression drops on the number of putting in k the interval of this statistic histogram, and the span of k is from 1 integer to (R+1) * G.p
iRepresent i sampled point, the object described of this statistic histogram just, p
jThen represent in N the sampled point on the shape profile, except p
iIn addition other N-1 the point in any one.p
iBe the above-mentioned concentrically ringed center of circle, p
j-p
iRepresent a vector, this vector points to p
jBin represents the interval division that the above-mentioned concentric circles with being with direction apart from division obtains, and k of bin (k) expression is interval.The implication of expression formula is if vectorial p
j-p
iDrop among the interval bin (k), then think a p
jDrop among the interval k of statistic histogram, the quantity h of the point among the interval k of corresponding statistic histogram
i(k) add 1.Symbol # represents the implication that adds up.
Explain further that in conjunction with Fig. 4, Fig. 5 in Fig. 4, the position of establishing place, the center of circle is p
i, the position of arrow points is p
j, through an intermediate point p
wLength from the broken line in the center of circle among Fig. 5 is interior distance, in calculating apart from shape hereinafter during descriptor, at first the broken line among Fig. 5 is done partial rotation and obtain the straight-line segment shown in Fig. 6, in seeing that then which distance regions this straight-line segment terminal point drops between, judge this straight-line segment and put p
iThe number of degrees of angle (being among Fig. 6) of tangential direction near angle θ that home position indicated drop in which angular interval, in conjunction with above-mentioned two parts information, finally determine a some p
jDrop in which interval, accumulated value that then should the interval adds 1 on basis before.
The final statistic histogram that obtains as shown in Figure 7, the dark more place of color is represented to count few more, the shallow more place of color is represented to count many more.
In the statistic histogram of Fig. 7, X direction is represented the angular interval division, and y direction is represented apart from interval division.
(2.3) calculate the feature of each shape profile
Repeat the process of (2.2), calculate the interior distance descriptor hereinafter in shape that obtains each sampled point on certain shape profile, thereby obtain description this shape.This description to whole shape is to form by one group of statistic histogram of describing as (2.2.3), and each statistic histogram all is the description of some points on this shape profile.Such one group of descriptor is exactly foregoing shape facility.
Repeat this process, calculate the feature that obtains all shapes to be retrieved in input inquiry shape and the database.
For the shape to be retrieved in the database, the calculating of its shape contour feature not be used in retrieval phase to be carried out, and can finish in advance.For the inquiry shape of input, the calculating of its shape contour feature can only be finished in retrieval phase.
(3) form fit
On the basis of the shape facility that step (2) calculates, gather for the shape that the inquiry shape and the shape to be retrieved in the database of input are formed, mate between any two shapes in the pair set, obtain its measure of dissimilarity value (distance) between any two.
Coupling between (3.1) two shapes
The present invention uses dynamic programming method, finds the solution the best correspondence of any two shape profile up-sampling points and the measure of dissimilarity value (distance) between this two shapes, finishes form fit.Specific practice is as follows:
Suppose that to be matched one of them is shaped as A, another one is shaped as B, forms two arrangement sets by the configuration sampling point of A and B, is designated as { p respectively
i, i=1 ..., N}, { q
j, j=1 ..., N}.
(3.1.1) the difference sequence of calculation { p
i, i=1 ..., any one the some p among the N}
iWith sequence { q
j, j=1 ..., any one the some q among the N}
jBetween characteristic distance c (i, j), this distance definition point p that (2.2) calculate that serves as reasons
iStatistic histogram with the some q
jStatistic histogram between distance, its mathematical definition is as follows:
H wherein
A, i, h
B, jBe the statistic histogram of definition in (2.2.3), subscript A and B represent h
A, i(k), h
B, j(k) be the statistic histogram of shape A and shape B respectively, c (i, j) expression point p
iWith a q
iCharacteristic distance.
By calculating the characteristic distance of being had a few on the have a few and shape B on the shape A, the characteristic distance matrix of acquisition N * N c (i, j), i=1 ..., N, j=1 ..., N}:
(3.1.2) two sequence { p of hypothesis
i, i=1 ..., N} and { q
j, j=1 ..., N} is at a p
1And q
1Place's alignment.Use dynamic programming method, try to achieve dissimilar degree (distance) D1 of two sequences, its solution procedure is as follows:
1. generate the empty matrix M of a N * N, be called the dynamic programming matrix.
2. initialization marginal condition:
M(0,0)=0;
M(i,0)=γ×i,i=1,...,N;
M(0,j)=γ×j,j=1,...,N;
These numerical value are not included in the dynamic programming matrix M, because the scope of the line index of the element among the M and column index is from 1 to N integer.The scalar penalty factor of γ for setting.
3. according to from left to right, from top to bottom order, calculate successively each element in the dynamic programming matrix M value S (i, j), i=1 ..., N, j=1 ..., N.Computing formula is as follows:
Wherein (i j) is a p to c
iWith a q
jBetween characteristic distance.
4. the value of each element is all calculated and is finished in the dynamic programming matrix, and then dynamic programming method finishes.The dissimilar degree D of two sequences
1=M (N, N).
(3.1.4) process of repetition (3.1.3) is supposed two sequence { p respectively
iAnd { q
iAt p
2With q
1Place's alignment, p
3With q
1Place's alignment ..., p
NWith q
1Place's alignment uses dynamic programming algorithm to try to achieve dissimilar degree (distance) D respectively
2, D
3..., D
N
(3.1.5) choose minimum that in try to achieve in the step (3.1.3) to (3.1.4) N the distance, as shape A, the measure of dissimilarity value (distance) between the B:
D(A,B)=min(D
i),i=1,...,N
(3.2) coupling between the shape in twos in the shape set
For the shape set of forming by the inquiry shape and the shape to be retrieved in the database of input, utilize the described method of step (3.1), any two shapes in the pair set utilize dynamic programming algorithm to mate, and obtain its measure of dissimilarity value (distance).
Contain n shape to be retrieved in the tentation data storehouse, n is a positive integer, and the n of inquiry shape in a database shape of input has been formed n+1 shape { x altogether
i, i=1 ..., n+1}.According to step (3.1), can obtain this n+1 shape measure of dissimilarity value (distance) between any two respectively, form a measure of dissimilarity matrix (distance matrix) { D
I, j, i, j=1 ..., n, n+1}:
Wherein, D
I, jRepresent the measure of dissimilarity value (distance) between i shape and j the shape.In addition, the inquiry shape with input is placed in this n+1 shape first, i.e. x
1
For the n in the database shape to be retrieved, its coupling and measure of dissimilarity between any two calculates, and not be used in retrieval phase and carries out, and can finish in advance.If but comprised the inquiry shape of input in two shapes of mating, then its coupling and measure of dissimilarity work could only be finished in retrieval phase.That is to say that for matrix D, the element value of its first row and first row must calculate in retrieval phase, but the equal calculated in advance of other element values is tried to achieve.
(4) measure of dissimilarity (distance) matrix of trying to achieve according to step (3) calculates the inquiry shape with the similarity between any one shape to be retrieved in the database.
This step just obtains result for retrieval by the shape method for measuring similarity that uses content erotic, and its specific practice is as follows:
(4.1) defining relation matrix w
I, j, its computing formula is as follows:
Wherein, D
I, jBe the dissimilar metric matrix (distance matrix) that obtains in the step (3.2), λ
I, jBe normalized parameter, the computing method of this normalized parameter are as follows:
λ
i,j=α·mean({knnd(x
i),knnd(x
j)})
In following formula, mean ({ knnd (x
i), knnd (x
j)) expression shape x
i, x
jThe mean distance of preceding b nearest neighbor distance.So-called nearest neighbor distance is meant and middle b the minimum distance of the measure of dissimilarity value (distance) of this shape.Parameter b and α be rule of thumb decision in actual application environment, b=10 in this example, α=0.27.
(4.2) definition probability transfer matrix P, this probability transfer matrix passes through w
I, jFollow direction normalization and obtain, computing formula is as follows:
W wherein
I, jBe above-mentioned relational matrix.
(4.3) define crucial function f, and find the solution crucial function by the process of following recurrence:
i=2,...,(n+1)
And have
f
t+1(x
1)=1
P wherein
I, jBe above-mentioned probability transfer matrix; This recursive procedure need be passed through T iteration, and parameter T is predetermined in actual application environment, T=5000 in this example.
(4.4) the crucial function f of using the recursive iteration process of step (4.3) to obtain, result's note is made f
T(x
i), i=1 ..., n, n+1, solving result are the matrixes of capable 1 row of n+1.Remove f
T(x
1), in the matrix of capable 1 row of remaining n, i the shape in the capable value representation database of i and the similarity of input inquiry shape.
(5) follow the similarity f between the individual shape to be retrieved of n in the database based on the input inquiry shape of trying to achieve in (4)
T(x
i), i=2 ..., n, n+1, deterministic retrieval output result.
To f
T(x
i), i=2 ..., the n among the n+1 is capable, and value sorts from big to small, the order later according to ordering, the retrieval output of shape to be retrieved order in the specified data storehouse.For example, i value is maximum, Shu Chu result for retrieval then, and i-1 shape comes first of result for retrieval, obtains second result for retrieval, the 3rd result for retrieval by that analogy, or the like.
What retrieval was exported is not the shape profile, but the original bianry image in the database.As Figure 10, shown in Figure 11.
Set a parameter l, the quantity of the image result that the expression retrieval is returned.That is to say, retrieval is returned be in the database with preceding l image of input inquiry image similarity maximum.The value of parameter l is set according to the demand of practical application flexibly by the user, l=40 in this example.
The present invention of experimental result proof can improve the retrieval performance of existing shape matching method.
Provided in the present invention on the MPEG-7CE-Shape-1 database in the table 1 and be published in the comparison of the main method in international important periodical and the meeting over nearly 10 years, the present invention has obtained 91.61% retrieval precision, is the highest among the result who obtains on this database at present.
Provided the result of on Kimia99 data set the present invention and in recent years important method in the table 2 and compare, the result shows that the result of method of the present invention on each rank all is higher than additive method.
In embodiment (4.1), exist two parameter b and α, table 3 has provided the retrieval precision that system can reach under different parameters, can see, and under the situation of fine setting parameter, Supreme Procuratorate of the present invention rope precision can reach 92.57%.
What provide among Fig. 9 is the distance hereinafter comparison of the recall ratio (curve of " * " labelled notation) of the recall ratio of method (curve of circles mark) and use the inventive method in shape in directly using on the MPEG-7 database.Can see method effect that the present invention provides obviously be better than directly using in distance method hereinafter in shape.
That Figure 10 provides is the result who retrieves on the MPEG-7 database, first row are shapes to be retrieved, the right 10 row are distance result for retrieval of the result for retrieval of method (odd-numbered line) and the inventive method (even number line) hereinafter in shape in directly using, and have provided preceding 10 results the most close among the figure.Can see method effect that the present invention provides obviously be better than directly using in distance method hereinafter in shape.
What Figure 11 provided is the local shape retrieval experiment of losing of band.First classifies the image to be retrieved of having lost a part as, the right 10 row be in directly using distance in shape hereinafter method (odd-numbered line) retrieve and use the inventive method (even number line) to retrieve the result for retrieval that obtains, provided preceding 10 result for retrieval the most similar among the figure.
The recall ratio of table 1 distinct methods on the MPEG-7 data set (bull ' s eyes)
The result for retrieval of table 2Kimia 99 data sets
Bull ' the s eye recall ratio of table 3 under different parameters
|
|
b=3 |
b=5 |
b=7 |
b=9 |
| α=0.1 |
83.9% |
88.11% |
89.26% |
89.84% |
| α=0.15 |
84.33% |
88.67% |
89.66% |
90.31% |
| α=0.2 |
85.77% |
90.29% |
91.34% |
91.84% |
| α=0.25 |
88.71% |
92.17% |
92.57% |
92.56% |
| α=0.3 |
89.69% |
91.16% |
91.41% |
91.16% |
| α=0.35 |
89.03% |
90.39% |
90.30% |
90.20% |
| α=0.4 |
88.74% |
89.99% |
89.97% |
89.84% |
The present invention not only is confined to above-mentioned embodiment; persons skilled in the art are according to content disclosed by the invention; can adopt other multiple embodiment to implement the present invention; therefore; every employing project organization of the present invention and thinking; do some simple designs that change or change, all fall into the scope of protection of the invention.