Embodiment
An embodiment of the present invention provides a kind of automatic keyline layout method and device, when use needs transversely or longitudinally to penetrate through version
When the space of a whole page material that face is cut carries out conjunction version printing, the imposition results that can be cut can be obtained, avoid the wave of printing material
Take.
As shown in figure 3, a kind of method of automatic keyline layout provided in an embodiment of the present invention includes:
S301, treat one space rectangles region of selection in layout space rectangles region from the space of a whole page, as current layout square
Shape region.
Current layout rectangular area can specifically be chosen according to following selection rule:Treat layout space rectangles region
It is ranked up according to size, the preferential space rectangles region for choosing area maximum, alternatively, preferentially choosing the sky of area minimum
White rectangular area.
S302, in each page of layout is treated, determine that is treated a layout page, by this treat layout page makeup it is described work as
In preceding layout rectangular area, and two sides at least two borders for treating the layout page and the current layout rectangular area
Boundary line is overlapping.
It is definite treat the layout page should can layout in current layout rectangular area, i.e., the Page Range after layout is not
More than the scope of current blank layout rectangular area.
S303, when determining to judge the residue there are during the remaining area after layout in the current layout rectangular area
Whether the shape in region is rectangle, if so, by current space rectangles region on the remaining area and the space of a whole page together as treating
Layout space rectangles region, if it is not, the remaining area is divided into two rectangular areas, by mark off two rectangles
Current space rectangles region is together as treating layout space rectangles region on region and the space of a whole page;
Repeat the above steps, each page whole layout until treating layout finishes, or treats layout blank square on the space of a whole page
Shape region is unable to that layout is any to treat the layout page.
As shown in figure 4, A can laterally be divided, obtained there are remaining area A in space rectangles region after page P layouts
Two rectangles B and C, can also be longitudinally divided by A, obtains two rectangles B ' and C '.
Specific division rule, i.e., how to determine laterally division or it is longitudinally divided, can according to the space of a whole page wide, high, area,
And the combined factors such as each width, height, area for treating the layout page consider.For example, for a page p, layout is in space rectangles
The width of region f, page p, high respectively Wp、Hp, the width of space rectangles region f, high respectively Wf、Hf;If Wp×(Hf-Hp)≥
Hp×(Wf-Wp), then laterally division, otherwise, longitudinally divided.Can also be according to following division rule, if (Wf-Wp)≥(Hf-
Hp), then laterally division, otherwise, longitudinally divided.
Different division rules can obtain different imposition results, may be different to the utilization rate of the space of a whole page, finally cut
Knife number may also be different, it is necessary to determine which kind of division rule used according to actual conditions.Certainly, division rule be not limited only to
Two kinds of rules of upper proposition, as long as remaining area is divided into two rectangles, can finally obtain the imposition results that can be cut.
Further, it is also possible to by attempting different splitting schemes, determine that the highest imposition results of utilization ratio of spaces carry out again
Printing.
As shown in figure 5, before step S301, this method further includes:Predefine the space of a whole page treats layout space rectangles region;
Idiographic flow is as follows:
S501, analysis all treat width, the height of the layout page, and width, the height of the analysis space of a whole page.
S502, according to analysis result, inquiry system knowledge base, judges whether to use Layout mode, if so, performing step
S503;Otherwise, step S504 is performed.
Layout problem can be abstracted as Two-dimension Bin Packing Problem (two-dimensional bin packing problem),
Belong to nondeterministic polynomial (Non-deterministic polynomial, NP) complete problem, there is very high calculating to answer
Polygamy(Referring to GAREY M R, JOHNSON D S.Computers and intractability [M] .San Francisco:
Freeman, 1979).The automatic keyline layout method of the prior art, obtained imposition results are all approximate suboptimal solutions, and non-optimal solution,
That is, the waste there are layout space.And for possessing the space of a whole page of certain feature and treating the layout page, it is that there are optimal solution
's.System knowledge base is exactly the characteristic for storing there are the space of a whole page of optimal solution and treating the layout page, and storage is accordingly
Optimal solution database, which, which indicates how to mark off on the space of a whole page in advance, initial treats layout space rectangles area
Domain.
S503, mark off on the space of a whole page and initial to treat layout space rectangles region.
Using Layout mode, i.e., the optimal solution indicated according to system knowledge base, Layout division tentatively waited to spell for initial
Version space rectangles region, and determine width, height and the rotation angle for allowing the page of layout in each space rectangles region.Wherein,
When the space of a whole page is divided at least two when layout space rectangles region, meet:Partly or entirely treat layout space rectangles region
A line can sequentially be linked to be at least one horizontal line or vertical line, the horizontal terminal is located at the space of a whole page respectively
Left and right border on, the terminal of the vertical line is respectively on the upper and lower border of the space of a whole page.That is, treat layout
The initial division in space rectangles region, will also meet the requirement that can be cut.
The embodiment of the present invention, represents that one kind treats the layout page with two tuple tp (w, h, r), and w is that pagewidth, h are the pages
Highly, r represents to rotate clockwise angle during layout, and the category set for all treating the layout page is Stp;With four-tuple gr (x, y,
W, H) represent space rectangles region, x, y represent coordinate of the vertex in the lower left corner in space rectangles region on the space of a whole page, and W represents empty
The width of white rectangular area, H represent the height in space rectangles region, and the collection of whole gr is combined into Sgr;The complete space of a whole page is GP.Layout
Pattern definition StpTo SgrMapping f, f mathematical definition it is as follows:
In addition, under Layout mode, space rectangles region is with treating that the mapping relations of the layout page have inheritance.That is step
S303 using remaining area as when the layout space rectangles region, not only record remaining area four-tuple gr ' (x ', y ', W ',
H '), two tuple tp ' of the corresponding layout page in space rectangles regions where also recording before remaining area layout (w ', h ', r '),
And pass through array (gr ' (x ', y ', W ', H '), tp ' (w ', h ', r ')) storage.Therefore, also it is merely able to spell into finger in remaining area
That determines type treats the layout page.
S504, using whole layout area as one treat layout space rectangles region.
When not using Layout mode, space rectangles region and treat that mapping relations are not present between the layout page, can will
It is any it is wide, high can layout treat layout page makeup in current layout rectangular area in current layout rectangular area.Its
In, can layout treat the layout page in current layout rectangular area, refer to that scope is no more than current layout rectangular area
Treat the layout page.
As shown in fig. 6, when using Layout mode, a method for treating the layout page is determined in step S302, including:
S601, from can layout treat the layout page in the current layout rectangular area, determine that wide, height is respectively
The wide, high of the page of permission layout treats the layout page in the current layout rectangular area, alternatively, from can layout described
Treated in current layout rectangular area in the layout page, determine wide, the high respectively described page for allowing layout according to the rotation
Postrotational wide, the high integral multiple of gyration treats the layout page.
For example, be intended to by by tp1 (w1, h1), tp2 (w2, h2), tp3 (w3, h3) three classes treat the layout page composition treat layout
Page set layout is in a certain space of a whole page, and according to system knowledge base, Layout division is three space rectangles regions:gr1(x1,y1,
W1, H1), gr2 (x2, y2, W2, H2), gr3 (x3, y3, W3, H3);Meanwhile system knowledge base indicates each space rectangles area
What domain mapped 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)).Allow to spell in gr1 (x1, y1, W1, H1)
Enter according to the postrotational tp1 of r1 (w1, h1), allow to spell in gr2 (x2, y2, W2, H2) into according to the postrotational tp2 of r2 (w2,
H2), allow to spell into according to the postrotational tp3 of r3 (w3, h3) in gr3 (x3, y3, W3, H3).Therefore, in definite space rectangles area
After domain, that dimension is spelled in space rectangles region treats the layout page.
For the adaptability of strengthening system knowledge base, layout page classifications quantity is treated in reduction, can carry out spirit to mapping relations
Processing living, the part for being unsatisfactory for mapping relations treats that the layout page can also be spelled in space rectangles region.If for example, treat layout page
At the same time there are tp1 (w1, h1) in face, tp4 (2*w1, h1), two are regarded as when determining the mapping relations of Layout mode by tp4
Tp1, for allowing to spell the gr1 (x1, y1, W1, H1) into tp1 (w1, h1), also allows for spelling into tp4 (2*w1, h1, r1).And
And since tp4 areas are more than tp1, layout preferentially can be carried out to tp4, avoid follow-up insufficient space.In another example for mapping
(gr1 (x1, y1, W1, H1), tp1 (w1, h1, r1)), it is assumed that the rotation angle r1 that tp1 spells into gr1 is 90 degree, is allowed in that gr1
Spell into tp5 (h1, w1).
S602, from definite treat that choosing one in the layout page treats the layout page.
When determine to obtain it is multiple when the layout page when, treat that choosing one in the layout page treats the layout page from definite;When
Determine uniquely when the layout page, treat that the layout page treats the layout page directly as selection by what is determined.
As shown in fig. 7, when not using Layout mode, a method for treating the layout page is determined in step S302, including:
S701, according to each width for treating the layout page, height, and width, the height of the current layout rectangular area determine full
The principle of the minimum space waste of foot treats the layout page.
For example, for treat layout page p, page p width, height respectively with Wp、HpRepresent, current layout rectangular area f, when
The width of preceding layout rectangular area f, high respectively Wf、Hf, S701 determines to treat the layout page using following choosing method, such as Fig. 8 institutes
Show, including:
S801, judge whether Wp==WfAnd Hp==HfThe page, if so, will meet Wp==WfAnd Hp==Hf's
The page treats the layout page as what is determined, terminates;Otherwise, step S802 is performed;
S802, judge whether Wp==HfAnd Hp==WfThe page, if so, will meet Wp==HfAnd Hp==Wf's
The page treats the layout page as what is determined, terminates;Otherwise, step S803 is performed;
S803, by can layout treat the layout page in the current layout rectangular area, the page of area maximum
The layout page is treated as definite;
Alternatively, by can layout treat the layout page in the current layout rectangular area, Min (Wf-Wp, Hf–Hp)
The page being minimized treats the layout page as what is determined;
Alternatively, by can layout treat the layout page in the current layout rectangular area, Min (Wf-Wp, Hf–Hp)
The page being minimized treats the layout page as what is determined.
S702, from definite treat that choosing one in the layout page treats the layout page.
When determine to obtain it is multiple when the layout page when, treat that choosing one in the layout page treats the layout page from definite;When
Determine uniquely when the layout page, treat that the layout page treats the layout page directly as selection by what is determined.
As shown in figure 9, in the S702 of the S602 and Fig. 7 of Fig. 6, when determine to obtain it is multiple when the layout page when, from definite
Treat to choose a method for treating the layout page in the layout page, including:
S901, determine ink channel direction.
Ink channel direction, is print direction of the space of a whole page in printing.
S902, calculate determine each treat layout page makeup after the current layout rectangular area with ink channel direction
The color degree of approximation of upper adjacent page.
Layout page P is treated for any twoa, Pb, PaWith PbColor degree of approximation matrix be defined as follows:
Wherein, sizeof representation pages area, Sim (Pa, Pb) value is (key, a value) tuple, after key is layout
PaWith PbRelative position (Posx,Posy), value is the color degree of approximation being calculated under the relative position.
Construction pixel set S, S include Pa、PbIn relative position (Posx,Posy) under moved along assigned direction after maximum
P in overlapping regiona、PbPixel, S={ (Pai,Pbi), wherein, PaiIt is PaIn a pixel, PbiIt is PbIn with PaiIn maximum
Overlapping region has the pixel of same position.Sim(Pa, Pb) function definition it is specific as follows:N is the element number in S,It isNormalization
Function.Function D is used to calculate color distortion, and two pixels in the colour space are analyzed for any CIELAB(Li,ai,bi),(Lj,
aj, bj)Color distortion be Sim values are smaller, page
Face Pa, PbColor is more close.Relative position is different, then Sim values are also different.
Therefore, the color degree of approximation of two pages under specific relative position is calculated, as moves to obtain along ink channel direction
Two pages in overlapping region are carried out Sim functional operation by maximum overlapping region.As shown in Figure 10, the page 1 and the page 2 are calculated
The color degree of approximation, that is, take the shadow region part of the page 1 and the page 2 carry out Sim functional operation.
S903, according to the color degree of approximation, treat that choosing one in the layout page treats the layout page from definite.
In this way, on the premise of space of a whole page area utilization is not influenced, typesetting is carried out according to the color degree of approximation, print can be improved
The color effect of brush.
The specific embodiment of the present invention is given below.
In the present embodiment, the size of the space of a whole page is 855 × 705, shares 9 and treats the layout page, its size is respectively page P1
(285×420), P2-P9(285×210), wherein P5, P6, the color of P7 is Lab(50,100,0), other page colors are
Lab(50,0,100), printing ink channel direction is set as longitudinal direction.
As shown in figure 11, layout process includes the following steps:
S1101, determine to treat the selection rule of the layout page:Preferentially it is put into that area is larger to be treated to current layout rectangular area
The layout page;
S1102, determine to use Layout mode, and Layout mode is:(tp1(285,210,0), gr1(0,0,855,420)),
(tp2(285,210,90), gr2(0,420,855,285);
S1103, from all treating to choose the space rectangles regions of maximum in layout space rectangles region as current layout square
Shape region;
Whether S1104, judgement treat to have in layout page set meet the size requirement of current layout rectangular area to treat layout
The page, if so, performing step S1105;Otherwise, S1108 is performed;
S1105, choose according to the color degree of approximation and treat the layout page, according to corresponding rotation angle layout in current layout square
Shape region, at the same in layout page set is treated delete choose treat the layout page;
S1106, judge whether current layout rectangular area has remaining area, if it is, performing S1107;Otherwise, perform
S1108;
S1107, using the remaining area of current layout rectangular area directly or after division as treating layout space rectangles area
Domain;
S1108, delete current layout rectangular area;
S1109, judge whether to need layout space rectangles region, if so, performing 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 needing layout the 5th
During the page, by calculating, the color degree of approximation of P8 and P3, P5, less than P5, P6, P7 color degree of approximation with P3, P5 respectively, because
This is preferentially put into P8, as shown in figure 13.Last imposition results are as shown in figure 14.
As shown in figure 15, an embodiment of the present invention provides a kind of device of automatic keyline layout, including:
Layout unit 1501, for treating to choose a space rectangles region in layout space rectangles region from the space of a whole page, makees
For current layout rectangular area;In each page of layout is treated, determine that is treated a layout page, this is treated that layout page makeup exists
In the current layout rectangular area, and at least two borders for treating the layout page and the current layout rectangular area
Two border line overlaps;Repeat the above steps, each page whole layout until treating layout finishes, or treats layout on the space of a whole page
Space rectangles region is unable to that layout is any to treat the layout page;
Remaining area division unit 1502, for when there are residue after layout in the definite current layout rectangular area
During region, whether the shape for judging the remaining area is rectangle, if so, by current blank on the remaining area and the space of a whole page
Rectangular area is together as treating layout space rectangles region, if it is not, the remaining area is divided into two rectangular areas,
By current space rectangles region on mark off two rectangular areas and the space of a whole page together as treating layout space rectangles region.
Preferably, the device further includes:Space of a whole page pretreatment unit, initial waits to spell for marking off on the space of a whole page in advance
Version space rectangles region;
The space of a whole page pretreatment unit is specifically used for:According to the width of the space of a whole page, height, and treat each page of layout width,
Height, determine to mark off on the space of a whole page it is initial treat layout space rectangles region, and determine respectively to treat in layout space rectangles region
Allow width, height and the rotation angle of the page of layout;Wherein, layout space rectangles region is treated when the space of a whole page is divided at least two
When, meet:At least one horizontal line or vertical can be sequentially linked to be by partly or entirely treating a line in layout space rectangles region
Line, respectively on the left and right border of the space of a whole page, the terminal of the vertical line is located at the horizontal terminal respectively
On the upper and lower border of the space of a whole page.
Preferably, the layout unit 1501 is used to determine one when the layout page, it is specifically used for:
From can layout treat the layout page in the current blank rectangular area, determine that wide, high is respectively described
Allow the wide, high of the page of layout to treat the layout page in current blank rectangular area, alternatively, from can layout described current
Treated in space rectangles region in the layout page, determine wide, the high page for being respectively the permission layout according to the anglec of rotation
That spends postrotational wide, high integral multiple treats the layout page;
Treat that choosing one in the layout page treats the layout page from definite.
Preferably, the remaining area division unit 1502 is additionally operable to:Deposited when in the definite current layout rectangular area
During remaining area after layout, determine width, height and the rotation angle for allowing the page of layout in the remaining area, be respectively
Allow width, height and the rotation angle of the page of layout in the current layout rectangular area.
Preferably, the layout unit 1501, for treating to choose a blank in layout space rectangles region from the space of a whole page
Rectangular area, before current layout rectangular area, is additionally operable to:Layout space rectangles are treated using whole layout area as one
Region.
Preferably, the layout unit 1501 is used to determine one when the layout page, it is specifically used for:
According to each width for treating the layout page, height, and width, the height of the current blank rectangular area, determine to meet most
The principle of few space waste treats the layout page;
Treat that choosing one in the layout page treats the layout page from definite.
Preferably, the layout unit 1501 is used for according to each width for treating the layout page, height, and the current blank
Width, the height of rectangular area, the principle for determining to meet minimum space waste when the layout page, be specifically used for:
Judge whether that wide, height treats layout page with the current blank rectangle region field width, the high equal first kind respectively
Face, if so, the first kind being treated, the layout page treats the layout page as what is determined;Otherwise,
Judge whether high, wide to treat layout with wide, high the second equal class of the current blank rectangular area respectively
The page, if so, second class being treated, the layout page treats the layout page as what is determined;Otherwise,
From can layout treat the layout page in the current blank rectangular area, choose area it is maximum treat layout
The page treats the layout page as what is determined;Alternatively, from can layout treat the layout page in the current blank rectangular area
In, determine each wide and wide difference of the current blank rectangular area for treating the layout page, and determine each to treat layout
The high and high difference of the current blank rectangular area of the page, the layout page is treated by the smaller value minimum in two differences
The layout page is treated as definite;Alternatively, from can layout treat the layout page in the current blank rectangular area, really
Fixed each wide and wide difference of the current blank rectangular area for treating the layout page, and definite each layout page for the treatment of
The high and high difference of the current blank rectangular area, treats the layout page as really the higher value minimum in two differences
Fixed treats the layout page.
Preferably, the layout unit 1501 is used for from definite when one is chosen in the layout page when the layout page,
It is specifically used for:
Determine ink channel direction;
Calculate determine it is each treat layout page makeup after the current blank rectangular area with phase on ink channel direction
The color degree of approximation of the adjacent page;
According to the color degree of approximation, treat that choosing one in the layout page treats the layout page from definite.
Preferably, the layout unit 1501 is used to calculating and definite each treats layout page makeup in the current blank
With during the color degree of approximation of adjacent page, being specifically used on ink channel direction after rectangular area:
Determine described definite each overlapped after the layout page is moved along ink channel direction with the maximum of the adjacent page
Region;
According to the pixel in definite each overlapping region for treating the layout page, and the adjacent page
Pixel in the overlapping region, determines definite each color degree of approximation for treating the layout page and the adjacent page.
Preferably, when the remaining area division unit 1502 is used to the remaining area being divided into two rectangles, tool
Body is used for:
The remaining area is laterally divided, obtains two rectangles;Alternatively,
The remaining area is longitudinally divided, obtain two rectangles.
In conclusion an embodiment of the present invention provides a kind of automatic keyline layout method and device, when using need laterally or
When the space of a whole page material that the longitudinally through space of a whole page is cut carries out conjunction version printing, the imposition results that can be cut can be obtained, avoid printing
The waste of brush material;When using Layout mode, additionally it is possible to obtain optimal imposition results, improve the utilization rate of the space of a whole page.
It should be understood by those skilled in the art that, the embodiment of the present invention can be provided as method, system or computer program
Product.Therefore, the present invention can use the reality in terms of complete hardware embodiment, complete software embodiment or combination software and hardware
Apply the form of example.Moreover, the present invention can use the computer for wherein including computer usable program code in one or more
Usable storage medium(Including but not limited to magnetic disk storage and optical memory etc.)The shape of the computer program product of upper implementation
Formula.
The present invention be with reference to according to the method for the embodiment of the present invention, equipment(System)And the flow of computer program product
Figure and/or block diagram describe.It should be understood that it can be realized by computer program instructions every first-class in flowchart and/or the block diagram
The combination of flow and/or square frame in journey and/or square frame and flowchart and/or the block diagram.These computer programs can be provided
The processors of all-purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices is instructed to produce
A raw machine so that the instruction performed by computer or the processor of other programmable data processing devices, which produces, to be used in fact
The device for the function of being specified in present one flow of flow chart or one square frame of multiple flows and/or block diagram or multiple square frames.
These computer program instructions, which may also be stored in, can guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works so that the instruction being stored in the computer-readable memory, which produces, to be included referring to
Make the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one square frame of block diagram or
The function of being specified in multiple square frames.
These computer program instructions can be also loaded into computer or other programmable data processing devices so that counted
Series of operation steps is performed on calculation machine or other programmable devices to produce computer implemented processing, thus in computer or
The instruction performed on other programmable devices is provided and is used for realization in one flow of flow chart or multiple flows and/or block diagram one
The step of function of being specified in a square frame or multiple square frames.
Obviously, various changes and modifications can be made to the invention without departing from essence of the invention by those skilled in the art
God and scope.In this way, if these modifications and changes of the present invention belongs to the scope of the claims in the present invention and its equivalent technologies
Within, then the present invention is also intended to comprising including these modification and variations.