This application is based upon and claims the benefit of priority from the prior Indian Patent Application No. 2494/CHE/2007, filed Nov. 2, 2007, the entire contents of which are incorporated herein by reference.
1. Field of the Invention
The present invention relates to the field of vector graphics. More particularly, the invention relates to the field of Bezier curves and other curves.
2. Discussion of the Related Art
In low memory embedded graphics system implementations, a Bezier curve is rendered or processed as consecutive lines between discrete samples on the curve. The quality of the curve being rendered is directly related to the number of samples taken into consideration. However, a large number of samples for most curves are redundant and also consume a large amount of CPU cycles. The method described herein attempts to solve this problem by introducing the concept of visual significance and deciding the number of samples in a curve based on its visual significance. In one embodiment, visual significance is determined using the curvature of a curve and the area of the curve.
Prior art in this field has dealt with an adaptive approach of sampling Bezier curves. Such approaches (adaptive subdivision algorithms) give very good results. However in a case of low memory & low computation power embedded systems, these approaches are not recommended because of their recursive nature. (Recursive nature of adaptive subdivision introduces the risk of stack overflow in embedded systems). Also, for graphics operations like filling, it is imperative that these samples are stored. To store these samples allocation of memory is necessary.
If an adaptive approach is used, dynamic allocation of memory for every point generated will be necessary. This is not recommended since it would be a very slow process. Thus, memory should be allocated before calculation of curve points, and for this the number of points required for a curve should be known. Thus, number of samples should be predicted and then memory should be allocated.
Prior art in this field has not considered the visual significance of a curve. A curve which is large and occupies more of a display region is visually more significant as compared to a curve which is small. Thus, a curve which is visually more significant will be sampled in more detail. Also, color of the curve would contribute to its visual significance. Previous art in this area has not considered this approach objectively.
The current invention makes use of visual significance to reduce the CPU & memory usage depending on the visual significance of a curve. As this approach avoids use of recursive methods to sample the curve, it significantly reduces the usage of stack which is critical in low memory systems.
To find the number of samples by which a curve can be accurately described in terms of lines between these samples is a problem. The fact that for a curve to be smooth and accurate, more samples taken at the curvature should be taken into consideration. Thus, the sampling rate along the curve should be variable. On the other hand, this would be a computationally complex affair. Also, such a method would demand a large memory for which the calculation of an upper limit would be difficult. Samples are to be stored for processing in a case of operations such as filling. Thus, it is necessary to know the number of samples in a curve before calculation of the curve samples. Thus, algorithms, like adaptive subdivision, which use continuous subdivision to generate points on the curve, are not suitable algorithms since the number of points generated by these algorithms for a curve is not predictable and dynamic memory allocation would be required for every sample generated. Also, such algorithms are recursive. Recursive algorithms are not recommended for embedded systems because of stack constraints.
An object of this invention is to utilize the visual significance of a curve in deciding the number of samples by which a curve can be satisfactorily described in terms of lines between these samples.
Another object of this invention is to utilize the visual significance of a curve in deciding amount of memory & CPU cycles to spend on generating the points on a curve or for filling a curve.
According to one aspect of the invention, a method is provided to determine a number of samples used in rendering a Bezier curve, defined by first, second, third and fourth sequential Bezier control points. The method includes determining a visual significance of a curve by measuring a characteristic of the curve, determining a curvature estimation factor of the curve based on a length of the curve and a distance between first and last control points of the curve, and determining the number of samples for a predetermined accuracy depending on the visual significance of the curve and the curvature estimation factor.
According to another aspect of the invention, a system is provided to determine the number of samples used in rendering a Bezier curve, defined by first, second, third and fourth sequential Bezier control points. The system includes a host processor, an embedded memory, a graphics processor unit (GPU), and a PCI bus. The GPU includes a graphics controller and an application programming interface (API). The graphics controller is configured to determine a visual significance of a curve by measuring a characteristic of the curve, a curvature estimation factor of the curve based on a length of the curve and a distance between first and last control points of the curve, and a number of samples for a predetermined accuracy depending on the visual significance of the curve and the curvature estimation factor.
According to another aspect of the invention, a computer readable storage medium is provided which is encoded with computer executable instructions, which when executed by a computer, cause the computer to perform a method to determine a number of samples used in rendering a Bezier curve, defined by first, second, third and fourth sequential Bezier control points. The method includes determining a visual significance of a curve by measuring a characteristic of the curve, determining a curvature estimation factor of the curve based on a length of the curve and a distance between first and last control points of the curve, and determining the number of samples for a predetermined accuracy depending on the visual significance of the curve and the curvature estimation factor.
According to another aspect of the invention, a method, system, and computer readable storage medium are provided, where the determining the visual significance of the curve includes determining a bounding box defined by the four control points defining the Bezier curve, and calculating an area of the bounding box as the visual significance.
According to another aspect of the invention, a method, system, and computer readable storage medium are provided, where the determining the visual significance of the curve includes calculating a perimeter of the curve (L) as the sum of distances given by: a distance between a start point and the first control point, a distance between the first control point and the second control point, and a distance between the second control point and an end point; and using the perimeter of the curve as the visual significance.
According to another aspect of the invention, a method, system, and computer readable storage medium are provided, where the determining the visual significance of the curve includes determining a background color, determining a color of the curve, comparing the background color with the color of the curve, and determining the number of samples depending on a color contrast between the curve and the background.
According to another aspect of the invention, a method, system, and computer readable storage medium are provided, where the determining the curvature estimation factor of the curve includes calculating the perimeter of the curve (L) as the sum of the distances given by: a distance between the first control point and the second control point, a distance between the second control point and the third control point, and a distance between the third control point and the fourth control point; calculating a distance (r) between a start point and an end point; and calculating the curvature estimation factor f by using f=(L−r)/L.
According to another aspect of the invention, a method, system, and computer readable storage medium are provided, where the determining the curvature estimation factor of the curve includes calculating perimeter of the curve (L) as a sum of distances given by: a distance between the first control point and the second control point, a distance between the second control point and the third control point, and a distance between the third control point and the fourth control point; calculating a distance (r) between a start point and an end point; calculating an intermediate curvature estimation factor e by using e=(L−r)/L; and calculating the curvature estimation factor f depending on a tolerance t as f={x: x is the greater of e and t}.
According to another aspect of the invention, a method, system, and computer readable storage medium are provided, where the determining the curvature estimation factor includes setting the curvature estimation factor to a fixed value which depends on the predetermined accuracy.
According to another aspect of the invention, a method, system, and computer readable storage medium are provided, where the determining the number of samples includes, determining a maximum number of samples based on the visual significance depending on the predetermined accuracy; and determining the number of samples is determined by multiplying the maximum number of sample points by the curvature estimation factor.
According to another aspect of the invention, a method, system, and computer readable storage medium are provided, wherein the determining the number of samples includes using a predetermined mapping of visual significance ranges to a number of sample points.
Further objects, features and advantages will become apparent from the following description, claims and drawings.
A more complete appreciation of the invention and many of the attendant advantages thereof will be readily obtained as the same becomes better understood by reference to the following detailed description when considered in connection with the accompanying drawings, wherein:
Bezier curves have a special significance with respect to vector graphics applications. Bezier curves of order two and three, i.e. quadratic and cubic Bezier curves, are generally used as basic units in these applications. Higher order curves can be represented as a combination of cubic and quadratic curves. Thus, here cubic Bezier curves are considered. However, the method described here is applicable to all types of curves or geometric equations such as an ellipse, circle, arcs etc., for which calculation of length or bounding box area is possible.
Referring to
A cubic Bezier curve can be described completely using four Bezier control points as shown in
Bezier curves can be described by parametric equations. The parametric equation for a cubic Bezier curve will be as follows:
x(t)=x0*(1−t)3+x1*(1−t)2*t+x2*(1−t)*t2+x3*t3
y(t)=y0*(1−t)3+y1*(1−t)2*t+y2*(1−t)*t2+y3*t3
where t varies from 0 to 1. The number of discrete sample points on the curve will be the number of steps in which t changes from 0 to 1.
The method of generating a curve based on the above equation is described in the flowchart given in
The curve defined by
The concept of visual significance can be correlated to the concept of frequency filtering in case of image processing. In image processing, for data compression, very high frequencies are filtered out since they have a small or negligible effect on the quality of the image with respect to the human eye. Similarly variations in cases of small curves on a display would represent very high frequencies. Thus, the smaller the curve, the more visually insignificant are the variations in the curve. Also it is difficult for the human eye to pinpoint variations in a small curve as compared to variations in a larger curve. This leads us to a conclusion that smaller curves can have a lesser number of samples as compared to a larger curve.
The color of a curve relative to its background would also contribute to its visual significance. A curve having more variation in color with respect to its background will be more visually significant. If the background has got dull color and the Bezier curve has prominent color, the number of samples has to be large. In the reverse situation, where the background has got prominent color and the curve has got dull color, then the number of samples can be reduced accordingly.
On these basic assumptions, a larger curve which is visually more significant can be sampled in more detail as compared to a smaller curve. Existing methods for rendering Bezier curves use the same number of samples without considering the visual significance of a curve. This invention gives a method for using the visual significance defined by the size of the curve and its color, in combination with the curvature of the curve to determine the number of samples required for a given Bezier curve.
f=(L−r)/L.
Here, f gives a good estimation of the curvature of the curve. The greater the value of f, the greater the curvature of the curve. For values of f lower than 0.5, the curve is more linear. The flattest curve is a straight line, and for a straight line, the curve estimation factor would be very close to zero. It is checked if f<0.5 (805). If f<0.5, then f is assigned a value of 0.5 (806). For a value of f≧0.5, the approximate area of the bounding box defined by the points P0, P1, P2 and P3 are denoted by “v” (807). Depending on the application and the quality required by the user, the maximum number of samples for a range of areas can be set. To set the maximum number of samples required for a particular area, the display area is divided into various ranges of areas. For example, the ranges might be from 0-32, 33-256, 257-1024, 1025-4096, 4097-32768 and so on as shown in Table 1 below. Then, the maximum number of samples that should be taken for a particular range of areas is decided.
This is a trial and error process and is similar to tuning a system to suit a certain specific purpose. Generally, the curves belonging to a higher range of v, i.e., curves having higher visual significance will have more samples. Using the calculated value of v, the maximum number of samples (max) is obtained (808). The number of samples required for the curve can be obtained by multiplying the maximum number of samples (max) with the curvature estimation factor (f) (809).
Experiments were conducted to verify the method mentioned above. A set of 50 cubic Bezier curves drawn with black color on a white background were taken for these experiments. Each curve was initially plotted with 256 points to get a good view of the shape of the curve. Then the minimum number of samples required to represent the shape of the curve was found. This number would be a relative value varying from person to person. However, approximately the value would be the same. This number was compared with the number of samples generated by the above method. The data shown in
Here, f gives a good estimation of the curvature of the curve. The greater the value of f, the greater the curvature of the curve. For values of f lower than 0.5, the curve is more linear. The flattest curve is a straight line, and for a straight line, the curve estimation factor would be very close to zero. It is checked if f<0.5 (905). If f<0.5, then f is assigned a value of 0.5 (906). For a value of f≧0.5, the visual significance (v) is assigned to L, the perimeter of the curve (907). Depending on the application and the quality required by the user, the maximum number of samples for a range of perimeter values can be set. To set the maximum number of samples required for a particular perimeter value, the display area is divided into various ranges of perimeter values. For example, the ranges might be from 0-32, 33-256, 257-1024, 1025-4096, 4097-32768 and so on as shown in Table 2. Then, the maximum number of samples that should be taken for a particular range of perimeter values is decided.
This is a trial and error process and is similar to tuning a system to suit a certain specific purpose. Generally, the curves belonging to a higher range of v, i.e., curves having higher visual significance, will have more samples. Using the calculated value of v, the maximum number of samples (max) is obtained (908). The number of samples required for the curve can be obtained by multiplying the maximum number of samples (max) with the curvature estimation factor (f) (909).
In a second embodiment of the invention, the method considers the deviation error in calculating the number of samples required for defining the curve. The number of samples required or the step size for sampling is directly related to the deviation error present in the curve. By setting the maximum number of samples, the deviation error tolerable for a curve is set. The proposed method is also applicable to implementations which use deviation as a criterion for determining the step size. In such implementations, the concept of visual significance can be used to calculate the deviation. For curves with higher visual significance, the deviation is small as compared to the deviation for curves with lower visual significance.
For selecting the step size, a constant value of deviation is decided upon by experimentation, keeping in mind the desired quality. The relationship between the deviation and the step size is as follows:
e=h*h*|v×a|/(8*|v|)
where,
A constant value of deviation (decided by experimentation to obtain the required quality) and the velocity and acceleration vectors of the curve are used to select the step size.
The above invention has applications in low memory devices like cellular phones, PDAs, DVD players, car navigation systems etc.
A device according to an embodiment of the present invention may also include at least one computer readable medium or memory for holding instructions programmed according to the teachings of the invention and for containing data structures, tables, records, or other data described herein. Examples of computer readable media suitable for the present invention are compact discs, hard disks, floppy disks, tape, magneto-optical disks, PROMs (EPROM, EEPROM, flash EPROM), DRAM, SRAM, SDRAM, or any other magnetic medium, compact discs (e.g., CD-ROM), or any other optical medium, punch cards, paper tape, or other physical medium with patterns of holes, a carrier wave (described below), or any other medium from which a computer can read.
Such computer readable media further includes a computer program product of the present invention for performing the inventive method herein disclosed. The computer code devices of the present invention can be any interpreted or executable code mechanism, including but not limited to, scripts, interpreters, dynamic link libraries, Java classes, and complete executable programs.
Although the present invention has been described with particular reference to specific examples, variations and modifications of the present invention can be effected within the spirit and scope of the following claims.
Number | Date | Country | Kind |
---|---|---|---|
2494/CHE/2007 | Nov 2007 | IN | national |