CN101764944B - Method for merging and classifying subtitle object vector outline according to inner and outer side attribute - Google Patents

Method for merging and classifying subtitle object vector outline according to inner and outer side attribute Download PDF

Info

Publication number
CN101764944B
CN101764944B CN 200810225866 CN200810225866A CN101764944B CN 101764944 B CN101764944 B CN 101764944B CN 200810225866 CN200810225866 CN 200810225866 CN 200810225866 A CN200810225866 A CN 200810225866A CN 101764944 B CN101764944 B CN 101764944B
Authority
CN
China
Prior art keywords
line segment
point
bezier line
secondary bezier
closed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN 200810225866
Other languages
Chinese (zh)
Other versions
CN101764944A (en
Inventor
吴正斌
袁慧晶
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing culture science and technology finance leasing Limited by Share Ltd
Original Assignee
China Digital Video Beijing Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Digital Video Beijing Ltd filed Critical China Digital Video Beijing Ltd
Priority to CN 200810225866 priority Critical patent/CN101764944B/en
Publication of CN101764944A publication Critical patent/CN101764944A/en
Application granted granted Critical
Publication of CN101764944B publication Critical patent/CN101764944B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a method for merging and classifying a subtitle object vector outline according to inner and outer side attribute, belonging to the subtitle editing-broadcasting technical field of a TV program making and broadcasting mechanism in radio industry; in the method, the inner and outer side attribute of each quadratic Bezier ling segment in all closed outlines of an quadratic Bezier is determined, the quadratic Bezier ling segment with the inner side attribute is cancelled; the closed outline of the subtitle object is reconstructed according to intersection points; a circumscribed rectangle of each quadratic Bezier ling segment in all the closed outline is calculated again; and finally, the directions of all the closed outlines are marked. The method in the invention can lead the closed outlines not to be intersected, so as to improve the rendering efficiency of the subtitle object and enhance the rendering effect of the subtitle object.

Description

The caption object vector outline is carried out the method for merging according to inside and outside side attribute
Technical field
The invention belongs to the subtitle editing and playing technical field of radio, TV and film industries TV programme record and broadcast mechanism, be specifically related to the inside and outside side attribute of a kind of basis carries out merging to the caption object vector outline method.
Background technology
In the subtitle editing and playing field, caption object can be divided into literal and two parts of figure.Literal comprises the in the world literal of various languages, the compound pattern that figure comprises the figure of various regular shapes, be comprised of primary graphic element and any irregular figure.From the angle of computer graphics, all types of caption object can be considered as the figure that is formed by a series of straight lines and curve.Figure is comprised of non-geometric attributes such as the geometric elements such as point, line, surface, body and gray scale, color, line style, live widths usually.From treatment technology, figure mainly is divided into two classes: a class is based on line information and represents, such as line frame graph of engineering drawing, contour map, curved surface etc.; Another kind of is continuous-tone image, namely usually said photo realism graphic.
Caption rendering is that computer graphics, computer digital image are processed the technology that combines with the program making business of TV station.Angle from the computer digital image processing, playing up of caption object comprised two aspects: first, based on a series of static treatment of pixel or sub-pixel, such as image intensification, binary conversion treatment, rim detection, Fuzzy Processing, embossment, the edge is anti-aliasing, the brightness pinup picture, texturing, anti-shake, ovalizing deflection, polygon morphing, crisperding, blast, sharpening, softening, projection, colored pencil, the oil painting be full of cracks, crosshatch, sample cutting, glass, the edge blast, ink outline is drawn, ceramic tile, letter paper, patchwork, plastics package, water ripples, sponge, the spraying pen, coloured glass, the special efficacys such as Gaussian Blur; Second, based on a series of dynamic process of key frame, comprise that ripples, flag waft, spiral, distortion, tripleplane, flame, ball change, three-dimensional deformation, bending, phantom, scrolling, folding, fireworks display, shutter, cracked, ripples, fluctuation, draw picture, turn ball, spiral, flag waft, fluctuate diplopia, butterfly change, time, convex lens, kaleidoscope, laser, fly the special efficacys such as light, magic spiral, motion blur, radial blur, wave, wave inverted image, convolution.
The rendering effect of captions is to weigh the important indicator of a caption system, particularly at the aspects such as processing of the treatment of details of anti-aliasing processing, small character, the processing of stereo edge, empty limit, diplopia, true three-dimension visual impression, three-dimensional word chamfering, texture, illumination.
In existing caption system, caption rendering exists following problem:
The first, the difference of playing up of text subtitle and graphic subtitle is come, and different graphic elements is also described with geometric vector of different nature.This problem realize and use aspect two brought to caption system a lot of unfavorable.From the angle that realizes, can cause existing in the caption system a plurality of diverse render engines and play up flow process, and if support a kind of new caption object, then need to define and realize new render engine, thereby cause the function expansibility of caption system to have significant limitation.From the angle of using, bring the fatal problem in two aspects: on the one hand, the effect that dissimilar caption object finally represents is inconsistent, for example two dissimilar caption object are the full limit that has added 2 pixels equally, but owing to having passed through different render engines, final result may be different, has brought inconvenience to the user when carrying out the captions creation; On the other hand, in caption system, have to specifically limit for the operation of caption object, for example, some caption object are supported how much rotations, how much convergent-divergents, what have does not then support, some caption object are supported at any angle edged, are added shadow, the edged of then only supporting fixed angle that has, add shadow, the not even support that has.All these problems all can affect general applicability and the functional completeness of caption system.
The second, the core algorithm of caption rendering engine all is based on floating-point operation, such as trigonometric function operation, antitrigonometric function computing, division arithmetic, power operation, extracting operation etc.This can cause the problem of two aspects: on the one hand, because what final process result required is the pixel value of integer type, therefore can carry out rounding operation in the different phase of render engine algorithm, this will cause the cumulative errors in the calculating, cause final captions effect to have defective at local detail, such as smudgy clear, the stroke adhesion of the many literal of stroke etc.; On the other hand, these floating-point operations all are the mathematical operations that takies a large amount of machine instructions, greatly reduce the operating efficiency of whole caption system, have influence on the ageing of captions making and broadcast, particularly in the making of high definition TV captions, because its data volume is 5 times of SD, it is more obvious that this point shows.
The 3rd, not satisfactory as the effect that the edge of one of caption rendering important indicator is anti-aliasing, even can't reach practical degree.This is because existing caption system is when carrying out anti-aliasing processing, rely on the image processing method in current pixel space fully, there is not the participation of captions geometric vector information, also just can't realize the processing based on sub-pixel, so that apparent in view edge sawtooth effect appears in the final rendering effect of existing caption system, affect the effect that captions represent.
Because above-mentioned same, when caption object being carried out process based on the image of filter pipeline, also can affect the final effect of captions.Existing caption system play up the pinup picture that flow process is normally carried out first face limit shadow, obtain an image, then this image is put into the filter pipeline, carry out again a series of image and process.But owing to there not being the participation of captions geometric vector information, the processing of filter pipeline can destroy the former effect after anti-aliasing.That is to say, originally accumulating new edge sawtooth effect with regard to undesirable edge treated.
Because above-mentioned same, for the caption object of slightly more complex graphic element, oscillation effect appears in the place in the figure flex point, causes graph outline unsmooth.Round rectangle object commonly used for example, by circular arc and four rectilinear(-al)s at four angles, scraggly phenomenon will appear in the place circular arc and straight line join.
The 4th, caption object is being carried out gradient color when playing up, should be that the gradual change color that the vector outline according to this object carries out is radially processed, but in existing caption system, it is that gradient color is put in the memory block that playing up of gradient color processed, when playing up, still taked the method for respective pixel pinup picture.This is just so that existing caption system can't be realized the rendering effect of gradient color truly.
The 5th, existing caption system can't realize increasing a plurality of outsides, a plurality of inner edge, a plurality of sides stereo edge, a plurality of shadow.The captions of the stack of simple face, limit, shadow represent can't satisfy television program designing to the requirement of caption system.
The 6th, playing up of existing caption system is not based on the Bezier curved profile, but because the type matrix in the TrueType character library is all described with the Bezier curve, so the Bezier Curve transform that just need to will extract from character library becomes the vector of another form, because the loss of information can appear in the information asymmetry between the different vector expressions in transfer process, thereby so that the distortion of the shape of stroke, cause stroke weight inhomogeneous, affect attractive in appearance that font represents.
The 7th, existing caption system can't be converted to the text subtile object graphic subtitle object, thereby can't realize the functions such as Character deformation, character inverted image, character counter-rotating, curve are put, characters in a fancy style, can't satisfy senior captions application demand.
The 8th, existing caption system can't be realized the edged mode of number of different types, and such as wedge angle limit, round edge, corner limit etc., this has affected the popularity that captions are used to a certain extent.
The 9th, existing caption system can't be realized the support to the arbitrary shape irregular figure, thereby the captions that can't tackle the types such as the geography information description that becomes more and more important, weather forecast, Comprehensive Data are made.
Bezier (Bezier) curve is a kind of important polynomial parameters curve in the computer graphics.The individual point of any N in the plane (N 〉=2) can consist of a Bezier curve, and this N point is called the control point of Bezier curve, and the polygon of N some composition is called the control polygon of Bezier curve.The parametric equation of N Bezier curve is as follows:
B ( t ) = Σ i = 0 n n i P i ( 1 - t ) n - i t i = P 0 ( 1 - t ) n + n 1 P 1 ( 1 - t ) n - 1 t + · · · + P n t n ,t∈[0,1]
Wherein, P 0, P 1..., P nIt is the control point of Bezier curve.
Thus, the parameter expression of a Bezier curve is:
B(t)=P 0+(P 1-P 0)t=(1-t)P 0+tP 1,t∈[0,1]
One time the Bezier curve is exactly linear Bezier curve, is actually two control point P 0And P 1Between straightway.
The parameter expression of quadratic bezier curve is:
B(t)=(1-t) 2P 0+2t(1-t)P 1+t 2P 2,t∈[0,1]
The parameter expression of three bezier curve is:
B(t)=P 0(1-t) 3+3P 1t(1-t) 2+3P 2t 2(1-t)+P 3t 3,t∈[0,1]
P 0, P 1, P 2, P 3Four points have defined three bezier curve on the plane or in three dimensions.Curve originates in P 0Move towards P 1, and from P 2Direction come P 3Generally can not pass through P 1Or P 2, these two points only provide directional information.P 0And P 1Between spacing, determined curve then become into P 3Before, move towards P 2The length of direction.
The Bezier curve has following characteristic.
(1) limitlessly detachable: a Bezier curve can cut in the arbitrfary point two or any many strips curve, and each strip curve is still the Bezier curve.
(2) symmetry: keep the coordinate position of the whole control point Pi of Bezier curve constant, just the ordering of control point Pi is put upside down, curve shape remains unchanged.This property explanation Bezier curve has any geometric properties at the starting point place, at destination county identical geometric properties is arranged also.
(3) convex closure: the Bezier curve is positioned within the convex closure at its control point.
(4) geometric invariance: the Bezier curve location is relevant with the position of its feature polygon vertex with shape, and it does not rely on the selection of coordinate system.
(5) variation reduction property: no more than this straight line of the intersection point number of arbitrary line and curve and the polygonal intersection point number of its feature in the plane.
(6) end points tangent vector: the starting point of Bezier curve, terminal point overlap with the corresponding polygonal starting point of feature, terminal point.The tangential direction of its starting point and destination county is consistent with the trend on feature polygonal article one limit and the last item limit.
In view of the characteristic of above-mentioned Bezier curve, if dissimilar caption object all is converted to quadratic bezier curve, then be conducive to improve the rendering effect of captions, satisfy the senior application of captions and solve the problem that existing Method of Rendering Caption exists.After dissimilar caption object is converted to quadratic bezier curve, under some application scenario, the situation of an inner self intersection of sealing quadratic bezier curve can appear, for example from plot, caption object through rotation or some multilingual font in.Therefore need to process this situation, delete or cut apart and seal the closed circuit that quadratic bezier curve inside comprises.Moreover, between a plurality of closed outlines that a caption object comprises, also may there be crossing situation, need to a secondary Bezier line segment be divided into many secondary Bezier line segments according to intersection point, and then according to the inside and outside side attribute of secondary Bezier line segment closed outline is advised and put in order, otherwise can affect rendering effect and the efficient of caption object.
Summary of the invention
For the defective that exists in the prior art, the purpose of this invention is to provide the inside and outside side attribute of a kind of basis carries out merging to the caption object vector outline method.The method is mutually disjointed after can making crossing closed outline advise and put in order, thereby improves subtitle rendering efficiency, strengthens the caption rendering effect.
For reaching above purpose, the technical solution used in the present invention is: the inside and outside side attribute of a kind of basis carries out the method for merging to the caption object vector outline, may further comprise the steps:
(1) determines the inside and outside side attribute of every secondary Bezier line segment in all closed outlines of caption object;
(2) with attribute be the secondary Bezier line segment deletion of inner edge;
(3) according to the closed outline of intersection point reconstruct caption object;
(4) boundary rectangle of every secondary Bezier line segment in all closed outlines that obtain in the calculation procedure (3) and all closed outlines;
The direction of all closed outlines that (5) obtain in the markers step (3).
The inside and outside side attribute of aforesaid a kind of basis carries out the method for merging to the caption object vector outline, determine in the step (1) that the method for the inside and outside side attribute of secondary Bezier line segment is: judge that the secondary Bezier line segment meaning of taking up an official post is interior point or exterior point in all closed outlines of caption object a bit; If interior point, the secondary Bezier line segment that then comprises this point is inner edge; If exterior point, the secondary Bezier line segment that then comprises this point is the outside.
The inside and outside side attribute of aforesaid a kind of basis carries out the method for merging to the caption object vector outline, wherein, described secondary Bezier line segment is taken up an official post to anticipate and a bit is the mid point of secondary Bezier line segment.
The inside and outside side attribute of aforesaid a kind of basis carries out the method for merging to the caption object vector outline, wherein, the mid point of judging secondary Bezier line segment is interior point or the method for exterior point may further comprise the steps in all closed outlines of caption object: suppose that secondary Bezier line segment is B, three control points of B are respectively P[0], P[1], P[2], mid point is Q;
1. determine the direction value d of B: if P[2] .y〉P[0] .y, then d=1; If P[2] .y<P[0] .y, then d=-1; If P[2] .y=P[0] .y, then d=0; Described P[0] .y and P[2] .y represents respectively P[0] and P[2] ordinate;
2. calculate the mid point Q of B;
3. judge abs (P[2] .y-P[0] .y) whether greater than abs (P[2] .x-P[0] .x), in this way, then take the Q point as starting point, along continuous straight runs is made a ray H; As no, then vertically make a ray H take the Q point as starting point; Calculate all the secondary Bezier line segments except B that intersect with H in all closed outlines of caption object, suppose to have M bar secondary Bezier line segment and H crossing, be respectively B[0], B[1] to B[M-1]; Described P[0] .x and P[2] .x represents respectively P[0] and P[2] abscissa, described abs function is the function that takes absolute value;
4. calculate respectively B[i] direction value d[i], the method that method and step are calculated the d value in 1. is identical; Described i=0,1 ..., M-1;
5. calculate d[i] with value d ': d '=d[0]+d[1]+...+d[M-1];
6. according to the inside and outside side attribute value a of d and d ' calculating B; If a=0, then B is inner edge; If a=1, then B is the outside;
Described a=1-abs (SIGN (d+d ') * SIGN (d ')), is described SIGN (x) defined as (x==0)? 0:((x〉0)? 1:-1)).
The inside and outside side attribute of aforesaid a kind of basis carries out the method for merging to the caption object vector outline, in the step (1), behind the inside and outside side attribute of secondary Bezier line segment in having determined a closed outline, then the inside and outside side attribute of the secondary Bezier line segment after this secondary Bezier line segment of this closed outline is identical with it, until run into an intersection point.
The inside and outside side attribute of aforesaid a kind of basis carries out the method for merging to the caption object vector outline, the method for the secondary Bezier line segment in the step (4) in the calculating closed outline and the boundary rectangle of closed outline is:
Three control vertexs supposing secondary Bezier line segment are respectively P0, P1 and P2, and the abscissa that P0 is ordered is P0.x, and ordinate is P0.y; The abscissa that P1 is ordered is P1.x, and ordinate is P1.y; The abscissa that P2 is ordered is P2.x, and ordinate is P2.y; The leg-of-mutton boundary rectangle T that calculating is made of P0, P1 and P2, T is the boundary rectangle of this secondary Bezier line segment, and formula is as follows:
T.left=min(P0.x,P1.x,P2.x),
T.right=max(P0.x,P1.x,P2.x),
T.top=min(P0.y,P1.y,P2.y),
T.bottom=max(P0.y,P1.y,P2.y);
Wherein, T.left represents the abscissa of boundary rectangle left frame, and T.right represents the abscissa of boundary rectangle left frame, and T.top represents the ordinate of boundary rectangle upper side frame, and T.bottom represents the ordinate of boundary rectangle lower frame; The min function representation is got the minimum value in all parameters, and the max function representation is got the maximum in all parameters;
The boundary rectangle of secondary Bezier line segments all in the closed outline is merged, just obtain the boundary rectangle of this closed outline.
The inside and outside side attribute of aforesaid a kind of basis carries out the method for merging to the caption object vector outline, the direction described in the step (5) comprises clockwise direction and counter clockwise direction, and clockwise direction is labeled as 1, counterclockwise is labeled as-1; The method of mark closed outline direction is: at first take out any secondary Bezier line segment B from closed outline, calculate the value of the direction attribute b of closed outline, b=d* (1-2*abs (d ')); If b〉0, then this closed curve is clockwise direction, otherwise is counterclockwise.
Adopt method of the present invention, by the closed outline that intersects is advised and put in order, so that mutually disjoint between the closed outline, thereby improved the rendering efficiency of captions, strengthened the rendering effect of captions.
Description of drawings
Fig. 1 in the embodiment converts oval pel to the closed outline schematic diagram that is comprised of the cubic Bezier line segment;
Fig. 2 is that the pel that in the embodiment wave flag waftd converts the closed outline schematic diagram that is comprised of the cubic Bezier line segment to;
Fig. 3 is the closed outline schematic diagram that in the embodiment heart-shaped pel is converted to cubic Bezier line segment composition;
Bezier line segment of Fig. 4 converts secondary Bezier line segment schematic diagram to, and 4a is a front Bezier line segment schematic diagram of conversion, and 4b is the quadratic B ezier line segment schematic diagram after changing;
Fig. 5 cubic Bezier line segment converts two quadratic B ezier line segment schematic diagrames to, and the contrast schematic diagram before and after 5a cubic Bezier line segment conversion, 5b are the contrast schematic diagrames before and after the another kind of cubic Bezier line segment conversion;
Fig. 6 exists the closed outline of adjacent secondary Bezier line segment self intersection situation to process front and back effect schematic diagram in the embodiment;
Fig. 7 exists the closed outline of non-adjacent secondary Bezier line segment self intersection situation to process front and back effect schematic diagram in the embodiment;
Fig. 8 is the boundary rectangle schematic diagram of secondary Bezier line segment in the embodiment;
Fig. 9 is secondary Bezier line segment mid point schematic diagram in the embodiment;
Figure 10 is twice processing of the closed outline front and back effect schematic diagram that has non-adjacent secondary Bezier line segment self intersection situation in the embodiment;
Figure 11 is the method flow diagram of cutting apart secondary Bezier in the caption object vector outline in the embodiment according to intersection point;
Figure 12 is the method flow diagram that calculates the intersection point of secondary Bezier line segments all in the caption object vector outline and other secondary Bezier line segments in the embodiment;
Figure 13 is method flow diagram of the present invention;
Figure 14 determines the inside and outside side attribute schematic diagram of a secondary Bezier line segment in the embodiment.
Embodiment
Describe the present invention below in conjunction with embodiment and accompanying drawing.
Method of the present invention be mainly used in dissimilar caption object is converted to by quadratic B ezier line segment form comprise the vector outline information of one or more closed outlines the time, in the caption rendering of the secondary Bezier line segment that exist to intersect between the different closed outlines.
Dissimilar caption object is converted to the vector outline information that comprises one or more closed outlines that is comprised of quadratic B ezier line segment can adopts following method.
Because the type of caption object comprises text subtile, fundamental figure captions and compound captions (captions that comprise literal and fundamental figure), therefore need to carry out different processing for dissimilar caption object.
If the type of caption object is text subtile, then can directly use the TrueType character library of operating system, need not conversion.Its method mainly may further comprise the steps:
1. according to the font name of text subtile object, the API (CreateFont) that uses operating system to provide creates logical font object F;
2. the API (SelectObject) that uses operating system to provide is set to logical font object F in the resource description table of operating system, and preserves the original logical font of operating system;
3. the Unicode according to current character encodes, the API (GetGlyphOutline) that uses operating system to provide obtains the internal memory byte number B that the vector outline information of current character takies in the TrueType character library from the current resource description table of operating system;
4. the internal memory byte number B that takies according to current character, storage allocation P;
5. according to the Unicode coding of current character and the internal memory P that takies, reuse the API (GetGlyphOutline) that operating system provides, from the current resource description table of operating system, obtain the vector outline information G of current character, and the original logical font of recovery operation system.
If the type of caption object is the fundamental figure captions, then convert thereof into the vector outline information of the closed outline that is formed by some three Bezier line segments, mainly be to determine every control point coordinate on the Bezier line segment according to the geometric parameter of fundamental figure, specifically may further comprise the steps:
1. according to the geometry of fundamental figure captions, the fundamental figure captions are divided into many curved sections, described curved section comprises straightway, just profound or remaining profound curved section, arc section and oval segmental arc;
2. according to the parametric equation of the boundary rectangle of fundamental figure captions, every curved section calculate every curved section convert to three times behind the Bezier line segment initial control point and the coordinate of finishing control point;
3. to every three Bezier line segments, coordinate and three Bezier parametric equations according to initial control point and finishing control point calculate respectively the coordinate at two other control point at t=1/3 and t=2/3 place.
Take the geometry of fundamental figure captions as ellipse as example, as shown in Figure 1.At first, be divided into four Bezier line segments according to oval four intersection point P100, P103, P106 and P109 with its boundary rectangle, be respectively from P100 to P103, from P103 to P106, from P106 to P109 and from P109 to P100.Four control points of the three bezier curve from P100 to P103 are respectively P100, P101, P102 and P103, four control points of the three bezier curve from P103 to P106 are respectively P103, P104, P105 and P106, four control points of the three bezier curve from P106 to P109 are respectively P106, P107, P108 and P109, and four control points of the three bezier curve from P109 to P100 are respectively P109, P110, P111 and P100.
Then, calculate coordinate (a, b), transverse axis radius r a and the longitudinal axis radius r b of elliptical center point according to four apex coordinates of the boundary rectangle of oval pel.The computing formula of each control point coordinate of every three Bezier line segments is as follows:
Make PinA=ra*0.55179445, PinB=rb*0.55179445.
P100.x=a, P100.y=b+rb;
P101.x=a+PinA; P101.y=b+rb;
P102.x=a+ra; P102.y=b+PinB;
P103.x=a+ra; P103.y=b;
P104.x=a+ra; P104.y=b-PinB;
P105.x=a+PinA; P105.y=b-rb;
P106.x=a; P106.y=b-rb;
P107.x=a-PinA; P107.y=b-rb;
P108.x=a-ra; P108.y=b-PinB;
P109.x=a-ra; P109.y=b;
P110.x=a-ra; P110.y=b+PinB;
P111.x=a-PinA; P111.y=b+rb。
Wherein, P100.x represents the abscissa that P100 is ordered, and P100.y represents the ordinate that P100 is ordered.In the present embodiment, other represent that similarly the implication of mode is identical with P100.
Waft shape as example, as shown in Figure 2 take the geometry of fundamental figure captions as the wave flag.At first, be divided into four curved sections according to four intersection point P200, P203, P206 and P209 of two curved sections and two straightways, be respectively from P200 to P203, from P203 to P206, from P206 to P209 and from P209 to P200.After converting every curved section to three Beziers, four control points of the cubic Bezier line segment from P200 to P203 are respectively P200, P201, P202 and P203, four control points of the cubic Bezier line segment from P203 to P206 are respectively P203, P204, P205 and P206, four control points of the cubic Bezier line segment from P206 to P209 are respectively P206, P207, P208 and P209, and four control points of the cubic Bezier line segment from P209 to P200 are respectively P209, P210, P211 and P200.
Waft four point coordinates of boundary rectangle of shape pel of known wave flag can calculate width and the height of this pel boundary rectangle, are respectively W2 and H2.In addition, according to waft parameter f x and the fy of horizontal and vertical amplitude of pel of known adjusting wave flag, can calculate the coordinate that P200 orders and be (a, b), a=fx*W, b=fy*H.
The computational process of control point coordinate may further comprise the steps on every three Bezier line segment.
1. based on just profound curvilinear equation, calculate the P203 point coordinates according to the P200 point coordinates.
P203.x=W2;
P203.y=b+b*0.9*sin((W2-a)*2*PI/W2)。
2. take the P200 point as starting point, take the P203 point as terminal point, according to the three bezier curve equation, calculate respectively the P201 point at t=1/3 and t=2/3 place and the coordinate that P202 is ordered.
P201.x=((m 1*c 2-m 2*c 1)-(a 1*c 2-a 2*c 1)*P200.x-(d 1*c 2-c 1*d 2)*P203.x)/(b 1*c 2-b 2*c 1)。
P202.x=((m 1*b 2-m 2*b 1)-(a 1*b 2-a 2*b 1)*P200.x-(d 1*b 2-d 2*b 1)*P203.x)/(c 1*b 2-c 2*b 1)。
Wherein, m 1=a+ (W2-a)/3, m 2=a+ (W2-a) * 2/3; t 1=1.0/3, t 2=2.0/3;
a 1=(1-t 1)*(1-t 1)*(1-t 1);
b 1=3*t 1*(1-t 1)*(1-t 1);
c 1=3*t 1*t 1*(1-t 1);
d 1=t 1*t 1*t 1
a 2=(1-t 2)*(1-t 2)*(1-t 2);
b 2=3*t 2*(1-t 2)*(1-t 2);
c 2=3*t 2*t 2*(1-t 2);
d 2=t 2*t 2*t 2
P201.y=((n 1*c 2-n 2*c 1)-(a 1*c 2-a 2*c 1)*P200.y-(d 1*c 2-c 1*d 2)*P203.y)/(b 1*c 2-b 2*c 1)。
P202.y=((n 1*b 2-n 2*b 1)-(a 1*b 2-a 2*b 1)*P200.y-(d 1*b 2-d 2*b 1)*P203.y)/(c 1*b 2-c 2*b 1)。
Wherein, n 1=b-b*0.9*sin ((W2-a) * 2*PI/ (3*W2)),
n 2=b-b*0.9*sin((W2-a)*2*PI*2/(3*W2))。
3. based on just profound curvilinear equation, calculate the P206 point coordinates according to the P200 point coordinates.
P206.x=W2-a;
P206.y=H2-b-b*0.9*sin((W2-a)*2*PI/W2)
4. calculate the P209 point coordinates.
P209.x=0;
P209.y=H2-b
5. take the P206 point as starting point, take the P209 point as terminal point, according to the three bezier curve equation, calculate respectively P207 point and the P208 point coordinates at t=1/3 and t=2/3 place, computational methods are identical with the coordinate that calculating P201 point, P202 are ordered.
6. the P204 point coordinates equals the P203 point coordinates, and the P205 point coordinates equals the P206 point coordinates, and the P210 point coordinates equals the P209 point coordinates, and the P211 point coordinates equals the P200 point coordinates.Why will repeat this several points, be for so that every Bezier line segment in the sealing vector outline information of this caption object all is three bezier curve.In fact, the three bezier curve that is formed by control point P203, P204, P205, P206, and be the straight line section by the three bezier curve that control point P209, P210, P211, P200 form.
Take the geometry of fundamental figure captions as heart as example, as shown in Figure 3.Four point coordinates of the boundary rectangle of known heart-shaped pel, can calculate this pel width and the height, be respectively W3 and H3.At first this pel is divided into 8 curved sections, is respectively from P300 to P303, from P303 to P306, from P306 to P309, from P309 to P312, from P312 to P315, from P315 to P318, P318 is to P320, from P320 to P300.Every curved section converted to the computational process of each control point coordinate may further comprise the steps behind three Bezier line segments.
1. at first according to the features of shape of heart-shaped pel, the coordinate of calculation level P300, P303, P306 and P309.
P300.x=0.73*W3+0.27*W3*cos(A),
P300.y=0.25*H3-0.25*H3*sin(A);
P303.x=0.73*W3+0.27*W3*cos(PI/3+A),
P303.y=0.25*H3-0.25*H3*sin(PI/3+A);
P306.x=0.73*W3+0.27*W3*cos(2*PI/3+A),
P306.y=0.25*H3-0.25*H3*sin(2*PI/3+A);
P309.x=0.73*W3+0.27*W3*cos(PI+A),
P309.y=0.25*H3-0.25*H3*sin(PI+A)。
Wherein PI and A are constant, PI=3.1415926, A=-0.5535442.
2. utilize the cubic Bezier parametric equation, take the P300 point as starting point, take the P303 point as terminal point, calculate respectively the P301 point at t=1/3 and t=2/3 place and the coordinate that P302 is ordered.The matrix form of three bezier curve is as follows:
P ( t ) = t 3 t 2 t 1 2 - 2 1 1 - 3 3 - 2 - 1 0 0 1 0 1 0 0 0 P 600 P 601 P 602 P 603 t∈[0,1]
X ( t ) = t 3 t 2 t 1 2 - 2 1 1 - 3 3 - 2 - 1 0 0 1 0 1 0 0 0 X 0 X 1 X 2 X 3 t∈[0,1]
Y ( t ) = t 3 t 2 t 1 2 - 2 1 1 - 3 3 - 2 - 1 0 0 1 0 1 0 0 0 Y 0 Y 1 Y 2 Y 3 t∈[0,1]
After top matrix expansion, obtain:
X(t)=A 0+A 1*t+A 2*t 2+A 3*t 3
Y(t)=B 0+B 1*t+B 2*t 2+B 3*t 3
Wherein, A 0=X 0A 1=-3X 0+ 3X 1A 2=3X 0-6X 1+ 3X 2A 3=-X 0+ 3X 1-3X 2+ X 3B 0=Y 0B 1=-3Y 0+ 3Y 1B 2=3Y 0-6Y 1+ 3Y 2B 3=-Y 0+ 3Y 1-3Y 2+ Y 3
Because the coordinate X that P300 point and P303 are ordered 0, X 3, Y 0, Y 3Known, the t value that P301 is ordered is that the t value that 1/3, P302 is ordered is 2/3, therefore can list a following quaternary linear function group:
X 1=A 0+A 1*(1/3)+A 2*(1/3) 2+A 3*(1/3) 3
Y 1=B 0+B 1*(1/3)+B 2*(1/3) 2+B 3*(1/3) 3
X 2=A 0+A 1*(2/3)+A 2*(2/3) 2+A 3*(2/3) 3
Y 2=B 0+B 1*(2/3)+B 2*(2/3) 2+B 3*(2/3) 3
Separate this equation group, can obtain the coordinate X that P301 and P302 are ordered 1, X 2, Y 1, Y 2Value.
3. utilize the cubic Bezier parametric equation, take the P303 point as starting point, take the P306 point as terminal point, calculate respectively the P304 point at t=1/3 and t=2/3 place and the coordinate that P305 is ordered.3. method asks the coordinate of P301, P302 identical in the step with the, repeats no more.
4. utilize the cubic Bezier parametric equation, take the P306 point as starting point, take the P309 point as terminal point, calculate respectively the P307 point at t=1/3 and t=2/3 place and the coordinate that P308 is ordered.3. method asks the coordinate of P301, P302 identical in the step with the, repeats no more.
5. according to the left-right symmetric of heart-shaped pel, can obtain the coordinate of P311, P312, P313, P314, P315, P316, P317 and P318.
6. the P320 coordinate of ordering is (W/2, H).
7. P323, the P324 coordinate of ordering equals the P300 point, and the coordinate that P319 is ordered equals the P318 point, and the coordinate that P321, P322 are ordered equals the P320 point.
At last, obtain the vector outline information that 8 three Bezier line segments form.These 8 three Bezier line segments are as follows:
Article one, three Bezier line segments being formed by control point (P300, P301, P302, P303) of line segment;
Three Bezier line segments that the second line segment is formed by control point (P303, P304, P305, P306);
Article three, three Bezier line segments being formed by control point (P306, P307, P308, P309) of line segment;
Article four, three Bezier line segments being formed by control point (P309, P310, P311, P312) of line segment;
Article five, three Bezier line segments being formed by control point (P312, P313, P314, P315) of line segment;
Article six, three Bezier line segments being formed by control point (P315, P316, P317, P318) of line segment;
Article seven, three Bezier line segments being formed by control point (P318, P319, P320, P321) of line segment (because the coordinate of P318, P319 is identical, the coordinate of P320, P321 is identical, so this line segment is actually the straight line section);
Article eight, three Bezier line segments being formed by control point (P321, P322, P323, P324) of line segment (because the coordinate of P321, P322 is identical, the coordinate of P323, P324 is identical, so this line segment is actually the straight line section).
For the fundamental figure caption object of other types, can be according to same thought, be converted into by once, the closed outline that forms of secondary or cubic Bezier line segment.
When the type of caption object was compound captions, the method that converts thereof into vector outline information may further comprise the steps:
1. according to the data structure of compound caption object, it is split as the individual basic caption object of M (M is positive integer).Basic caption object just refers to text subtile object or fundamental figure caption object.
2. use respectively the processing method of above-mentioned " text subtile object " and " fundamental figure caption object " to obtain this M the substantially vector outline information of caption object.
3. according to the space coordinate of the basic caption object of M, M the vector outline information combination that step is obtained in 2. forms the final vector outline information of this compound caption object together.
Caption object through after the above-mentioned conversion, is also needed rotation, deformation parameter according to caption object, the vector outline information after the conversion is carried out the space geometry conversion.
The anglec of rotation of supposing caption object is A, and the control point number of basic caption object is n (n is positive integer), is respectively P[0] to P[n-1], the process of then a basic caption object being carried out the space geometry conversion may further comprise the steps.
A. four apex coordinates of the boundary rectangle of the basic caption object of basis calculate the coordinate of the central point Q of basic caption object.
B. according to the postrotational P[i of following formula correction] coordinate of (0≤i≤n, i are positive integer):
x=P[i].x-Q.x,
y=P[i].y-Q.y,
P[i].x=Q.x+x*cos(A)-y*sin(A),
P[i].y=Q.y+x*sin(A)+y*cos(A);
Wherein, P[i] .x and P[i] .y is respectively P[i] point is horizontal, ordinate, Q.x and Q.y are respectively horizontal stroke, the ordinate that Q is ordered.
Dissimilar caption object is converted to by once, behind the closed outline that forms of secondary or three bezier curve, in order to make the consistency of render engine on algorithm process, reduce the complexity of algorithm, the efficient of optimized algorithm also needs the Bezier line segment unification of different number of times is converted to quadratic B ezier line segment.
The principle that Bezier line segment is converted to quadratic B ezier line segment is: with former and later two control points R0 of a Bezier line segment and R1 first and the 3rd control point as quadratic B ezier line segment, the mid point of R0 and R1 is as second control point of quadratic B ezier line segment.
Fig. 4 is that a Bezier line segment is converted to secondary Bezier line segment schematic diagram, and 4a is a front Bezier line segment of conversion, and 4b is the quadratic B ezier line segment after changing.Wherein, P40=R40, P42=R41, P41=(mid point of R40 and R41), i.e. P41.x=(R40.x+R41.x)/2; P41.y=(R40.y+R41.y)/2.
The principle that the cubic Bezier line segment is converted to quadratic B ezier line segment is: convert a cubic Bezier line segment to two quadratic B ezier line segments.
5a among Fig. 5 and 5b are respectively two kinds of situation schematic diagrames that the cubic Bezier line segment are converted to two quadratic B ezier line segments.The control point of supposing a cubic Bezier line segment is respectively R50, R51, R52, R53.Q1 is the mid point of R50 and R51, Q2 is the mid point of R52 and R53, Q3 is the mid point of R51 and R52, Q4 is the mid point of Q1 and Q3, Q5 is the mid point of Q2 and Q3, Q6 is the mid point of Q4 and Q5, and Q7 is straight line and R0 and the straight intersection point of R1 structure that Q4 and Q5 consist of, and Q8 is straight line and R52 and the straight intersection point of R53 structure that Q4 and Q5 consist of.
As follows according to the coordinate that coordinate and the Bezier parametric equation of 4 of R50, R51, R52, R53 calculates Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8:
Q1.x=(R50.x+R51.x)/2,Q1.y=(R50.y+R51.y)/2;
Q2.x=(R52.x+R53.x)/2,Q2.y=(R52.y+R53.y)/2;
Q3.x=(R51.x+R52.x)/2,Q3.y=(R51.y+R52.y)/2;
Q4.x=(Q1.x+Q3.x)/2,Q4.y=(Q1.y+Q3.y)/2;
Q5.x=(Q2.x+Q3.x)/2,Q5.y=(Q2.y+Q3.y)/2;
Q6.x=(Q4.x+Q5.x)/2,Q6.y=(Q4.y+Q5.y)/2;
Q7.x=(3*Q1.x+3*Q4.x-R0.x-Q6.x)/4,
Q7.y=(3*Q1.y+3*Q4.y-R0.y-Q6.y)/4;
Q8.x=(3*Q2.x+3*Q5.x-R3.x-Q6.x)/4,
Q8.y=(3*Q2.y+3*Q5.y-R3.y-Q6.y)/4。
Original cubic Bezier line segment is punished into two quadratic B ezier line segments at the Q6 point, and three control points of a Bezier line segment are respectively R50, Q7, and Q6, three control points of another Bezier line segment are respectively Q6, Q8, R53.
In the vector outline information of the closed outline that is formed by quadratic bezier curve, may there be the quadratic B ezier line segment of self intersection, namely closed outline includes one or more closed circuits, such as Fig. 6, Fig. 7 and shown in Figure 10.In order to strengthen the rendering effect of captions, improve rendering efficiency, need to process this situation, delete or cut apart closed circuit.
The method of processing the secondary Bezier of self intersection is: at first judge the situation that whether has secondary Bezier line segment self intersection among the closed outline G, if exist, then continue to judge it is adjacent secondary Bezier line segment self intersection or non-adjacent secondary Bezier line segment self intersection, if adjacent secondary Bezier line segment self intersection, then with the closed circuit deletion that comprises adjacent secondary Bezier line segment self intersection that includes among the closed outline G; If non-adjacent secondary Bezier line segment self intersection then is divided into a plurality of closed outlines with closed outline G and its closed circuit that comprises non-adjacent secondary Bezier line segment self intersection that includes.
Judge whether exist the method for secondary Bezier line segment self intersection to be among the closed outline G: supposing to have among the G M secondary Bezier line segment, is respectively B[0], B[1], B[2] to B[M-1]; Take out successively each secondary Bezier line segment B[j among the G], judge B[j] whether crossing with other secondary Bezier line segment among the G, if intersect, then there is the self intersection situation in G; Otherwise, do not have the self intersection situation.
Judge that the method whether two secondary Bezier line segments intersect is: the boundary rectangle that at first calculates two secondary Bezier line segments; Whether the boundary rectangle of then judging two secondary Bezier line segments exists common factor, if exist, then these two secondary Bezier line segments intersect, and if there is no, then these two secondary Bezier line segments are non-intersect.
With reference to Fig. 8, the method for calculating the boundary rectangle of a secondary Bezier line segment is: three control points supposing secondary Bezier line segment are respectively P0, P1 and P2, and the abscissa that P0 is ordered is P0.x, and ordinate is P0.y; The abscissa that P1 is ordered is P1.x, and ordinate is P1.y; The abscissa that P2 is ordered is P2.x, and ordinate is P2.y; The leg-of-mutton boundary rectangle T that calculating is made of P0, P1 and P2, T is the boundary rectangle of this secondary Bezier line segment, and formula is as follows:
T.1eft=min(P0.x,P1.x,P2.x),
T.right=max(P0.x,P1.x,P2.x),
T.top=min(P0.y,P1.y,P2.y),
T.bottom=max(P0.y,P1.y,P2.y);
Wherein, T.1eft represent the abscissa of boundary rectangle left frame, T.right represents the abscissa of boundary rectangle left frame, and T.top represents the ordinate of boundary rectangle upper side frame, and T.bottom represents the ordinate of boundary rectangle lower frame; The min function representation is got the minimum value in all parameters, and the max function representation is got the maximum in all parameters.
If there is the situation of secondary Bezier line segment self intersection among the closed outline G, then judge it is that adjacent secondary Bezier line segment self intersection or the method for non-adjacent secondary Bezier line segment self intersection are: if B[j] and adjacent segments B[j+1] intersect, then be adjacent secondary Bezier line segment self intersection, otherwise be non-adjacent secondary Bezier line segment self intersection.
With reference to Fig. 6, if adjacent secondary Bezier line segment self intersection, then the method with the closed circuit deletion of the adjacent secondary Bezier line segment that comprises self intersection that includes among the closed outline G is:
Supposing to have among the G M secondary Bezier line segment, is respectively B[0], B[1], B[2] to B[M-1], the adjacent secondary Bezier line segment of two self intersections is respectively B[j] and B[j+1]; At first calculate B[j] and B[j+1] point of intersection S; Then with B[j] initial control point link to each other with S consist of a new secondary Bezier line segment B[j '], with S and B[j+1] finishing control point link to each other consist of a new secondary Bezier line segment B[j+1 '], B[j '], B[j+1 '] with closed outline G in original secondary Bezier line segment B[0] to B[j-1], B[j+2] to B[M-1] consisted of a new closed outline G ', make G=G '; Delete at last S and B[j] the closed outline that consists of of finishing control point.(6a) is the front closed outline G of processing among Fig. 6, (6b) is the closed outline G after processing, (6c) closed outline for deleting.
With reference to Fig. 7, if non-adjacent secondary Bezier line segment self intersection, the method that then closed circuit of closed outline G and its non-adjacent secondary Bezier line segment that comprises self intersection that includes is divided into a plurality of closed outlines is:
The non-adjacent secondary Bezier line segment of supposing two self intersections is respectively B[j] and B[k], j<k; At first calculate B[j] and B[k] point of intersection S; Then with B[j] initial control point link to each other with S consist of a new secondary Bezier line segment B[j '], and with S and B[k] finishing control point link to each other consist of a new secondary Bezier line segment B[k '], B[j '], B[k '] with closed outline G in original line segment B[0] to B[j-1], B[k+1] to B[M-1] consisted of a new closed outline G ', make G=G '; At last with S and B[j] finishing control point and B[k] initial control point link to each other, two new secondary Bezier line segments have been formed, with these two new secondary Bezier line segment and B[j+1] to B[k-1] in all secondary Bezier line segments consisted of a new closed outline G ", G " is joined caption object vector outline information table.
Calculate the method for two quadratic bezier curve intersection points in the caption object vector outline information, in theory, can calculate according to the combined parameters equation of two quadratic bezier curves.But this method is worthless, because not only amount of calculation is huge, and all is based on the computing of floating number, and the efficient of algorithm can be lower.Therefore, present embodiment adopts " two minutes iterative methods ".The core concept of the method is: if two quadratic B ezier line segment intersections, these two quadratic B ezier line segments of naming a person for a particular job in the basis so are divided into respectively two quadratic B ezier line segments, obtain 4 quadratic B ezier line segments; And then after the same method, process this 4 line segments, until the initial control point of final every line segment and the air line distance of finishing control point (generally, this value is less than some values
Figure G2008102258667D00191
), finally can be summed up as the intersection point that calculates two straightways.The method specifically may further comprise the steps:
(I) suppose that two crossing secondary Bezier line segments are respectively B[j] and B[k], with B[j] and B[k] be handled as follows respectively:
1. calculate the initial control point of secondary Bezier line segment and the air line distance L between the finishing control point, L = ( x 1 - x 0 ) 2 + ( y 1 - y 0 ) 2 , wherein, x0, y0 are that initial control point is horizontal, ordinate, x1 and y1 are that finishing control point is horizontal, ordinate;
2. whether judge L greater than M, if greater than, then calculate the mid point of secondary Bezier line segment, secondary Bezier line segment is divided into two secondary Bezier line segments in midpoint, described M = 2 ;
3. repeating step 1. to step 2., until the initial control point of every secondary Bezier line segment after dividing and the air line distance L between the finishing control point are less than or equal to M;
(II) with B[j] and B[k] through after step (I) processing, suppose that final two secondary Bezier line segments that intersect are respectively B[j '] and B[k '], calculate B[j '] initial control point and straight line and the B[k ' of finishing control point formation] initial control point and the intersection point of the straight line of finishing control point formation.
In the present embodiment, the method for calculating the mid point of secondary Bezier line segment is: three control points supposing secondary Bezier line segment are respectively P0, P1 and P2, and function expression is
B(t)=(1-t) 2P 0+2t(1-t) 2P 1+t 2P 2 t∈[0,1];
Make t=0.5, calculate on the secondary bezier curve equation a bit, this point is the mid point of secondary Bezier line segment, and the computing formula of its coordinate is B=(P0+2*P1+P2)/4.
As shown in Figure 9, R1 is the mid point of straight line (P0, P1), and R2 is the mid point of straight line (P1, P2), and R3 is the mid point of straight line (P2, P0), and Q is the intersection point of straight line (R1, R2) and straight line (R3, P1).The Q point is the mid point of quadratic bezier curve (P0, P1, P2).
R1 point abscissa R1.x=(P0.x+P1.x)/2, R1 point ordinate R1.y=(P0.y+P1.y)/2; R2 point abscissa R2.x=(P1.x+P2.x)/2, R2 point ordinate R2.y=(P1.y+P2.y)/2.Wherein, P0.x, P0.y are that the P0 point is horizontal, ordinate; P1.x, P1.y are that the P1 point is horizontal, ordinate; P2.x, P2.y are that the P2 point is horizontal, ordinate.
The ordinate Q.y=(R1.y+R2.y) that the abscissa Q.x=(R1.x+R2.x) that Q is ordered/2=(P0.x+2*P1.x+P2.x)/4, Q are ordered/2=(P0.y+2*P1.y+P2.y)/4.
After the situation of non-adjacent secondary Bezier line segment self intersection among the closed outline G was processed, still might there be the situation of self intersection in the closed outline after cutting apart.As shown in figure 10, closed outline (10a) after treatment, be divided into (10b), (10c) and (10d) shown in closed outline, wherein still there is the situation of self intersection in the closed outline shown in (10c), therefore need to repeat above-mentioned steps the closed outline shown in (10c) is processed again, until there is not the situation of self intersection to occur in all closed outlines after cutting apart.Closed outline (10c) is through after processing again, is divided into (10c1) and (10c2) two closed outlines.
In the vector outline information of caption object, may there be crossing situation between the different closed outlines, in order to be conducive to the follow-up rendering of caption object, strengthen the final rendering effect of caption object, need to process this situation, at the intersection point place quadratic B ezier line segment is divided into many quadratic B ezier line segments.
Figure 11 has shown the method for cutting apart secondary Bezier in the caption object vector outline according to intersection point of the present invention, may further comprise the steps:
(1) calculates secondary Bezier line segments all in the caption object vector outline and the intersection point of other secondary Bezier line segments;
(2) at the intersection point place of every secondary Bezier line segment, this secondary Bezier line segment is cut apart;
Three control points supposing a secondary Bezier line segment B are respectively P[0], P[1], P[2], at B n intersection point arranged, be respectively S[0] to S[n-1], the t value in Bezier parametric equation corresponding to each intersection point is respectively S[0] .t is to S[n-1] .t;
At first at S[0] the some place is divided into two line segment B1 and B1 ' with line segment B;
Three control points of B1 are respectively P[0], Q[0], S[0], P[0] and S[0] coordinate known, Q[0] coordinate be:
Q[0].x=(1-t)*P[0].x+t*P[1].x,
Q[0].y=(1-t)*P[0].y+t*P[1].y;
Three control points of B1 ' are respectively S[0], R[0], P[2], S[0] and P[2] coordinate known, R[0] coordinate be:
R[0].x=(1-t)*P[1].x+t*P[2].x,
R[0].y=(1-t)*P[1].y+t*P[2].y;
Wherein, Q[0] .x represents Q[0] abscissa of point, Q[0] .y represents Q[0] and the ordinate of point, R[0] .x represents R[0] and the some abscissa, R[0] .y represents R[0] the some ordinate; T=(S[0] .t-P[0] .t)/(P[2] .t-P[0] .t), P[0] .t is P[0] t value in Bezier parametric equation corresponding to point, P[2] .t is P[2] t value in the Bessel equation of some correspondence;
Then at S[1] the some place is divided into two line segment B2 and B2 ' with line segment B1 ', and method is 1. identical with step;
By that analogy, at last at S[n-1] the some place is divided into two line segment Bn and Bn ' with line segment Bn-1 '; Finally obtain the line segment after the N+1 bar is cut apart.
Figure 12 has shown the method flow that calculates the intersection point of secondary Bezier line segments all in the caption object vector outline and other secondary Bezier line segments, may further comprise the steps:
1. travel through closed outlines all in the caption object vector outline, take out one from get different closed outline G[i];
2. travel through G[i] in all quadratic B ezier line segments, take out one from get different secondary Bezier line segment B[j];
3. travel through in this caption object vector outline except B[j] all secondary Bezier line segments, take out one from get different secondary Bezier line segment B[k];
4. judge B[j] and B[k] boundary rectangle whether have common factor, if there is no, then go to step 3.; If exist, then calculate B[j] and B[k] between intersection point.
Calculate B[j] with B[k] between intersection point and the principle of the intersection point of the secondary Bezier line segment of above-mentioned calculating self intersection identical, repeat no more herein.
Figure 13 has shown the method flow of the caption object vector outline being advised and being put in order according to the inside and outside side attribute of secondary Bezier line segment of the present invention, mainly may further comprise the steps.
(1) determines the inside and outside side attribute of every secondary Bezier line segment in all closed outlines of caption object.
Determine the inner edge of a secondary Bezier line segment/outer side attribute, only need to determine that any one point on this secondary Bezier line segment is interior point or exterior point gets final product in the vector outline information of whole caption object, generally can use the mid point of this line segment.If the mid point of this line segment is interior point, then this line segment is inner edge; If exterior point, then this line segment is the outside.
The mid point of judging secondary Bezier line segment is interior point or the method for exterior point may further comprise the steps in all closed outlines of caption object.
Suppose that secondary Bezier line segment is B, three control points of B are respectively P[0], P[1], P[2], mid point is Q.
1. determine the direction value d of B: if P[2] .y〉P[0] .y, then d=1; If P[2] .y<P[0] .y, then d=-1; If P[2] .y=P[0] .y, then d=0.Wherein, P[0] .y and P[2] .y represents respectively P[0] and P[2] ordinate.
2. calculate the mid point Q coordinate of B.
3. judge abs (P[2] .y-P[0] .y) whether greater than abs (P[2] .x-P[0] .x), in this way, then take the Q point as starting point, along continuous straight runs is made a ray H to the right; As no, then vertically upwards make a ray H take the Q point as starting point.In the present embodiment, suppose that along continuous straight runs makes a ray H to the right, as shown in figure 14.Calculate all the secondary Bezier line segments except B that intersect with H in all closed outlines of caption object, suppose to have M bar secondary Bezier line segment and H crossing, be respectively B[0], B[1] to B[M-1].Wherein, P[0] .x and P[2] .x represents respectively P[0] and P[2] abscissa, the abs function is the function that takes absolute value.
4. calculate respectively B[i] direction value d[i], the method that method and step are calculated the d value in 1. is identical.Wherein, i=0,1 ..., M-1.
5. calculate d[i] with value d ': d '=d[0]+d[1]+...+d[M-1].
6. according to the inside and outside side attribute value a of d and d ' calculating B:
a=1-abs(SIGN(d+d′)*SIGN(d′))。Wherein, is SIGN (x) defined as (x==0)? 0:((x〉0)? 1:-1)), if i.e. x=0, then SIGN (x)=0; If x〉0, SIGN (x)=1 then; If x<0, then SIGN (x)=-1.
If a=0, then B is inner edge; If a=1, then B is the outside.
Behind the inside and outside side attribute of a secondary Bezier line segment in having determined a closed outline, then the inside and outside side attribute of the secondary Bezier line segment after this closed outline this secondary Bezier line segment is identical with it, until run into an intersection point.
Utilize said method can determine the inside and outside side attribute of every secondary Bezier line segment comprising in all closed outlines.
(2) with attribute be the secondary Bezier line segment deletion of inner edge.
Behind the inside and outside side attribute of every the secondary Bezier line segment that in having determined vector outline information, has comprised in all closed outline, deleting all methods that are labeled as the secondary Bezier line segment of inner edge is: in every secondary Bezier line segment, there is a border attribute variable to represent inner edge/outer side attribute, all secondary Bezier line segments in the traversal vector outline information are that the secondary Bezier line segment of inner edge is deleted from closed outline and got final product with the border attribute.
(3) according to the closed outline of intersection point reconstruct caption object.
Delete property need to re-start rule also to all closed outlines after being the secondary Bezier line segment of inner edge, namely according to intersection point secondary Bezier line segment is coupled together, and rebuilds each closed outline.The closed outline that rebuilds must be disjoint closed outline each other.
The concrete grammar of rule and a caption object may further comprise the steps:
A. from all closed outlines, take out one from get different closed outline G1;
B. judge that whether the difference of starting point coordinate of the end point coordinate of the last item secondary Bezier line segment of G1 and article one secondary Bezier line segment is less than or equal to threshold values T, usually T gets 0.00001, in this way, then G1 does not need to process, repeating step a is to step b, until all closed outlines are processed complete;
C. take out the next closed outline G2 adjacent with G1;
Whether the curve tail of d. judging G1 overlaps with the curve tail of G2 with the curve head of G2 or the curve head of G1, judge that namely whether the difference of end point coordinate of the last item secondary Bezier line segment of the starting point coordinate of article one secondary Bezier line segment of the difference of starting point coordinate of article one secondary Bezier line segment of the end point coordinate of the last item secondary Bezier line segment of G1 and G2 or G1 and G2 is less than or equal to threshold values T, in this way, then G1, G2 are merged, and from vector outline, delete G2;
E. take out the next closed outline G2 ' adjacent with G2, make G2=G2 ', repeating step d equates with G1 until G2 is last closed outline or G2;
F. repeating step a is to step e, until all closed outlines are processed complete.
Said process is described below with false code:
First closed outline in the G1=vector outline;
All closed outlines in while (G1 unequal to NULL) // traversal vector outline
{
While (G1 needs again to process)
{
G2=G1.Next; //G2 is the next closed outline adjacent with G1
while(G2!=NULL&&G2!=G1)
{
If (G2 needs again to process)
{
If (nose heave the closing of curve of the curve tail of G1 and G2)
{
// G1 and G2 are joined end to end
G1.Tail.Next=G2.Head;
G1.Head.Prev=G2.Tail;
G2.Tail.Next=G1.Head;
G2.Head.Prev=G1.Tail;
G1.Tail=G2.Tail;
G′=G2;
G2=G2.Prev;
From the closed outline chained list, delete G ';
}
Elseif (the curve head of G1 and the curve cabrage of G2 are closed)
{
// G1 and G2 are joined end to end
G2.Tail.Next=G1.Head;
G2.Head.Prev=G1.Tail;
G1.Tail.Next=G2.Head;
G1.Head.Prev=G2.Tail;
G1.Head=G2.Head;
G′=G2;
G2=G2.Prev;
From the closed outline chained list, delete G ';
}
}
G2=G2.Next;
}
}
G1=G1.Next;
}
(4) boundary rectangle of every secondary Bezier line segment in all closed outlines that obtain in the calculation procedure (3) and all closed outlines, method is the same, repeats no more herein.
The direction of all closed outlines that (5) obtain in the markers step (3) comprises clockwise direction and counter clockwise direction.Clockwise direction is labeled as 1, is labeled as counterclockwise-1.Judge the direction of a closed curve G, only need to take out any secondary Bezier line segment among the G, judge that its direction gets final product.Concrete treatment step is as follows:
1. appoint from closed outline G that to get a secondary Bezier line segment be B, suppose that three control points of B are respectively P[0], P[1], P[2], mid point is Q;
2. determine the direction value d of B: if P[2] .y〉P[0] .y, then d=1; If P[2] .y<P[0] .y, then d=-1; If P[2] .y=P[0] .y, then d=0;
3. calculate the mid point Q of B;
4. judge abs (P[2] .y-P[0] .y) whether greater than abs (P[2] .x-P[0] .x), in this way, then take the Q point as starting point, along continuous straight runs is made a ray H; As no, then vertically make a ray H take the Q point as starting point; Calculate all the secondary Bezier line segments except B that intersect with H in all closed outlines of caption object, suppose to have M bar secondary Bezier line segment and H crossing, be respectively B[0], B[1] to B[M-1];
5. calculate respectively B[i] direction value d[i], the method that method and step are calculated the d value in 1. is identical; Wherein, i=0,1 ..., M-1;
6. calculate d[i] with value d ': d '=d[0]+d[1]+...+d[M-1];
7. calculate the value of the direction attribute b of B, b=d* (1-2*abs (d ')); If b〉0, then closed outline G is clockwise direction, otherwise is counterclockwise.
Method of the present invention is not limited to above-mentioned embodiment, and those skilled in the art's technical scheme according to the present invention draws other execution mode, belongs to equally technological innovation scope of the present invention.

Claims (6)

1. the inside and outside side attribute of a basis carries out the method for merging to the caption object vector outline, may further comprise the steps:
(1) determines the inside and outside side attribute of every secondary Bezier line segment in all closed outlines of caption object;
(2) with attribute be the secondary Bezier line segment deletion of inner edge;
(3) according to the closed outline of intersection point reconstruct caption object;
(4) boundary rectangle of every secondary Bezier line segment in all closed outlines that obtain in the calculation procedure (3) and all closed outlines; The method of the secondary Bezier line segment in the calculating closed outline and the boundary rectangle of closed outline is:
Three control vertexs supposing secondary Bezier line segment are respectively P0, P1 and P2, and the abscissa that P0 is ordered is P0.x, and ordinate is P0.y; The abscissa that P1 is ordered is P1.x, and ordinate is P1.y; The abscissa that P2 is ordered is P2.x, and ordinate is P2.y; The leg-of-mutton boundary rectangle T that calculating is made of P0, P1 and P2, T is the boundary rectangle of this secondary Bezier line segment, and formula is as follows:
T.left=min(P0.x,P1.x,P2.x),
T.right=max(P0.x,P1.x,P2.x),
T.top=min(P0.y,P1.y,P2.y),
T.bottom=max(P0.y,P1.y,P2.y);
Wherein, T.left represents the abscissa of boundary rectangle left frame, and T.right represents the abscissa of boundary rectangle left frame, and T.top represents the ordinate of boundary rectangle upper side frame, and T.bottom represents the ordinate of boundary rectangle lower frame; The min function representation is got the minimum value in all parameters, and the max function representation is got the maximum in all parameters;
The boundary rectangle of secondary Bezier line segments all in the closed outline is merged, just obtain the boundary rectangle of this closed outline;
The direction of all closed outlines that (5) obtain in the markers step (3).
2. the inside and outside side attribute of a kind of basis as claimed in claim 1 carries out the method for merging to the caption object vector outline, it is characterized in that, determine in the step (1) that the method for the inside and outside side attribute of secondary Bezier line segment is: judge that the secondary Bezier line segment meaning of taking up an official post is interior point or exterior point a bit in all closed outlines of caption object; If interior point, the secondary Bezier line segment that then comprises this point is inner edge; If exterior point, the secondary Bezier line segment that then comprises this point is the outside.
3. the inside and outside side attribute of a kind of basis as claimed in claim 2 carries out the method for merging to the caption object vector outline, it is characterized in that: described secondary Bezier line segment is taken up an official post to anticipate and a bit is the mid point of secondary Bezier line segment.
4. the inside and outside side attribute of a kind of basis as claimed in claim 3 carries out the method for merging to the caption object vector outline, it is characterized in that, the mid point of judging secondary Bezier line segment is interior point or the method for exterior point may further comprise the steps in all closed outlines of caption object: suppose that secondary Bezier line segment is B, three control points of B are respectively P[0], P[1], P[2], mid point is Q;
1. determine the direction value d of B: if P[2] .y〉P[0] .y, then d=1; If P[2] .y<P[0] .y, then d=-1; If P[2] .y=P[0] .y, then d=0; Described P[0] .y and P[2] .y represents respectively P[0] and P[2] ordinate;
2. calculate the mid point Q of B;
3. judge abs (P[2] .y-P[0] .y) whether greater than abs (P[2] .x-P[0] .x), in this way, then take the Q point as starting point, along continuous straight runs is made a ray H; As no, then vertically make a ray H take the Q point as starting point; Calculate all the secondary Bezier line segments except B that intersect with H in all closed outlines of caption object, suppose to have M bar secondary Bezier line segment and H crossing, be respectively B[0], B[1] to B[M-1]; Described P[0] .x and P[2] .x represents respectively P[0] and P[2] abscissa, described abs function is the function that takes absolute value;
4. calculate respectively B[i] direction value d[i], the method that method and step are calculated the d value in 1. is identical; Described i=0,1 ..., M-1;
5. calculate d[i] with value d ': d '=d[0]+d[1]+... + d[M-1];
6. calculate the inside and outside side attribute value a of B according to d and d '; If a=0, then B is inner edge; If a=1, then B is the outside;
Described a=1-abs (SIGN (d+d ') * SIGN (d ')), described SIGN (x) is defined as (x==0) 0:((x〉0) 1:-1)).
5. the inside and outside side attribute of a kind of basis as claimed in claim 4 carries out the method for merging to the caption object vector outline, it is characterized in that: in the step (1), behind the inside and outside side attribute of secondary Bezier line segment in having determined a closed outline, then the inside and outside side attribute of the secondary Bezier line segment after this secondary Bezier line segment of this closed outline is identical with it, until run into an intersection point.
6. the inside and outside side attribute of a kind of basis as claimed in claim 4 carries out the method for merging to the caption object vector outline, it is characterized in that, direction described in the step (5) comprises clockwise direction and counter clockwise direction, and clockwise direction is labeled as 1, counterclockwise is labeled as-1; The method of mark closed outline direction is: at first take out any secondary Bezier line segment B from closed outline, calculate the value of the direction attribute b of closed outline, b=d* (1-2*abs (d ')); If b〉0, then this closed curve is clockwise direction, otherwise is counterclockwise.
CN 200810225866 2008-11-04 2008-11-04 Method for merging and classifying subtitle object vector outline according to inner and outer side attribute Expired - Fee Related CN101764944B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 200810225866 CN101764944B (en) 2008-11-04 2008-11-04 Method for merging and classifying subtitle object vector outline according to inner and outer side attribute

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 200810225866 CN101764944B (en) 2008-11-04 2008-11-04 Method for merging and classifying subtitle object vector outline according to inner and outer side attribute

Publications (2)

Publication Number Publication Date
CN101764944A CN101764944A (en) 2010-06-30
CN101764944B true CN101764944B (en) 2013-03-06

Family

ID=42495916

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 200810225866 Expired - Fee Related CN101764944B (en) 2008-11-04 2008-11-04 Method for merging and classifying subtitle object vector outline according to inner and outer side attribute

Country Status (1)

Country Link
CN (1) CN101764944B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102724417B (en) * 2011-05-09 2015-05-27 新奥特(北京)视频技术有限公司 Method and system for realizing caption special effect in louver mode
CN104732515B (en) * 2014-12-22 2018-01-23 深圳市百能信息技术有限公司 A kind of method and apparatus of line and curve connection body extraction outline

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6448968B1 (en) * 1999-01-29 2002-09-10 Mitsubishi Electric Research Laboratories, Inc. Method for rendering graphical objects represented as surface elements
CN1564201A (en) * 2004-04-13 2005-01-12 复旦大学 Three-D texture chartlet method based on master drawing covering and separating

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6448968B1 (en) * 1999-01-29 2002-09-10 Mitsubishi Electric Research Laboratories, Inc. Method for rendering graphical objects represented as surface elements
CN1564201A (en) * 2004-04-13 2005-01-12 复旦大学 Three-D texture chartlet method based on master drawing covering and separating

Also Published As

Publication number Publication date
CN101764944A (en) 2010-06-30

Similar Documents

Publication Publication Date Title
CN101465973B (en) Method for rendering subtitling based on curved profile closed loop domain and pixel mask matrix
CN101764945B (en) Subtitle dramatizing method based on closed outline of Bezier
CN101764943B (en) Method for dividing quadratic Bezier curve in subtitle object vector outline by intersection points
CN101415079B (en) Method for transforming subtitling object into Bessel curve
CN101764946B (en) Method for discretization of vector outline of subtitle object into straight-line segment
US6504537B1 (en) System, method and article of manufacture for fractional tessellation during graphics processing
Eck Introduction to Computer Graphics
CN101764944B (en) Method for merging and classifying subtitle object vector outline according to inner and outer side attribute
CN101764948B (en) Segmenting method of self-intersection closed outline in caption object vector outline
CN101764947B (en) Method for bordering inner edge and outer edge to polygon of vector outline of subtitle object
CN101764940B (en) Subtitle rendering method based on pixel space mask matrix model
CN101764939B (en) Texture mapping method based on pixel space mask matrix
US9064340B2 (en) Drawing apparatus, drawing method, and drawing program
CN101764941B (en) Method for defining pixel type of pixel space mask matrix
CN101764938B (en) Edge anti-aliasing processing method based on contour line distance of adjacent four pixels
US9779528B2 (en) Text realization
CN103198496B (en) A kind of method of abstracted image being carried out to vector quantization
Yeh et al. Double-sided 2.5 D graphics
CN111666739A (en) Chinese vector word stock generation method based on Potrace algorithm
CN101764935B (en) Form gradient radial color filling method based on pixel space mask matrix
CN101764937B (en) Method for confirming distance of pixel space mask code matrix from pixel to outermost side
CN110570504B (en) Closed symbol drawing method and device, electronic equipment and storage medium
CN101764942B (en) Method for defining pixel area of pixel space mask matrix
Hussain et al. Intelligent digitisation of Arabic characters
KR100679289B1 (en) System of processing image for vector pixel

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
ASS Succession or assignment of patent right

Owner name: BEIJING CULTURAL AND SCIENTIFIC FINANCING LEASE CO

Free format text: FORMER OWNER: XIN'AOTE(BEIJING) VIDEO TECHNOLOGY CO., LTD.

Effective date: 20150414

C41 Transfer of patent application or patent right or utility model
COR Change of bibliographic data

Free format text: CORRECT: ADDRESS; FROM: 100080 HAIDIAN, BEIJING TO: 100044 SHUNYI, BEIJING

TR01 Transfer of patent right

Effective date of registration: 20150414

Address after: 100044, room 2, building 1, No. 401, Golden Sail Road, Beijing, Shunyi District

Patentee after: Beijing culture science and technology finance leasing Limited by Share Ltd

Address before: 100080 Beijing city Haidian District xicaochang No. 1 Beijing Silicon Valley computer city 15 1501-1506 room

Patentee before: China Digital Video (Beijing) Limited

CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20130306

Termination date: 20161104

CF01 Termination of patent right due to non-payment of annual fee