The height-width relationship of text blocks is an important consideration in automatic document layout design. Knowledge of this relationship enables intelligent tradeoffs between horizontal spaces and vertical spaces in documents.
Conventionally, the height-width relationship of text blocks is determined through replacement of the text content in the text blocks under different widths and through a determination of the corresponding heights. This method results in discrete pairs of widths and heights and the results are typically error-free representations of the text block height-width relationships. Although this method provides an accurate relationship between the heights and the widths of the text blocks, implementation of this method typically requires a great deal of time and processing power. For instance, a document containing ten text blocks, each having ten height-width combinations would require the processing of ten to the tenth power of possible combinations. The computation power and time required by processing of this magnitude often exceed practical limits.
Accordingly, it would be desirable to be able to determine the height-width relationships of text blocks in more efficient and less expensive manners.
A method for establishing a height-width estimation model for a text block is disclosed herein. In the method, a discrete form of a relationship between the height and the width of the text block is calculated. In addition, at least one coefficient in a polynomial function depicting the relationship between the height and the width is calculated based upon the calculated discrete form and the model is established based upon the calculated at least one coefficient. The model provides a closed form function for estimation of the text block heights associated with one or more widths.
Features of the present invention will become apparent to those skilled in the art from the following description with reference to the figures, in which:
For simplicity and illustrative purposes, the present invention is described by referring mainly to an exemplary embodiment thereof. In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention. It will be apparent however, to one of ordinary skill in the art, that the present invention may be practiced without limitation to these specific details. In other instances, well known methods and structures have not been described in detail so as not to unnecessarily obscure the present invention.
As described in greater detail herein below, a method is presented to enable the determination of a closed form model that enables the relatively accurate estimation of text block heights for given widths. The closed form model is in the form of a polynomial function containing one or more coefficients that may be calculated by performing a statistical regression analysis of the relationships based upon the actual heights and the widths of the text blocks. More particularly, in the method, a lookup table is created through actual text placement, using conventional methods. The one or more coefficients in the polynomial function are calculated using statistical regression techniques. In addition, the calculated one or more coefficients may be replaced into the polynomial function to establish the height-width estimation model. The term “polynomial”, as used throughout the present disclosure, may be defined to include a polynomial function of the width “w” and of its reciprocal “1/w”.
Various forms and orders may be used for the statistical regression depending upon, for instance, the actual application scenario. In one regard, the relationships between the heights and the widths of the text blocks may be used as a foundation for simultaneous content adaptation and layout adjustment using, for instance, the Simplex algorithm.
Through implementation of examples of the present invention, a closed mathematical formula is provided to describe the height-width relationship of text blocks. In addition, the accuracy of the estimation may be adjusted by using different terms in the statistical regression. Thus, for instance, adjustments in the layouts of images containing text blocks may be made in a more efficient and less expensive manner as compared with previously known layout adjustment techniques.
With respect first to
As shown in
The text blocks 104-110 and the image block 112 may be considered as failing to utilize all of the available space in the document 102 to provide an aesthetically pleasing arrangement. For instance, a relatively large space 114 exists between the image block 112 and a right side of the document 102. In addition, the arrangement of objects in the layout 100 generally does not provide a balanced use of horizontal and vertical spaces.
The layout 100 may thus be modified by moving the image block 112 to reduce the size of the space 114 as shown in
The text blocks that have been modified are text blocks 106 and 110. The modified version of text block 106 corresponds to text block 118 in
The relationships between the heights and widths of the text blocks 104-110, 118-122 may be determined, for instance, to enable a desirable tradeoff between the horizontal space and the vertical space in the layout 100 to be made. The relationship between the heights and widths of text blocks has typically been determined through an estimation method that actually replaces the text content into various text containers having different widths to determine this relationship. An example of a result of this estimation method is shown in Table 1 below, which illustrates discrete pairs of widths and heights. The relationships between the various heights and widths shown in Table 1 are considered to be “error-free” representations because the relationships are determined through actual text placement into differently sized text blocks.
Although the relationships denoted in Table 1 may be employed to determine the heights and widths of the modified text blocks 118, 120, and 122, the amount of time and processing power required to determine the values contained in Table 1 for all of the text blocks 118, 120, and 122 may be relatively high. In addition, determination of these values becomes increasingly more difficult as the number of text blocks increases.
As will be described in greater detail herein below, closed formulas are developed to more easily enable estimations of the height-width relationships of text blocks. In one regard, the amount of time and processing power required to determine the height-width relationships of text blocks may substantially be reduced through implementation of the closed formulas disclosed herein. In addition, the closed formulas described herein may enable the use of systematic, numeric optimization-based layout adjustment algorithms, such as, constraint satisfaction solutions.
With reference to
The layout adjustment system 202 may comprise a general computing environment and includes a controller 204 configured to control various operations of the layout adjustment system 202. The controller 204 may comprise a microprocessor, a micro-controller, an application specific integrated circuit (ASIC), and the like. Data may be transmitted to various components of the layout adjustment system 202 over a system bus 206 that operates to couple the various components of the layout adjustment system 202. The system bus 206 represents any of several types of bus structures, including, for instance, a memory bus, a memory controller, a peripheral bus, an accelerated graphics port, a processor bus using any of a variety of bus architectures, and the like.
One or more input devices 208 may be employed to input information into the layout adjustment system 202. The input devices 208 may comprise, for instance, a keyboard, a mouse, a scanner, a disk drive, removable media, flash drives, and the like. The input devices 208 may be used, for instance, to input documents or representations of the documents (that is, the document in code format, which is referred to herein after as a “document” for purposes of simplicity) to the layout adjustment system 202. The input devices 208 are connected to the controller 204 through an interface 210 that is coupled to the system bus 206. The input devices 208 may, however, be coupled by other conventional interface and bus structures, such as, parallel ports, USB ports, etc.
The controller 204 may be connected to a memory 212 through the system bus 206. Generally speaking, the memory 212 may be configured to provide storage of software, algorithms, and the like, that provide the functionality of the layout adjustment system 202. By way of example, the memory 212 may store an operating system 214, application programs 216, program data 218, and the like. In this regard, the memory 212 may be implemented as a combination of volatile and non-volatile memory, such as DRAM, EEPROM, MRAM, flash memory, and the like. In addition, or alternatively, the memory 212 may comprise a device configured to read from and write to a removable media, such as, a floppy disk, a CD-ROM, a DVD-ROM, or other optical or magnetic media.
The memory 212 may also store modules programmed to perform various layout adjustment functions. More particularly, the memory 212 may store a discrete height-width determination module 220, a statistical regression calculation module 222, and a layout adjustment module 224. The discrete height-width determination module 220 generally operates to calculate the discrete form of the height-width relationship of text blocks. The statistical regression calculation module 222 generally operates to run a regression equation to approximate the height of a text block as a polynomial function of the width of the text block based upon the determined discrete height-width relationship.
The controller 204 may implement the discrete height-width determination module 220, more particularly, to determine the discrete relationships of the heights and widths of text blocks through actual text placement. That is, the relationships between the heights and widths of the text blocks contained in a document may be determined through an estimation method that actually replaces the text content into various text containers having different widths to determine the discrete height-width relationship. The output of this estimation method may be used to populate a lookup table, such as Table 1 provided above.
The controller 204 may implement the statistical regression calculation module 222 to calculate a closed formula for the determination of the relationship between various heights and widths of text blocks. More particularly, the statistical regression calculation module 222 may calculate one or more coefficients in the closed formula through statistical regression calculations. Once the coefficients of the closed formula have been calculated, the closed formula may be used to estimate the relationships between the heights and the widths of a text block. In one instance, the height in the closed formula comprises a polynomial function of the width of the text block. For instance, if the text block is rectangular, heuristically, the width (w) and the height (h) should roughly follow a hyperbolic format:
w*h=a, Equation (1)
where “a” is a constant determined by text content, font style, font size, and the actual text placement algorithm. Equation (1) may be rewritten to solve for the height (h) as follows:
h=a/w Equation (2)
However, Equation (2) is considered to be a rough estimate because, extra padding space may be needed for each line, the text lines are discrete in nature (that is, text placement may only generate integer numbers of lines), extra space is wasted at the end of the text block, and there may be other subtle adjustments that may be performed by the text placement algorithm for aesthetic considerations. It has been found that these factors are relatively minor adjustments to the basic form of Equation (2). Therefore, these factors may be treated as terms of different orders and the coefficients (C) may be calculated through regression as described above. Thus, a more generalized form of h(w) is as follows:
h=C0*w+C1+C2/w+C3/(w2). Equation (3)
Although higher order terms may be included in Equation (3), the higher order terms have been omitted because they may be considered as being relatively insignificant. It should, however, be understood that Equation (3) may include the higher order terms without deviating from a scope of the layout adjustment system 202.
In addition, since the height (h) is the number of lines and may only be an integer, a round ( ) function is used to get the nearest integer of h. Thus, the final estimate may be expressed as:
h′=round(h), Equation (4)
which yields the nearest integer of h.
The results of experimental results conducted under five different restriction conditions imposed on the terms in Equation (3) have been listed below in Table 2. In addition,
The terms recited in Table 2 were obtained through input of the actual heights and widths from Table 1 into Equation (3) and running a conventional regression method, for instance, through software such as, MATLAB, MS EXCEL, and the like, to obtain the best parameters, which are represented as the terms in Table 2. It should therefore be understood that the values for the coefficients C0-C3 represented in Table 2 are for illustrative purposes and that the coefficients C0-C3 may have other values without deviating from a scope of the layout adjustment system 202. It should also be understood that the values for the coefficients C0-C3 will vary according to the actual relationships between the heights and the widths of the text blocks as set forth, for instance, in Table 1.
As shown in Table 2, the regression method was run without restrictions on the coefficients C0-C3 for the first series. In addition, restrictions were imposed on respective ones of the coefficients C0-C3 in Series 2-5, as noted in the column entitled “Restrictions”. More particularly, in the regression method, one or more of the coefficients C0-C3 were forced to zero and the remaining coefficients C0-C3 were determined. The number of coefficients C0-C3 that are determined generally controls the complexity and accuracy of the regression method. More particularly, the determination of the coefficient C0-C3 values in Series 1 may be considered as being the most complex and the most accurate in terms of the models employed in the Series 1-5.
Table 2 also includes a column entitled “RMSE”, which is an abbreviation for the Root Mean Square Error. The RMSE may generally be determined by calculating the squared deviations of the heights calculated through the regression equations with the actual heights in Table 1, averaging the squares, and taking the square root of the average. As shown in Table 2, the RMSE for the first four series were less than one line. The first model (Series 1) has the lowest RMSE and is therefore the most tunable of the five models. The third model (Series 3) provides the greatest balance between complexity and accuracy of the models. The fifth model (Series 5) has the highest RMSE because it attempts to establish a pure linear relationship (h=C0*w+C1), which, in most cases, does not represent the actual relationships between heights and widths of the text blocks.
However, in certain instance, such as, when adjustments to the layout are relatively minor, the fifth model, which is a linear model, may describe the relationship between the height and the width of a text block with sufficient accuracy. As shown in Table 3, when the degree of adjustment is relatively minor, for instance, below 30%, the max error, which denotes the largest estimation error for any height-width combination used in determining the values of the coefficients C0 and C1, were calculated as being 1 line. More particularly, the max errors were determined by comparing the heights estimated through use of the coefficients C0 and C1 for certain widths with the heights corresponding to the widths listed in Table 1.
As such, for relatively minor layout adjustments, the linear form of Equation (3) may be employed to estimate the heights of various text block widths. In addition, because the linear form may be employed, the conventional Simplex algorithm may be employed to solve a layout adjustment problem in an efficient manner. The layout adjustment problem may be defined as a problem associated with determining a solution layout that satisfies one or more constraints in a layout.
In Table 3, if an application enables the width to change from a minimum width (min_width) to a maximum width (max_width), the degree of adjustment may be defined as:
(max_width−min_width)/(min_width+max_width). Equation (5)
With reference back to Table 2, the column entitled “Max Error” generally denotes the largest estimation error for any height-width combination used in determining the values of the coefficients C0-C3. More particularly, the max errors were determined by comparing the heights estimated through use of the coefficients C0-C3 for certain widths with the heights corresponding to the widths listed in Table 1. The results of the error determinations have been illustrated in the graph 300 depicted in
As may be seen from the results illustrated in Table 2 and the graph 300, the model represented by Equation (3) may be used as a closed formula to estimate height values for various width values. Therefore, the amount of processing power and time required to estimate the heights corresponding to various widths of text blocks may be significantly lower than is required with known height estimation techniques. In addition, the model represented by Equation (3) may be applied in many instances to non-rectangular and relative short text blocks.
In one regard, the estimation scheme described above may be used by the controller 204 in implementing the layout adjustment module 224. More particularly, for instance, the closed formula of Equation (3) with the coefficients C0-C3 calculated in the manners described above may be employed to determine the height-width relationships of one or more text blocks contained in a document. In addition, these relationships may be used in setting and/or adjusting the layout of text blocks and/or image blocks in the document.
The regression described above may be conducted on a subset or sampling of the height-width combinations contained in Table 1. For instance, the number of height-width combinations used in the regression techniques described above to determine the coefficients C0-C3 may equal to some number less than the entire set of height-width combinations listed in Table 1. However, the number of samples must be at least equal to the number of parameters in the model represented by Equation (3). Through use of the reduced number of samples, the time and computing power required to determine the model represented by Equation (3) may be substantially reduced.
According to another embodiment, parameters for the model may be based upon their physical meanings. For instance, instead of employing statistical regression to experimentally estimate the model parameters (coefficients C0-C3), a more “white-box” approach may be employed. An example of this approach is provided below.
Initially, if a text block width is allowed to be infinite, the text is placed and the occupied length of the text (assigned as “a”) is obtained. Secondly, let “w” be the width of the text and “m” be the number of lines needed for the width. On average, the end of each line will leave an unused space of b/2, where b is the average width of a word. In addition, the end of the last line will leave an unused space of w/2. Based upon these assumptions, a relationship between “a”, “m”, and “w” may be represented as follows:
a=m*w−(m−1)*b/2−w/2. Equation (6)
Multiplying both sides of Equation (6) by 2 yields:
2*a=2*m*w−(m−1)*b−w. Equation (7)
Equation (7) may be re-written as:
2*a=(2*w−b)*m+b−w. Equation (8)
In addition, Equation (8) may be re-written as:
2*a+w−b=(2*w−b)*m. Equation (9)
Equation (9) is equivalent to:
m=(w+2*a−b)/(2*w−b), Equation (10)
which is equivalent to:
=[½+(2*a−b)/(2*w)]/[1−b/(2*w)],
which is approximately equivalent to:
≈[½+(2*a−b)/(2*w)]*[1+b/(2*w)+b*b/(4*w*w)],
which is also approximately equivalent to:
≈½+(a−b/4)/w+(a*b/2−b*b/8)/(w*w),
when w>>b/2.
For purposes of illustration, it is assumed that “a” has been measured to be 7485, and b is 5.6*6.04 (5.6 is assumed to be the average number of characters in a word for that paragraph, and 6.04 is assumed to be the average width of each character for the selected font).
Thus, m may be estimated by:
m=0.5+7476.5/w+126443/(w2). Equation (11)
Application of this model to the data contained in Table 1 results in a Max Error of 1 and a RMSE of 0.43, which may be sufficiently accurate in calculating the height-width relationships.
The height-width relationships of one or more text blocks contained in a document, which may be used in setting and/or adjusting the layout of text blocks and/or image blocks in the document or data pertaining thereto, may be transmitted outside of the layout adjustment system 202 through one or more adapters 226. In a first example, the adjusted layout 100′ data may be transmitted to a network 228, such as, an internal network, an external network (the Internet), etc. In a second example, the adjusted layout 100′ data may be outputted to one or more output devices 230, such as, displays, printers, facsimile machines, etc.
With reference to
As shown in
At step 404, one or more of the coefficients in a polynomial function depicting the relationship between the height and the width of a text block may be calculated. As described above, the model may comprise a polynomial function, such as, Equation (3), and the one or more coefficients C0-C3 may be calculated using regression techniques with the discrete heights and widths calculated at step 402. Once the one or more coefficients C0-C3 have been calculated, the values of the coefficients C0-C3 may be put into the model to thereby establish the model as indicated at step 406. In this regard, the model may be established to contain a single unknown, height, for a given width. As such, the model may be implemented to estimate the height associated with a given width for a text block.
With reference now to
The method 420 may be initiated in response to a variety of stimuli at step 422. The method 420 may be initiated, for instance, in response to a command to become initiated by a user, in response to receipt of document layout change request, etc. In any respect, a document may be received at step 424 and at least one text block in the document may be identified at step 426.
At step 428, the discrete form of the height-width relationship of the at least one text block may be calculated. As described above with respect to step 402 (
At step 434, the height of the at least one text block may be estimated through implementation of the model established in step 432. More particularly, the height of the at least one text block may be estimated for one or more widths through use of the model. Knowledge of the estimated heights for various widths may be employed to adjust the layout of the document, as indicated at step 436.
The method 420 may end as indicated at step 438 following adjustment of the document layout. Alternatively, the method 420 may be repeated to adjust the document layout for a number of times or until a desired document layout is reached. In one regard, the desired document layout may comprise a layout in which horizontal and vertical spaces are arranged in an aesthetically pleasing manner.
With reference now to
At step 502, the relationship of the height (m) and the width (w) of a text block may be set according to the following equation:
m=½+(a−b/4)/w+(a*b/2−b*b/8)/(w*w), Equation (12)
where “a” is an occupied length of the text if a text block width is allowed to be infinite, and “b” is the average width of a word in the text block. A manner in which Equation (12) may be derived is described herein above, for instance, as a derivation of Equation (10).
At step 504, the coefficients “a” and “b” may be replaced with their actual values. In addition, at step 506, the height (m) and the width (w) may be solved for to establish the height-width estimation model for the text block.
Through implementation of either of the methods 400, 420, 500 the amount of computing resources required to estimate the heights corresponding to various widths of text blocks may be substantially reduced as compared with traditional methods for estimating these relationships.
Some or all of the operations illustrated in the methods 400, 420, 500 may be contained as a utility, program, or a subprogram, in any desired computer accessible medium. In addition, the methods 400, 420, 500 may be embodied by a computer program, which can exist in a variety of forms both active and inactive. For example, they can exist as software program(s) comprised of program instructions in source code, object code, executable code or other formats. Any of the above can be embodied on a computer readable medium, which include storage devices and signals, in compressed or uncompressed form.
Exemplary computer readable storage devices include conventional computer system RAM, ROM, EPROM, EEPROM, and magnetic or optical disks or tapes. Exemplary computer readable signals, whether modulated using a carrier or not, are signals that a computer system hosting or running the computer program can be configured to access, including signals downloaded through the Internet or other networks. Concrete examples of the foregoing include distribution of the programs on a CD ROM or via Internet download. In a sense, the Internet itself, as an abstract entity, is a computer readable medium. The same is true of computer networks in general. It is therefore to be understood that any electronic device capable of executing the above-described functions may perform those functions enumerated above.
The computer system 600 includes one or more controllers and a processor 602. The processor 602 may be used to execute some or all of the steps described in the methods 400, 420. Commands and data from the processor 602 are communicated over a communication bus 604. The computer system 600 also includes a main memory 606, such as a random access memory (RAM), where the program code for, for instance, the controller 204, may be executed during runtime, and a secondary memory 608. The secondary memory 608 includes, for example, one or more hard disk drives 610 and/or a removable storage drive 612, representing a floppy diskette drive, a magnetic tape drive, a compact disk drive, etc., where a copy of the program code for the layout adjustment system 202 may be stored.
The removable storage drive 610 reads from and/or writes to a removable storage unit 614 in a well-known manner. User input and output devices may include a keyboard 616, a mouse 618, and a display 620. A display adaptor 622 may interface with the communication bus 604 and the display 620 and may receive display data from the processor 602 and convert the display data into display commands for the display 620. In addition, the processor 602 may communicate over a network, for instance, the Internet, LAN, etc., through a network adaptor 624.
It will be apparent to one of ordinary skill in the art that other known electronic components may be added or substituted in the computer system 600. In addition, the computer system 600 may include a system board or blade used in a rack in a data center, a conventional “white box” server or computing device, etc. Also, one or more of the components in
What has been described and illustrated herein is a preferred embodiment of the invention along with some of its variations. The terms, descriptions and figures used herein are set forth by way of illustration only and are not meant as limitations. Those skilled in the art will recognize that many variations are possible within the spirit and scope of the invention, which is intended to be defined by the following claims—and their equivalents—in which all terms are meant in their broadest reasonable sense unless otherwise indicated.