Summary of the invention
The invention proposes a kind of printed page analysis method and apparatus, quickly and effectively can accurately mark and identify each version
Surface element.
According to the first aspect of the invention, a kind of printed page analysis method is the following steps are included: input step, input include more
The image to be processed of a space of a whole page element;Plot step draws closed curve in the region where each space of a whole page element;Adaptively
Set-up procedure adaptively adjusts the closed curve to the edge of the space of a whole page element;Extraction step, according to adaptive adjustment
The encapsulated coil to the edge of the space of a whole page element extracts each space of a whole page element from the image to be processed.
According to the second aspect of the invention, the closed curve is rectangle frame, which includes extending in a first direction
The first opposite side and the second opposite side for extending in a second direction;And the adaptive set-up procedure includes by first opposite side
It adaptively adjusts with second opposite side to the edge of the space of a whole page element;The extraction step include according to adaptively adjust to
First opposite side and second opposite side at the edge of the space of a whole page element extract each space of a whole page from the image to be processed
Element.
According to the third aspect of the invention we, the space of a whole page element includes picture, title and text, also, described adaptive
Set-up procedure include: judge first opposite side and second opposite side be in blank space or push down picture or push down title or
The text of text;If pushing down picture or pushing down the text of title or text, carry out first extension, will first opposite side with
Second opposite side extends to the edge of the space of a whole page element;If executing first in blank space and shrinking, by described first pair
Side and second opposite side are contracted to the edge of the space of a whole page element.
According to the fourth aspect of the invention, height threshold and width threshold value have been pre-defined for title and text, height
The space of a whole page element for being respectively greater than the height threshold and the width threshold value with width is considered as text, is carrying out the first extension
Or after first shrinks, judge whether the height of the rectangle frame and width are greater than height threshold and width threshold value;If it is,
The space of a whole page element is judged for text, carries out the second extension and third extension;If it is not, then judging the space of a whole page element for mark
Topic, without the second extension and third extension, wherein second extension includes by first opposite side in the first direction
On extend to the edge of the space of a whole page element;The third extension includes extending second opposite side in this second direction
To the edge of the space of a whole page element.
According to the fifth aspect of the invention, in second extension, first opposite side and the space of a whole page element are obtained
The spacing between next row black pixel point in said first direction carries out the spacing and defined first spacing threshold
Compare, if the spacing is less than first spacing threshold, first opposite side is extended into a pixel wide, and repeat
It states and compares;If the spacing is greater than first spacing threshold, stop second extension.
According to the sixth aspect of the invention, in third extension, second opposite side and the space of a whole page element are obtained
The spacing between next row black pixel point in this second direction carries out the spacing and defined second spacing threshold
Compare, if the spacing is less than second spacing threshold, second opposite side is extended into a pixel wide, and repeat
It states and compares;If the spacing is greater than second spacing threshold, stop the third extension.
According to the seventh aspect of the invention, it shrinks in first extension, described first, second extension and described the
After three extensions, the outside edges of first opposite side and second opposite side towards the space of a whole page element are extended into predetermined quantity
Pixel wide.
According to the eighth aspect of the invention, a kind of printed page analysis device includes: input unit, and it includes multiple for being used to input
The image to be processed of space of a whole page element;Display unit shows the image to be processed inputted;Detection unit, when user is each
When drawing closed curve on space of a whole page element region, the detection unit detects the position of the closed curve;Adjustment unit,
It is used to adjust the closed curve;Extraction unit is used to be extracted from the image to be processed according to the closed curve
The space of a whole page element;And processing unit, controlling the adjustment unit according to the testing result of the detection unit will be described
Closed curve is adjusted to the edge of space of a whole page element, and controls the extraction unit and extract each space of a whole page element.
According to the ninth aspect of the invention, the closed curve is rectangle frame, which includes extending in a first direction
The first opposite side and the second opposite side for extending in a second direction, and the detection unit detects first opposite side and described the
The position of two opposite side;The processing unit controls the adjustment unit for described first according to the testing result of the detection unit
Opposite side and second opposite side are adjusted to the edge of space of a whole page element, and control the extraction unit and extract each space of a whole page element.
According to the tenth aspect of the invention, the space of a whole page element includes picture, title and text, also, the processing is single
Member judges first opposite side according to the testing result of the detection unit and second opposite side is in blank space or to push down
Picture or the text for pushing down title or text;If pushing down picture or pushing down the text of title or text, the processing unit
It controls the adjustment unit and carries out the first extension, first opposite side and second opposite side are extended into the space of a whole page element
Edge;If the processing unit, which controls the adjustment unit, to carry out first and shrinks in blank space, will first opposite side with
Second opposite side is contracted to the edge of the space of a whole page element.
According to the eleventh aspect of the invention, height threshold and width threshold value have been pre-defined for title and text, it is high
Degree and width are respectively greater than the height threshold and the space of a whole page element of the width threshold value is considered as text, are carrying out described the
After one extension or first contraction, the processing unit judges the rectangle frame according to the testing result of the detection unit
Height and width whether be greater than the height threshold and the width threshold value;If it is, described in the processing unit control
Adjustment unit carries out the second extension and third extension;If it is not, then the processing unit controls the adjustment unit without institute
State the second extension and third extension;Wherein, it is described second extension include by first opposite side in said first direction
Extend to the edge of the space of a whole page element;The third extension includes extending to second opposite side in this second direction
The edge of the space of a whole page element.
According to the twelfth aspect of the invention, in second extension, the detection unit obtains first opposite side
With the spacing between the next row black pixel point of the space of a whole page element in said first direction, the processing unit should between
Away from being compared with defined first spacing threshold, if the spacing is less than first spacing threshold, the adjustment is controlled
First opposite side is extended a pixel wide by unit, and repeats above-mentioned comparison;If the spacing is greater than first spacing
Threshold value then controls the adjustment unit and stops second extension.
According to the thirteenth aspect of the invention, in third extension, the detection unit obtains second opposite side
With the spacing between the next row black pixel point of the space of a whole page element in this second direction, the processing unit should between
Away from being compared with defined second spacing threshold, if the spacing is less than second spacing threshold, the adjustment is controlled
Second opposite side is extended a pixel wide by unit, and repeats above-mentioned comparison;If the spacing is greater than second spacing
Threshold value then controls the adjustment unit and stops the third extension.
According to the fourteenth aspect of the invention, it is described first extension, it is described first shrink, it is described second extension and it is described
After third extension, the processing unit controls the adjustment unit will be described in first opposite side and second opposite side direction
The pixel wide of the outside edges extension predetermined quantity of space of a whole page element.
Printed page analysis method and apparatus according to the present invention, it may not be necessary to the accurate location of specified space of a whole page element, so both
The efficiency for improving specified space of a whole page element can also mitigate the eye fatigue degree of operator.
Specific embodiment
The embodiment that the invention will now be described in detail with reference to the accompanying drawings.In all the appended drawings, identical label indicates identical member
Part, and omit its repeated explanation.
Regular publication, such as newspaper, space of a whole page element thereon is mostly rectangle, therefore, in text or image
Rectangle frame is drawn on equal spaces of a whole page element region, and extends the four edges of rectangle frame to the edge of space of a whole page element to carry out version
Surface analysis, this printed page analysis method efficiently solves the prior art, and that rectangle frame is drawn in number processing is difficult and not accurately
Problem, improves the efficiency and accuracy of printed page analysis, and then improves the working efficiency and number processing of number processing business
Quality.It should be understood that the one pair of them side of rectangle frame is parallel with an opposite side of space of a whole page element, another opposite side and space of a whole page member
Another opposite side of element is parallel.For convenience, in the description with left and right and on get off to indicate these two pair side.It controls and is up and down
Mutually for a user.
Illustrate printed page analysis method of the invention by taking rectangle frame as an example below.However, the present invention is not limited to rectangle frames, and
It is that any other closed curve can be selected according to the shape of space of a whole page element.
In general, the space of a whole page element during printed page analysis includes text, picture and title, the space of a whole page according to the present invention
Analysis method can draw a small square when the body part to such as newspaper draws rectangle frame in a part of text
The four edges of the rectangle frame are extended to body part using the word space and line space of text and the mean size of word by shape frame
Edge, can greatly improve in this way draw frame efficiency, can also mitigate significantly draw frame personnel eye fatigue degree.
When drawing rectangle frame to Picture section, small rectangle frame can be drawn, as long as framing picture various pieces, so that it may
The rectangle frame is extended to the edge of picture automatically using connected domain.
When drawing rectangle frame to title division, title division can be passed through to draw, using projection automatically by rectangle frame
Extend to the edge of title division.Sometimes when the surrounding margins such as title or text are larger, rectangle frame can be drawn greatly a bit with
Title or text etc. are framed, if the four edges of rectangle frame are located at blank space at this time, title or text can be automatically contracted to
Edge.The edge that the frame manually drawn can be extended to adaptively to each space of a whole page element in this way, is convenient for subsequent
Space of a whole page element extraction and content recognition processing.
Throughout the specification, white gravoply, with black engraved characters is subject to all images, the image of black matrix wrongly written or mispronounced character is carried out instead first
Color.In addition, introducing the extended method twice of rectangle frame in specification, the optimum position on side is finally obtained.For picture,
Extended method is only performed once to be sufficient.
Fig. 1 shows the block diagram of printed page analysis device of the invention.
Printed page analysis device 10 of the invention includes input unit 101, display unit 102, detection unit 103, adjustment list
First 104, extraction unit 105, processing unit 106.
When carrying out printed page analysis, user inputs image to be analyzed by input unit 101.Display unit 102 shows institute
The image to be analyzed of input, here, image to be analyzed include multiple space of a whole page elements.User is where shown space of a whole page element
Rectangle frame is drawn on region.Detection unit 103 detects the position of the four edges of rectangle frame on the image.106 basis of processing unit
The testing result of detection unit 103 judge the four edges of rectangle frame be blank space or be pressed on picture or be pressed in text or
On the text of title.
If detection unit 103 determines certain side of rectangle frame in blank space, processing unit 106 controls adjustment unit
104 are contracted to the side of rectangle frame at the edge of space of a whole page element.In the process, the pixel on 103 opposite side of detection unit clicks through
Row scanning stops shrinking if occurring the pixel that gray value is 1 (black pixel point) on side.
If detection unit 103 determines that the side of rectangle frame is pressed on picture or is pressed on the text of text or title,
Then processing unit 106 controls the edge that the side of rectangle frame is propagated outward into space of a whole page element by adjustment unit 104.
In the process, the pixel on 103 opposite side of detection unit is scanned, if gray value is 1 (black picture on side
Vegetarian refreshments) pixel quantity be less than amount threshold, then stop extending.Then, the control of processing unit 106 adjustment unit 104 will
The four edges of rectangle frame are adjusted to optimum position.M row or N column pixel are scanned on the outside of 103 opposite side of detection unit, find out first
Optimum position of a least row or column of black pixel point number as side, wherein M and N is positive integer, it is preferred that 3≤M
≤ 5,3≤N≤5.
Then, processing unit 106 judges whether rectangle frame is greater than threshold value.When the width and height of rectangle frame are respectively greater than width
Think that space of a whole page element is text when degree threshold value and height threshold, adjustment unit 104 carries out extension up and down to rectangle frame and left and right is expanded
Exhibition, otherwise it is assumed that space of a whole page element is title, without extension, in order to text and title etc. are distinguished, because title is not required to
It to carry out extending up and down again and left and right extends.
If processing unit 106 determines that rectangle frame is greater than threshold value, adjustment unit 104 executes extension up and down to rectangle frame.
Then, adjustment unit 104 executes left and right extension to rectangle frame.Expansion up and down can then be described in detail referring to figure 5 and figure 6
Exhibition and left and right extension.
Finally, adjustment unit 104 adjusts rectangle frame to optimum position.5 rows or 5 column pictures near 103 opposite side of detection unit
Element is scanned, and finds out optimum position of first least row or column of black pixel point number as side.
Below with reference to Fig. 2-4 printed page analysis method that the present invention will be described in detail.
Fig. 2 shows the schematic diagrames for drawing rectangle frame in embodiment of the present invention on newspaper.Fig. 3 shows the square of Fig. 2
Shape frame extends to the schematic diagram of space of a whole page element edges.Fig. 4 shows the overview flow chart of printed page analysis method of the invention.
As shown in figure 4, inputting image to be processed (S400) first.Here, image to be processed includes multiple space of a whole page elements.So
Afterwards, rectangle frame (S401) is drawn in the region where each space of a whole page element.
Next, the four edges for determining rectangle frame are in blank space or to be pressed on picture or be pressed in title or text
On text (S402).If being determined as blank in step S402, side is contracted to the edge (S403) of space of a whole page element.If
On the text for being judged to being pressed on picture or being pressed in title or text in step S402, then the side of rectangle frame is extended to
The edge (S404) of space of a whole page element.
In step S402, the pixel on the four edges of rectangle frame is scanned, when black pixel point on certain side
Number be greater than threshold number of pixels when, determine that the side is pressed on picture or is pressed on the text of title or text.Specifically, originally
Invention detects the four edges of rectangle frame using the method for projection, and the side of left and right two throw up and down (i.e. to horizontal direction)
Shadow, upper and lower two sides carry out left and right projection (i.e. to vertical direction) projection, if the sum of any a line projected pixel gray value
It is 0, then it represents that the side is at blank position.If the sum of any a line projected pixel gray value is greater than defined gray scale threshold
Value, then it represents that the side is pressed on picture or is pressed on the text of title or text.
In addition, using the method for projection, side is contracted to first grey scale pixel value when being shunk in step S403
The sum of the position that is not zero.When being extended in step s 404, also with the method for projection, side is extended into first picture
The sum of plain gray value is less than the position of the gray threshold.
After step S404, the four edges of rectangle frame are adjusted to optimum position (S405).M row or N column on the outside of opposite side
Pixel is scanned, and finds out optimum position of first least row or column of black pixel point number as side, wherein M and N are equal
For positive integer, it is preferred that 3≤M≤5,3≤N≤5.
Next, process proceeds to step S406, judge whether the height of rectangle frame and width are greater than height threshold and width
Spend threshold value.
Specifically, connected domain analysis is carried out to the black pixel point in rectangle frame, calculates connected domain in the rectangle frame
The left and right average headway and upper and lower average headway of mean breadth and average height and connected domain, by 3 times of average connected domain width
Add twice of connected domain or so average headway as the width threshold value, 3 times of average connected domain height is added into twice of connection
Domain is between the upper and lower away from as the height threshold.
The purpose that above-mentioned judgement is carried out in step S406 is to discriminate between the type of space of a whole page element.
In the present invention, space of a whole page element includes title, text and picture.It is drawn for the space of a whole page element needs of these three types
Different rectangle frames is made, it is specifically described below.
It, can be by rectangle when lemma is smaller and surrounding margins are larger when drawing rectangle frame in the region where title
Frame is drawn larger to frame entire title, when lemma is big or surrounding margins are smaller, can pass through title to draw square
Shape frame, as shown in the title of title and right upper portion at the top of Fig. 2.
When drawing rectangle frame in picture region, if picture is an entirety, appoint in picture region
Place one rectangle frame of drafting of anticipating is ok, and if picture is a few partial subgraph pieces of separation, as long as guaranteeing separation
Each section word picture have pixel in rectangle frame, as shown in the picture of the bottom Fig. 2.
When drawing rectangle frame in text region, it is assumed that include M row N column text in text, wherein M and N is big
In the positive integer for being equal to 3, as long as then the size of rectangle frame is arranged greater than 3 rows 3, as shown in Figure 2.
Herein it is to be appreciated that Fig. 2 is to clearly demonstrate the case where drawing rectangle frame.When practical drafting rectangle frame, often
A rectangle frame is drawn, it can all extend to the edge of space of a whole page element automatically, as shown in Figure 3.It is not in all rectangle frames in Fig. 2
The case where not extending.
That is, in step S406, if it is decided that result be it is yes, then illustrate space of a whole page element be text, if NO,
Then illustrate that space of a whole page element is title.Title is not needed to be extended again.
If judgement result is yes in step S406, rectangle frame is executed and extends (step S407) up and down.It is specific next
Say, using connected domain between the upper and lower away from and connected domain size, two sides up and down of rectangle frame are extended into the upper following of space of a whole page element
Edge.
Carry out the extension up and down in the printed page analysis method that the present invention will be described in detail below with reference to Fig. 5.
It should be noted that being only respectively greater than height threshold and width threshold value in the height and width for determining rectangle frame
Under the conditions of just execute up and down extension.Moreover, here when referring to two up and down of rectangle frame.
First, it is determined that when whether the distance between front to next line black picture element is 1 pixel (S501).If step
Judgement result is yes in S501, then whether the connected domain where judging next line black pixel point is horizontal line (S502).
In step S502, judge connected domain whether be horizontal line method are as follows: the company where next line black pixel point
The width that the height in logical domain is less than the connected domain where 1/5th and next line black pixel point of average connected domain height is big
When 5 times of average connected domain width, then it is assumed that the connected domain is horizontal line.
If determine in step S502 result be it is no, when front extends to the outside a pixel (S503), then return
Step S51 carries out next round judgement.
If judgement result is yes in step S502, stop extending (step S506).
On the other hand, if in step S501 determine result be it is no, judge whether next line connected domain average headway small
In line space threshold value (S505).
In step S505, obtain when front to next line (up or down) black pixel point spacing, and with regulation
Line space threshold value be compared.Specifically, the line space threshold value is set to: when upper and lower average headway is less than 20, being
Upper and lower average headway is multiplied by 1.5, when upper and lower average headway is more than or equal to 20, adds 10 for upper and lower average headway.
If determining that result is no in step S505, then it is assumed that when front is located at the boundary of the space of a whole page element, (top is located at
Coboundary is located at lower boundary below), stop extension (step S506).If judgement result is yes in step S505, under determining
Whether a line connected domain size is less than row connected domain size threshold value (step S507).
In step s 507, count next line connected domain mean breadth, and with defined row connected domain size threshold value into
Row compares.Specifically, connected domain size threshold value is set to connected domain mean breadth and adds 6, i.e. the mean breadth of connected domain is most
Differ 5 pixels.
If determining that result is no (encountering title or horizontal line) in step S507, then it is assumed that when front is located at the space of a whole page element
Boundary (top is located at coboundary, below be located at lower boundary), stop extension (step S506).If determining knot in step S507
Fruit be it is yes, then judge whether connected domain mean size is 0 (step S508).
In step S508, when up or down extending, if scanning to image up-and-down boundary find not yet it is black
Colour vegetarian refreshments illustrates to extend to blank space when front, then stops extending (step S506), otherwise will move to next line company when front
Then logical domain boundary carries out next round judgement (step S509).
Finally, the four edges of rectangle frame are adjusted to optimum position (S510) after step S506.Regulation on the outside of opposite side
Capable or regulation column pixel is scanned, and finds out optimum position of first least row or column of black pixel point number as side,
For example, the regulation row or regulation are classified as 5 rows or 5 column.
So far, the extension process up and down of printed page analysis method of the invention terminates.
Fig. 4 is returned, left and right extension (step S408) next is executed to rectangle frame.Specifically, connected domain or so is utilized
The side of left and right two of rectangle frame is extended to the left and right edges of space of a whole page element by the size of spacing and the size of connected domain.
Carry out the left and right extension in the printed page analysis method that the present invention will be described in detail below with reference to Fig. 6.
It should be noted that being only respectively greater than height threshold and width threshold value in the height and width for determining rectangle frame
Under the conditions of just execute left and right extension.Moreover, here at the left and right for referring to rectangle frame two.
First, it is determined that when whether the distance between front to next column black picture element is 1 pixel (step S600).If
Judgement result is yes in step S600, then whether the connected domain where judging next column black picture element is vertical line (step S601).
In step s 601, judge connected domain whether be vertical line method are as follows: when the width of connected domain is less than average connection
When the height of 1/5th and connected domain of field width degree is greater than 5 times of average connected domain height, then it is assumed that the connected domain is vertical line.
If judgement result is no in step S601, when front extends to the outside a pixel (step S602), process
Return step S600 carries out next round judgement.
If judgement result is yes in step S601, stop extending (step S606).
On the other hand, if in step S600 determine result be it is no, judge whether next column connected domain average headway small
In column pitch threshold value (step S603).
In step S603, obtain when front to next column (is turned left or turn right) spacing of black pixel point, and with regulation
Column pitch threshold value be compared.Specifically, the column pitch threshold value is set to: when left and right average headway is less than 20, being
Left and right average headway, when left and right average headway is more than or equal to 20, adds 10 multiplied by 1.5 for left and right average headway.
If the judgement result in step S603 is no, then it is assumed that when front is located at the boundary (left bit of the space of a whole page element
In left margin, the right is located at right margin), stop extension (step S606).If the judgement result in step S603 be it is yes, sentence
Determine whether next column connected domain mean size is less than column connected domain size threshold value (step S604).
In step s 604, count next column connected domain average height, and with defined column connected domain size threshold value into
Row compares.Specifically, column connected domain size threshold value is set to connected domain average height and adds 6, i.e., the average height of connected domain is most
Poor 5 pixels of multiphase.
If the judgement result in step S604 is no (encountering title or horizontal line), then it is assumed that when front is located at space of a whole page member
The boundary (left side is located at left margin, and the right is located at right margin) of element stops extension (step S606).If sentencing in step S604
Determine result be it is yes, then judge next column up and down expanded height whether change (step S605).
In step s 605, extension up and down is carried out to next column connected domain, if the column connected domain height is greater than after extension
Rectangle frame height (that is, variation) then stops left and right extension (step S606).If there is no changing after extension,
Judge whether connected domain mean size is 0 (step S607).
In step S607, when leftward or rightward extension, if the right boundary of scanning to image find not yet it is black
Colour vegetarian refreshments (connected domain mean size is 0), illustrates that the side extends to blank space, stops left and right extension (step S606), otherwise
The side moves to next column connected domain boundary (step S608), then carries out next round judgement (step S600).
Finally, the four edges of rectangle frame are adjusted to optimum position (S609) after step S606.Regulation on the outside of opposite side
Capable or regulation column pixel is scanned, and finds out optimum bit of first least row or column of black pixel point number as the side
It sets, for example, the regulation row or regulation are classified as 5 rows or 5 column.
So far, the left and right extension process of printed page analysis method of the invention terminates.
It should be noted that the flow chart of Fig. 4 illustrates only the processing step of rectangle frame adjusting stage, by rectangle frame from
Adaptation is adjusted to after the edge of space of a whole page element, also to extract space of a whole page element according to rectangle frame, although not showed that in Fig. 4,
It is this is the common knowledge in printed page analysis field.
Printed page analysis method and apparatus of the invention only need user arbitrarily to draw one on needing the space of a whole page element analyzed
A rectangle frame, rectangle frame will adaptively expand to the edge of the space of a whole page element, can greatly improve identification in this way and extract
The efficiency of space of a whole page element can also mitigate the eye fatigue degree of operator significantly.
Specific embodiment is combined to carry out further in detail the purpose of the present invention, technical scheme and beneficial effects above
Explanation.It should be understood that describing a specific embodiment of the invention merely for the sake of the purpose of illustration above, it is not intended to limit
The system present invention.Any modification, equivalent substitution, improvement and etc. done all within the spirits and principles of the present invention, should be included in
Within protection scope of the present invention.