Embodiment
Embodiments provide a kind of automatic keyline layout method and device, when using the space of a whole page material needing horizontal or longitudinal through space of a whole page to carry out cutting to carry out the printing of conjunction version, the imposition results that can cut can be obtained, avoid the waste of printing material.
As shown in Figure 3, a kind of method of automatic keyline layout that the embodiment of the present invention provides comprises:
S301, treat to choose a space rectangles region in layout space rectangles region, as current layout rectangular area from the space of a whole page.
Current layout rectangular area specifically can be chosen according to following selection rule: treat layout space rectangles region and sort according to size, preferentially choose the space rectangles region that area is maximum, or, preferentially choose the space rectangles region that area is minimum.
S302, in each page treating layout, determine that is treated a layout page, this treated layout page makeup is in described current layout rectangular area, and described in treat that at least two borders of the layout page are overlapping with two boundary lines of described current layout rectangular area.
Determine treat the layout page should layout in current layout rectangular area, the Page Range namely after layout is no more than the scope of current blank layout rectangular area.
S303, when determining the remaining area after there is layout in described current layout rectangular area, whether the shape judging described remaining area is rectangle, if, using described remaining area together with space rectangles region current on the space of a whole page as treating layout space rectangles region, if not, described remaining area is divided into two rectangular areas, using mark off two rectangular areas together with space rectangles region current on the space of a whole page as treating layout space rectangles region;
Repeat above-mentioned steps, until treat that the whole layout of each page of layout is complete, or the space of a whole page treats that layout space rectangles region can not layout be arbitrary treats the layout page.
As shown in Figure 4, after page P layout, in space rectangles region, there is remaining area A, A laterally can be divided, obtain two rectangle B and C, also A longitudinally can be divided, obtain two rectangle B ' and C '.
How concrete division rule, namely determine laterally to divide or longitudinally divide, can wide according to the space of a whole page, high, area, and each treats the combined factors considerations such as wide, high, the area of the layout page.Such as, for a page p, layout is respectively W at wide, the height of space rectangles region f, page p
p, H
p, wide, the height of space rectangles region f are respectively W
f, H
f; If W
p× (H
f-H
p)>=H
p× (W
f-W
p), then laterally divide, otherwise, longitudinally divide.Can also according to following division rule, if (W
f-W
p)>=(H
f-H
p), then laterally divide, otherwise, longitudinally divide.
Different division rules can obtain different imposition results, may be different to the utilization factor of the space of a whole page, and the cutter number finally cut also may be different, need to decide to adopt which kind of division rule according to actual conditions.Certainly, division rule is not limited only to two kinds of rules set forth above, as long as remaining area to be divided into two rectangles, finally can obtain the imposition results that can cut.
In addition, by attempting different splitting schemes, can also determine that the imposition results that utilization ratio of spaces is the highest is printed again.
As shown in Figure 5, before step S301, the method also comprises: what pre-determine the space of a whole page treats layout space rectangles region; Idiographic flow is as follows:
The wide, high of the layout page is all treated in S501, analysis, and analyzes the wide, high of the space of a whole page.
S502, according to analysis result, inquiry system knowledge base, judge whether use Layout mode, if so, perform step S503; Otherwise, perform step S504.
Layout problem can abstractly be Two-dimension Bin Packing Problem (two-dimensional bin packing problem), belong to nondeterministic polynomial (Non-deterministic polynomial, NP) complete problem, there is very high computational complexity (see GAREY M R, JOHNSON D S.Computers andintractability [M] .San Francisco:Freeman, 1979).The automatic keyline layout method of prior art, the imposition results obtained is all approximate suboptimal solution, but not optimum solution, that is, there is the waste of layout space.And for possessing the space of a whole page of certain feature and treating the layout page, there is optimum solution.System knowledge base is exactly for storing the space of a whole page that there is optimum solution and treating the characteristic of the layout page, and stores the database of corresponding optimum solution, and this optimum solution indicates to mark off on the space of a whole page how in advance initial treats layout space rectangles region.
S503, the space of a whole page marks off and initial treats layout space rectangles region.
Using Layout mode, namely according to the optimum solution of system knowledge base instruction, is tentatively initial treat layout space rectangles region by Layout division, and determines to allow each space rectangles region in wide, height and the anglec of rotation of the page of layout.Wherein, when the space of a whole page be divided at least two until layout space rectangles region time, meet: partly or entirely treat that a limit in layout space rectangles region can sequentially be linked to be at least one horizontal line or perpendicular line, described horizontal terminal lays respectively on the left and right border of the described space of a whole page, and the terminal of described perpendicular line lays respectively on the upper and lower border of the described space of a whole page.That is, treat the initial division in layout space rectangles region, also will meet the requirement that can cut.
With two tuple tp (w, h, r), the embodiment of the present invention, represents that a class treats the layout page, w is pagewidth, h is page height, dextrorotation gyration when r represents layout, all treat that the category set of the layout page is S
tp; Represent space rectangles region with four-tuple gr (x, y, W, H), x, y represent the coordinate of the summit in the lower left corner in space rectangles region on the space of a whole page, and W represents the width in space rectangles region, and H represents the height in space rectangles region, and the set of whole gr is S
gr; The complete space of a whole page is GP.Layout mode defines S
tpto S
grmapping f, the mathematical definition of f is as follows:
In addition, under Layout mode, space rectangles region with treat that the mapping relations of the layout page have inheritance.Namely step S303 using remaining area as when the layout space rectangles region, not only record remaining area four-tuple gr ' (x ', y ', W ', H '), also record the layout page corresponding to space rectangles region, remaining area layout front place two tuple tp ' (w ', h ', r '), and by array (gr ' (x ', y ', W ', H '), tp ' (w ', h ', r ')) deposit.Therefore, be also merely able in remaining area to spell and treat the layout page into specified type.
S504, whole layout area is treated layout space rectangles region as one.
When not adopting Layout mode, space rectangles region and treat to there are not mapping relations between the layout page, layout can treat that layout page makeup is in current layout rectangular area by wide, high arbitrarily in current layout rectangular area.Wherein, layout can treat the layout page in current layout rectangular area, what the scope of referring to was no more than current layout rectangular area treats the layout page.
As shown in Figure 6, when adopting Layout mode, determining a method treating the layout page in step S302, comprising:
S601, from can layout treat the layout page in described current layout rectangular area, determining that wide, height is respectively in described current layout rectangular area allows the wide, high of the page of layout to treat the layout page, or, from can layout treat the layout page in described current layout rectangular area, determine that the page that wide, height is respectively described permission layout treats the layout page according to postrotational wide, the high integral multiple of the described anglec of rotation.
Such as, wish will by tp1 (w1, h1), tp2 (w2, what h2), tp3 (w3, h3) three class treated that the layout page forms treats that the layout of layout page set is at a certain space of a whole page, according to system knowledge base, Layout division is three space rectangles region: gr1 (x1, y1, W1, H1), gr2 (x2, y2, W2, H2), gr3 (x3, y3, W3, H3); Meanwhile, what system knowledge base indicated that each space rectangles region maps respectively treats the layout page, is recorded as (gr1 (x1, y1, W1, H1), tp1 (w1, h1, r1)), (gr2 (x2, y2, W2, H2), tp2 (w2, h2, r2)), (gr3 (x3, y3, W3, H3), tp3 (w3, h3, r3)).Gr1 (x1, y1, W1, H1) allow to spell into according to the postrotational tp1 of r1 (w1, h1) in, gr2 (x2, y2, W2, H2) allow to spell into according to the postrotational tp2 (w2, h2) of r2 in, gr3 (x3, y3, W3, H3) in allow to spell into according to the postrotational tp3 (w3, h3) of r3.Therefore, after determining space rectangles region, spell in space rectangles region and treat the layout page into dimension.
For strengthening the adaptability of system knowledge base, reduce and treat layout page classifications quantity, can carry out sweetly disposition to mapping relations, the part not meeting mapping relations treats that the layout page also can be spelled in space rectangles region.Such as, if treat to there is tp1 (w1, h1) in the layout page simultaneously, tp4 (2*w1, h1), regards as two tp1 when determining the mapping relations of Layout mode by tp4, for allowing to spell into tp1 (w1, h1) gr1 (x1, y1, W1, H1), same permission is spelled into tp4 (2*w1, h1, r1).Further, because tp4 area is greater than tp1, preferentially can carry out layout to tp4, avoid follow-up insufficient space.Again such as, for mapping (gr1 (x1, y1, W1, H1), tp1 (w1, h1, r1)), suppose that the anglec of rotation r1 that tp1 spells into gr1 is 90 degree, allow in that gr1 to spell into tp5 (h1, w1).
S602, treat that choosing one the layout page treats the layout page from what determine.
When determine to obtain multiple until the layout page time, treat that choosing one the layout page treats the layout page from what determine; When determine to obtain unique until the layout page time, treat that the layout page directly treats the layout page as what choose using what determine.
As shown in Figure 7, when not adopting Layout mode, determining a method treating the layout page in step S302, comprising:
S701, treat the wide, high of the layout page according to each, and described current layout rectangular area is wide, high, that determines the principle meeting minimum space waste treats the layout page.
Such as, for treating layout page p, wide, the height of page p is respectively with W
p, H
prepresent, current layout rectangular area f, wide, the height of current layout rectangular area f are respectively W
f, H
f, S701 uses following choosing method to determine to treat the layout page, as shown in Figure 8, comprising:
S801, judge whether to there is W
p==W
fand H
p==H
fthe page, if so, will W be met
p==W
fand H
p==H
fthe page treat the layout page as what determine, terminate; Otherwise, perform step S802;
S802, judge whether to there is W
p==H
fand H
p==W
fthe page, if so, will W be met
p==H
fand H
p==W
fthe page treat the layout page as what determine, terminate; Otherwise, perform step S803;
S803, can layout treat in the layout page in described current layout rectangular area, the maximum page of area treats the layout page as what determine;
Or, can layout treat in the layout page in described current layout rectangular area, Min (W
f-W
p, H
f– H
p) page of getting minimum value treats the layout page as what determine;
Or, can layout treat in the layout page in described current layout rectangular area, Min (W
f-W
p, H
f– H
p) page of getting minimum value treats the layout page as what determine.
S702, treat that choosing one the layout page treats the layout page from what determine.
When determine to obtain multiple until the layout page time, treat that choosing one the layout page treats the layout page from what determine; When determine to obtain unique until the layout page time, treat that the layout page directly treats the layout page as what choose using what determine.
As shown in Figure 9, in the S702 of S602 and Fig. 7 of Fig. 6, when determine to obtain multiple until the layout page time, choose from treating of determining the method that is treated the layout page the layout page, comprising:
S901, determine ink channel direction.
Ink channel direction is the print direction of the space of a whole page when printing.
S902, calculate determine each treat layout page makeup after described current layout rectangular area with the color degree of approximation of adjacent page on ink channel direction.
Layout page P is treated for any two
a, P
b, P
awith P
bcolor degree of approximation defined matrix as follows:
Wherein, sizeof representation page area, Sim (P
a, P
b) value is (key, a value) tuple, key is P after layout
awith P
brelative position (Pos
x, Pos
y), value is the color degree of approximation calculated under this relative position.
Structure pixel S set, S comprises P
a, P
bat relative position (Pos
x, Pos
y) under move along assigned direction after maximum overlapping region in P
a, P
bpixel, S={ (P
ai, P
bi), wherein, P
aip
ain a pixel, P
bip
bin with P
aithere is in maximum overlapping region the pixel of same position.Sim (P
a, P
b) definition of function is specific as follows:
n is the element number in S,
be
normalization function.Function D, for calculating color distortion, analyzes two pixel (L in the color space for arbitrary CIELAB
i, a
i, b
i), (L
j, a
j, b
j) color distortion be
Sim value is less, page P
a, P
bcolor is more close.Relative position is different, then Sim value is also different.
Therefore, calculate the color degree of approximation of two pages under specific relative position, being moves along ink channel direction obtains maximum overlapping region, carries out Sim functional operation to two pages in overlapping region.As shown in Figure 10, calculate the color degree of approximation of the page 1 and the page 2, the shadow region part of namely getting the page 1 and the page 2 carries out Sim functional operation.
S903, according to the described color degree of approximation, treat that choosing one the layout page treats the layout page from what determine.
Like this, under the prerequisite not affecting space of a whole page area utilization, carry out typesetting according to the color degree of approximation, the color effect of printing can be improved.
Provide specific embodiments of the invention below.
In the present embodiment, the space of a whole page is of a size of 855 × 705, and have 9 and treat the layout page, its size is respectively page P
1(285 × 420), P2-P9(285 × 210), wherein the color of P5, P6, P7 is Lab(50,100,0), other page color are Lab(50,0,100) and, set printing ink channel direction as longitudinal.
As shown in figure 11, layout process comprises the steps:
S1101, determine the selection rule treating the layout page: preferential put into current layout rectangular area area larger treat the layout page;
S1102, determine use Layout mode, Layout mode is: (tp
1(285,210,0), gr
1(0,0,855,420)), (tp
2(285,210,90), gr
2(0,420,855,285);
S1103, from all treating to choose maximum space rectangles region layout space rectangles region as current layout rectangular area;
S1104, judge to treat whether to have in layout page set meet current layout rectangular area dimensional requirement treat the layout page, if so, perform step S1105; Otherwise, perform S1108;
S1105, to choose according to the color degree of approximation and treat the layout page, according to corresponding anglec of rotation layout in current layout rectangular area, simultaneously treat to delete in layout page set choose treat the layout page;
S1106, judge whether current layout rectangular area has remaining area, if so, then performs S1107; Otherwise, perform S1108;
S1107, using the remaining area of current layout rectangular area directly or after dividing as treating layout space rectangles region;
S1108, delete current layout rectangular area;
S1109, judge whether to need layout space rectangles region, if so, perform step S1103; Otherwise, terminate.
According to above step, successively by P1, P2, P3, P4 layout to the space of a whole page, as shown in figure 12.When needs layout the 5th page, through calculating, the color degree of approximation of P8 and P3, P5, be less than P5, P6, P7 respectively with the color degree of approximation of P3, P5, therefore preferentially put into P8, as shown in figure 13.Last imposition results as shown in figure 14.
As shown in figure 15, embodiments provide a kind of device of automatic keyline layout, comprising:
Layout unit 1501, for treating from the space of a whole page to choose a space rectangles region in layout space rectangles region, as current layout rectangular area; In each page treating layout, determine that is treated a layout page, this treated layout page makeup is in described current layout rectangular area, and described in treat that at least two borders of the layout page are overlapping with two boundary lines of described current layout rectangular area; Repeat above-mentioned steps, until treat that the whole layout of each page of layout is complete, or the space of a whole page treats that layout space rectangles region can not layout be arbitrary treats the layout page;
Remaining area division unit 1502, for when determining to there is the remaining area after layout in described current layout rectangular area, whether the shape judging described remaining area is rectangle, if, using described remaining area together with space rectangles region current on the space of a whole page as treating layout space rectangles region, if not, described remaining area is divided into two rectangular areas, using mark off two rectangular areas together with space rectangles region current on the space of a whole page as treating layout space rectangles region.
Preferably, this device also comprises: space of a whole page pretreatment unit, initial treats layout space rectangles region for mark off on the space of a whole page in advance;
Described space of a whole page pretreatment unit is specifically for wide, high according to the space of a whole page, and treat each page wide, high of layout, that determines the space of a whole page marks off initial treats layout space rectangles region, and determines respectively to treat to allow the wide, high of the page of layout and the anglec of rotation in layout space rectangles region; Wherein, when the space of a whole page be divided at least two until layout space rectangles region time, meet: partly or entirely treat that a limit in layout space rectangles region can sequentially be linked to be at least one horizontal line or perpendicular line, described horizontal terminal lays respectively on the left and right border of the described space of a whole page, and the terminal of described perpendicular line lays respectively on the upper and lower border of the described space of a whole page.
Preferably, described layout unit 1501 for determining that one when the layout page, specifically for:
From can layout treat the layout page in described current blank rectangular area, determining that wide, height is respectively in described current blank rectangular area allows the wide, high of the page of layout to treat the layout page, or, from can layout treat the layout page in described current blank rectangular area, determine that the page that wide, height is respectively described permission layout treats the layout page according to postrotational wide, the high integral multiple of the described anglec of rotation;
Treat that choosing one the layout page treats the layout page from what determine.
Preferably, described remaining area division unit 1502 also for: when determining to there is the remaining area after layout in described current layout rectangular area, determine in described remaining area, to allow the wide, high of the page of layout and the anglec of rotation, be respectively in described current layout rectangular area and allow the wide, high of the page of layout and the anglec of rotation.
Preferably, described layout unit 1501, for treating from the space of a whole page to choose a space rectangles region in layout space rectangles region, before current layout rectangular area, also for: whole layout area is treated layout space rectangles region as one.
Preferably, described layout unit 1501 for determining that one when the layout page, specifically for:
Treat the wide, high of the layout page according to each, and described current blank rectangular area is wide, high, that determines the principle meeting minimum space waste treats the layout page;
Treat that choosing one the layout page treats the layout page from what determine.
Preferably, described layout unit 1501 is for treating the wide, high of the layout page according to each, and described current blank rectangular area is wide, high, determine the principle meeting minimum space waste when the layout page, specifically for:
Judge whether to exist and wide, highly treat the layout page with described current blank rectangle region field width, the high equal first kind respectively, if so, the described first kind is treated the layout page treats the layout page as what determine; Otherwise,
Judge whether to exist and high, widely treat the layout page with wide, the high equal Equations of The Second Kind of described current blank rectangular area respectively, if so, described Equations of The Second Kind is treated the layout page treats the layout page as what determine; Otherwise,
From can layout treat the layout page in described current blank rectangular area, choose area maximum treat that the layout page treats the layout page as what determine; Or, from can layout treat the layout page in described current blank rectangular area, determine each wide difference treating the wide of the layout page and described current blank rectangular area, and determine the high difference of each height treating the layout page and described current blank rectangular area, minimum for the smaller value in two differences is treated that the layout page treats the layout page as what determine; Or, from can layout treat the layout page in described current blank rectangular area, determine each wide difference treating the wide of the layout page and described current blank rectangular area, and determine the high difference of each height treating the layout page and described current blank rectangular area, minimum for the higher value in two differences is treated that the layout page treats the layout page as what determine.
Preferably, described layout unit 1501 for choosing one when the layout page in the layout page from what determine, specifically for:
Determine ink channel direction;
Calculate determine each treat layout page makeup after described current blank rectangular area with the color degree of approximation of adjacent page on ink channel direction;
According to the described color degree of approximation, treat that choosing one the layout page treats the layout page from what determine.
Preferably, described layout unit 1501 for calculate determine each until the color degree of approximation of layout page makeup with adjacent page on ink channel direction after described current blank rectangular area time, specifically for:
Determine described determine each after the layout page moves along ink channel direction with the maximum overlapping region of described adjacent page;
Each pixel treating in the described overlapping region of the layout page determined according to described, and the pixel in the described overlapping region of described adjacent page, determine described determine each treat the color degree of approximation of the layout page and described adjacent page.
Preferably, when described remaining area division unit 1502 is for being divided into two rectangles by described remaining area, specifically for:
Described remaining area is laterally divided, obtains two rectangles; Or,
Described remaining area is longitudinally divided, obtains two rectangles.
In sum, embodiments provide a kind of automatic keyline layout method and device, when using the space of a whole page material needing horizontal or longitudinal through space of a whole page to carry out cutting to carry out the printing of conjunction version, the imposition results that can cut can be obtained, avoid the waste of printing material; When using Layout mode, best imposition results can also be obtained, improving the utilization factor of the space of a whole page.
Those skilled in the art should understand, embodiments of the invention can be provided as method, system or computer program.Therefore, the present invention can adopt the form of complete hardware embodiment, completely software implementation or the embodiment in conjunction with software and hardware aspect.And the present invention can adopt in one or more form wherein including the upper computer program implemented of computer-usable storage medium (including but not limited to magnetic disk memory and optical memory etc.) of computer usable program code.
The present invention describes with reference to according to the process flow diagram of the method for the embodiment of the present invention, equipment (system) and computer program and/or block scheme.Should understand can by the combination of the flow process in each flow process in computer program instructions realization flow figure and/or block scheme and/or square frame and process flow diagram and/or block scheme and/or square frame.These computer program instructions can being provided to the processor of multi-purpose computer, special purpose computer, Embedded Processor or other programmable data processing device to produce a machine, making the instruction performed by the processor of computing machine or other programmable data processing device produce device for realizing the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
These computer program instructions also can be stored in can in the computer-readable memory that works in a specific way of vectoring computer or other programmable data processing device, the instruction making to be stored in this computer-readable memory produces the manufacture comprising command device, and this command device realizes the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
These computer program instructions also can be loaded in computing machine or other programmable data processing device, make on computing machine or other programmable devices, to perform sequence of operations step to produce computer implemented process, thus the instruction performed on computing machine or other programmable devices is provided for the step realizing the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
Obviously, those skilled in the art can carry out various change and modification to the present invention and not depart from the spirit and scope of the present invention.Like this, if these amendments of the present invention and modification belong within the scope of the claims in the present invention and equivalent technologies thereof, then the present invention is also intended to comprise these change and modification.