Embodiment
Below, describe the present invention in connection with drawings and Examples.
Main study subject of the present invention comprises the identification of the identification of caption and the incidence relation of image and caption, is intended to improve by the identification of these layout informations the related application such as recognition effect and other logical organization extraction of reading order.The present invention is mainly used in the digital document meeting the following conditions: can read digital document by page, can obtain character text object and image object and their association attributes such as font, position coordinates of every page, such as, the digital document of the CEBX form that general PDF document and upright company make.
In the present invention, caption recognition methods comprises the following steps:
(1) read the space of a whole page to be identified, separate character text object and image object in this space of a whole page, and character text object merging is become to text block, image object is left to image block.Wherein, can come separating character text object and image object according to document layout structure analysis method and/or according to the data object type in digital document;
(2) from the text block merging, identify the text block of caption type,, caption text block, such as, can be according to identifying caption text block with lower at least one: the distance of font size, text block and the image block of main font, the number of words of text block, the form of expression whether text block meets caption in text block.
Identify caption text block from text block after, by optimization method, image block and caption text block are carried out to Optimum Matching, thereby obtain the image block and the caption text block that are associated.
Specifically, in one embodiment, because the distance being mutually related between image block and caption text block approaches (or the most approaching) conventionally, so the caption (or making all captions all find the image being associated) being associated for all images are all found, can using with this image at a distance of the caption of enough nearly (or nearest) as caption associated with it.In this case, can utilize optimization method to make to realize the distance sum minimum between image block and the caption text block of Optimum Matching.
Here, can adopt bipartite graph Optimum Matching method to realize the distance sum minimum between image block and the caption text block of Optimum Matching, specific as follows:
(1) structure cum rights bipartite graph G={X, Y, E}
As shown in Figure 1, in this bipartite graph, image block set and the set of caption text block, respectively as two subclass of X, Y of bipartite graph, are expressed as to X={X
1, X
2... X
i... X
nand Y={Y
1, Y
2... Y
j... Y
m, wherein, n is the number of image block in the space of a whole page, the numbering that i is image block, and m is the number of caption text block in the space of a whole page, j is the numbering of caption text block.E={e
ijrepresent the limit set of connect Vertex set X and Y, element e wherein
ijpresentation video piece X
iwith caption text block Y
jlimit, its weights ω
ijfor image block X
icentral point and the caption text block Y of boundary rectangle frame
jthe central point of boundary rectangle frame between Euclidean distance.
(2) utilize bipartite graph Optimum Matching algorithm to obtain the Optimum Matching of image block and caption text block
In the time of specific implementation, can be by the limit e in bipartite graph shown in Fig. 1
ijweights ω
ijnegate, and utilize KM (Kuhn-Munkras) maximum weight matching algorithm to carry out optimum Perfect matching, has the image of least weight match algorithm result and caption text block image block and the caption text block as Optimum Matching thereby obtain.
When the number of the image block on the space of a whole page and caption text block is not one by one at once, by subclass polishing few number, that is, the number of two subclass is equated with dummy node, and give the weights of a large number as virtual limit.
After correctly identifying the incidence relation of image and caption, utilize these incidence relations to improve the recognition effect of reading order, specific as follows:
(1) from the text block of the space of a whole page, remove caption text block, can utilize existing reading order method to determine the reading order of all the other text block and image block;
(2) after caption text block being turned back to the image block matching in reading order, thereby obtain complete reading order.
By this method, both guaranteed in sequencer procedure, logical relation closely image and caption can not split by other document object, avoid again merging prematurely image and caption easily causes the problem of the overlapping execution that affects sort algorithm between space of a whole page piecemeal, thereby improved to a great extent the accuracy of reading order identification.
Here, be noted that according to the caption of the inventive method identification and not only can be used for the incidence relation of recognition image and caption, but also can be used for utilizing any other of caption to apply, such as image retrieval etc.; Not only can be used for improving the recognition effect of reading order according to the image of the inventive method identification and the incidence relation of caption, but also any other that can be used for the incidence relation that need to utilize image and caption apply, such as image retrieval etc.; Can be used for that space of a whole page content is reset and information extraction etc. need to utilize any application of reading order according to the improved reading order of the inventive method.Therefore, can need to export respectively the incidence relation of reading order, image block and the caption text block of identification according to the present invention, the caption text block of identification, the text block of arranging according to the reading order of identification and image block according to practical application uses for the application of any these identifying informations of needs.
In order to realize above method, the invention provides a kind of layout information recognition device.With reference to Fig. 2, this device can comprise that reading unit 1, caption recognition unit 2, matching unit 3, reading order improve unit 4 and output unit 5, wherein, reading unit 1 reads the space of a whole page to be identified, separate character text object and image object in this space of a whole page, and character text object merging is become to text block, image object is left to image block; Caption recognition unit 2 identifies caption text block from the text block merging; Matching unit 3 utilizes optimization method to carry out Optimum Matching to image block and caption text block, thereby obtains the image block and the caption text block that are associated; Reading order improves unit 4 and from the text block of the space of a whole page, removes caption text block, and determines the reading order of all the other text block and image block, after then caption text block being turned back to the image block matching in reading order; Output unit 5 needs the incidence relation of reading order, image block and the caption text block that can export respectively identification, the caption text block of identification, the text block of arranging according to the reading order of identification and image block to use for any application that need to utilize these identifying informations according to practical application.The concrete operations of these unit are identical with the corresponding steps in said method, therefore, omit its detailed description.
Below, will be described in detail specific implementation of the present invention by specific embodiment.
(the first embodiment)
In the present embodiment, adopt e-book " 21 century Basis of Computer Engineering study course " (publishing house of Beijing University of Post & Telecommunication), this e-book has 317 pages, and the space of a whole page to be identified as shown in Figure 3, carrys out the incidence relation of recognition image and caption based on bipartite graph Optimum Matching.
With reference to Fig. 4, the recognition methods in the present embodiment comprises the following steps:
Step S1, read the page and separate text object and image object
In the present embodiment, as shown in the rectangle frame in Fig. 3, wherein there are four image blocks and five text block in Segment situation.
Step S2, identification caption text block
In the present embodiment, by being set, degree of confidence determines whether current text piece is caption text block.With reference to Fig. 5, this step is specific as follows:
Step S21, calculating font size degree of confidence Q1
The font size of the main font of all character texts in the font size/space of a whole page of the main font of Q1=current text piece
Wherein, about the calculating of main font, the font that in employing prior art statistics certain limit, the frequency of occurrences is the highest is as main font.In the present embodiment, the font size of the main font of caption text block is 9, and in the page, the font size of the main font of all characters is 10.56, degree of confidence Q1=9/10.56=0.85.
Step S22, calculating range image degree of confidence Q2
Whether Q2=approaches with image block distance
In the present embodiment, four caption text block approach with image block position respectively, thereby degree of confidence Q is 1.
Step S23, calculating number of words degree of confidence Q3
The average word number of the word number/space of a whole page text block in Q3=current text piece
In the present embodiment, the word number of four caption text block is respectively 10,12,11,11, and in the page, the average word number of text block is 25, and therefore, degree of confidence Q3 is respectively 0.4,0.48, and 0.44 and 0.44.
Step S24, calculating form of expression degree of confidence Q4
Whether Q4=meets the regular expression of caption
In the present embodiment, regular expression is defined as: ^ (figure [[: space :]] * [[: numeral :]]+([.] [[: numeral :]]+| ([[: numeral :]]+))), be that shape is as conventionally forms such as " Fig. 1-1 " " Fig. 1 .1 ", four caption text block all meet this form, thereby degree of confidence Q4 is 1.Certainly, should be appreciated that, above-mentioned regular expression is only to represent whether current text piece meets the exemplary realization of the form of expression of caption, anyly expresses the form of expression whether current text piece meet caption and all should be included in protection scope of the present invention.
Step S25, the overall degree of confidence R of weighted calculation
R=(u×Q1+v×Q2+w×Q3+x×Q4)/(u+v+w+x)
Wherein, u, v, w, x represents weighting coefficient, is natural number, gets in the present embodiment u=3, v=2, w=1, x=1, the overall degree of confidence of four caption text block is respectively 0.85,0.86 as calculated, and 0.85 and 0.85.
Step S26, judge whether overall degree of confidence R exceedes threshold value r, if R >=r judges in step S27 that current text piece is caption text block, if R < is r, in step S28, judge that current text piece is not caption text block.In the present embodiment, getting threshold value r is 0.7,, in the time that overall degree of confidence exceedes 0.7, judges that current text piece is caption text block, and therefore, in Fig. 3, four caption text block all can be correctly validated.
The bipartite graph of step S3, construct image piece and caption text block also calculates weights
In the present embodiment, cum rights bipartite graph G={X as shown in Figure 6 a of structure, Y, E}, that is, and using the image block set in Fig. 3 and the set of caption text block respectively as the X of bipartite graph, two subclass of Y, that is, X={X
1, X
2, X
3, X
4, Y={Y
1, Y
2, Y
3, Y
4, and gather the limit e in E using the Euclidean distance of the central point of image block boundary rectangle frame and the central point of caption text block boundary rectangle frame as limit
ijweights ω
ij.Therefore, in the present embodiment, need to calculate respectively ω
11, ω
12, ω
13, ω
14, ω
21, ω
22, ω
23, ω
24, ω
31, ω
32, ω
33, ω
34, ω
41, ω
42, ω
43, ω
44, and due to picture number and caption number correspondence one by one, so without polishing node.
Step S4, utilize KM algorithm to find the incidence relation between image block and caption text block
In the present embodiment, the target of optimization is to make the weights sum on the limit that in matching result, all couplings are right as far as possible little, therefore, need to calculate the least weight match algorithm of bipartite graph.In actual realization, the weights on all limits are implemented to inversion operation, and apply KM maximum weight matching algorithm and calculate maximum weight matching result, this result is the least weight match algorithm result of image and caption.
With reference to Fig. 7, KM algorithm is implemented as follows:
A) provide initial label
Wherein, in the present embodiment, n and m are 4;
B) obtain limit collection E
l={ (xi, y
j) | l (xi)+l (y
j)=ω ij}, G
l=(X, Y, E
l) and G
lin one coupling M;
C) judge whether all nodes of saturated X of M, if all nodes of the saturated X of M carry out d step, otherwise carry out e step;
D) judge that M is the Optimum Matching of G, and finish to calculate;
E) in X, look for a M unsaturation point x
0, make A ← { x
0, B ← φ, A, B is two set;
F) judge N
gl(A) whether equal B, if N
gl(A)=B, turns k step, otherwise carries out g step, wherein,
be with A in the node set of node adjacency;
G) look for a node y ∈ N
gl(A)-B;
H) judge that whether y is M saturation point, if y is M saturation point, carries out i step, otherwise carries out j step;
I) find out the match point z of y, make A ← A ∪ z}, { y}, turns f step to B ← B ∪;
J) there is an augmentative path P from x0 to y, make M ← M ⊕ E (P), turn c step;
K) be calculated as follows a value:
Revise label:
L) ask E according to l '
l 'and G
l ';
M) make l ← l ', G
l← G
l ', turn g step.
Can obtain the incidence relation of image and caption by above KM algorithm, that is, and to each image block X
ifind the caption text block Y of coupling
j.In the present embodiment, as shown in Figure 6 a, four images and four captions can form complete bipartite graph, and matching result is as shown in line in Fig. 6 b.If utilize existing distance near principle determination methods, only depend on distance and the pattern of single image and caption, easily obscure incidence relation, for example image block 3 and image block 4 are all close with caption text block 3 distances, cannot correctly judge the incidence relation of image and caption.And by the present invention, can find global optimum's incidence relation, that is, can image block 3 is associated with caption text block 3, image block 4 is associated with caption text block 4.
The whole image block matching and caption text block in step S5, the output space of a whole page, and for improvement of the recognition effect of reading sequence of layout
Be implemented as follows:
A) under the prerequisite of incidence relation that retains image and caption, from the text block of the space of a whole page, remove caption text block;
B) whole other the space of a whole page piecemeals that step a remained, adopt existing method to carry out reading order identification;
C), after identifying reading order, after caption text block is turned back to the image block matching in reading order, obtain complete reading order.
Fig. 8 has shown and utilizes the existing reading order recognition methods based on XY tree Segment (for example can be referring to " Optimized XY-cut for Determining a Page ReadingOrder ", Proceedings of the Eighth International Conference onDocument Analysis and Recognition, 2005) page shown in Fig. 3 is carried out to the design sketch of reading order sequence, Fig. 9 has shown the design sketch that utilizes the inventive method the page shown in Fig. 3 to be carried out to reading order sequence, wherein, broken line represents reading order.From this two width, figure can find out, in Fig. 8, image block 1 and its caption text block 1 and image block 2 are split with its caption text block 2, and therefore, the sequence of this part is reasonable not; And in Fig. 9, logical relation closely image block 1 is not split with its caption text block 2 with its caption text block 1 and image block 2, but read according to the order of " image block 1 → caption text block 1 → image block 2 → caption text block 2 ", therefore, the accuracy that has improved reading order identification, improvement effect is obvious.
(the second embodiment)
In the present embodiment, as an example of the 165th page of e-book " 21 century Basis of Computer Engineering study course " example, the processing of the present invention to image block number and the unequal situation of caption text block number is described.Generally, when image block number and caption text block number are when unequal, the number of image block can be more than the number of caption text block.
As shown in figure 10, in this page, in last character block, have one with civilian image block 5, and image block 5 and image block 3 are all very close to the distance of caption text block 3.If only depend on distance and the pattern of single image and caption, easily obscure incidence relation.And in the present embodiment, in bipartite graph with dummy node polishing caption text block set Y, and give a large number (such as, 9999) as the weights on virtual limit, all the other implementation methods are identical with the first embodiment.By this method, can correctly identify matching relationship, that is, image block 1 to image block 4 with caption text block 1 to caption text block 4 Corresponding matchings respectively, and image block 5 is isolated without coupling caption.
Equally, matching result is applied to improvement reading sequence of layout, the ranking results obtaining, as shown in the broken line in Figure 10, meets people's reading habit.
Below with reference to drawings and Examples, the present invention be have been described in detail; but; should be appreciated that, the present invention is not limited to above disclosed specific embodiment, and the modification that any those skilled in the art easily expects on this basis and modification all should be included in protection scope of the present invention.