« PreviousContinue »
METHOD AND APPARATUS FOR
ANTIALIASING BY GAMMA CORRECTED
FIELD OF THE INVENTION
The invention relates generally to display of video data in a computer system. More particularly, the invention relates to antialiasing of lines and/or points in a graphics display by gamma correction based on pixel area calculation.
BACKGROUND OF THE INVENTION
Graphical images are represented in typical computer systems by individual points on a computer monitor known as pixels. There are typically thousands or several million pixels in a single computer display that are individually manipulated to form the two-dimensional and threedimensional images which a user sees on the computer screen.
Each pixel is displayed at a specified intensity, with the intensity of each color component (e.g., red, green, and blue) pixel in a color system separately specified in accordance with the color model for the system. In monochrome systems, the pixel intensity is determined from the gray scale value of the pixel. In a typical computer graphics system, video driver circuitry specifies a voltage for each pixel displayed (or color component pixel in the case of RGB color systems). However, there is not a direct linear mapping between driver voltage levels and pixel intensity. Monitor response is nonlinear and a power law gamma correction curve describes the parametric relationship between the applied voltage (to the electron-gun or pixel driver) and the displayed pixel intensity. The calculation by which the applied voltage needed to display a particular intensity is determined is known as gamma correction of intensity. The precise value of the gamma parameter is monitor dependent and typically varies from 2.0 to 3.0, although the National Television System Committee (NTSC) has defined a signal standard value of 2.2. The shape of the correction curve depends, in part, on the gamma parameter value.
In typical computer graphics systems, the driver voltages associated with predetermined pixel intensity values are stored in lookup tables, the number of entries in the lookup table ideally equaling the possible number of pixel intensity values. In order to determine the voltage output level required to achieve a desired pixel (or sub-pixel) intensity, the table entry corresponding to that intensity level is looked up and the value therein applied to the driver circuitry.
In a computer graphics system, a line segment (which may be, but is not necessarily, a polygon boundary) has both length and width. Each line segment is bounded by two edges, the distance between the edges being the width of the line segment, and each edge is bounded by two endpoints, one at either end of each line segment edge. Similarly, although pixels are often thought of as points, each pixel has finite boundaries and a defined area. In a typical computer system with square pixels, the pixel boundaries are the top, bottom, and sides of the pixel and the area is equal to the height times the width (i.e., length of a side boundary times the length of a top or bottom boundary). If the pixel dimensions are normalized, then each pixel boundary has a length of one and the magnitude of the area of each pixel is advantageously one.
Because the pixels in a computer graphics system are arranged in a rectangular grid, and are typically rectangular, purely vertical and horizontal lines (or line segments) and
boundaries are generally displayed relatively precisely and with little distortion. However, lines that are not oriented at right angles are not neatly mapped onto adjacent pixels and undesirable distortions and artifacts can occur because of the
5 imperfect mapping between diagonal lines and/or boundaries and pixels forming the display. Moreover, the edges of lines and/or polygons often do not map to precisely defined locations on the pixel boundaries, such as when the edge is not parallel to a horizontal or vertical axis, which may
10 further distort the displayed image.
In particular, a form of distortion colloquially referred to as "j aggies" may occur because of the stair-stepping effect which can be seen when a diagonal line is represented by a series of diagonally adjacent pixels. This stair-stepping
15 effect can be ameliorated by effectively blurring the pixels at the edge of a line.
Numerous techniques are known in the art for "blurring" the pixels, such as varying the intensity of certain pixels based on, for example, the percentage of pixel area covered
20 by the line. However, many of the prior art techniques tend to be computationally complex, using complex filters and/or supersampling of pixels. Other prior art techniques reduced the need for extensive computations by using table look ups for antialiasing, at the cost of limiting adaptability (if the
25 table entries were fixed) and necessarily requiring the implementation of unwieldy tables. Moreover, many of the prior art techniques are not readily scalable for wide lines of varying width as the computations quickly become impracticable given the performance constraints typically imposed.
Furthermore, lengthy tables can undesirably constrain the flexibility of a graphics system as table entries are typically predetermined and not readily modified, making it difficult for the graphics system to efficiently support multiple monitors and/or types of monitors that are unlikely to have identical operating characteristics.
SUMMARY OF THE INVENTION
In view of the foregoing, there is a need for a technique for antialiasing that is computationally efficient, does not require extensive tables, and is readily scalable.
The present invention provides an improved technique for antialiasing by gamma correction of pixel intensity of covered pixels wherein the pre-gamma corrected intensity is
45 relative to the amount of the pixel covered by a line as determined from the intersections of the edges of a line and pixel boundaries. By applying gamma correction to a single pixel by linear interpolation on a cubic representation of a normalized gamma correction curve, the present invention
50 does not require a lengthy lookup table. Moreover, the present invention is readily adaptable for operation with a variety of displays with differing gamma correction characteristics.
In an alternative embodiment of the present invention, 55 line antialiasing is further enhanced by alpha-blending the line pixel with the background. In a second alternative embodiment of the present invention, the endpoints of antialiased line segments are evaluated appropriately by accurately assessing the amount of pixel area covered and go varying the pixel intensity accordingly.
BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1A is an illustration of a diagonal line segment. FIG. IB is an illustration of a pixel representation of a 65 diagonal line segment.
FIG. 1C is an illustration of a pixel representation of a wide line segment.
FIG. 2 is an illustration of a line segment partially covering a plurality of pixels and triangles used to identify the point of interception between an edge of the line segment and a pixel boundary.
FIG. 3 is a flowchart representation of a method of 5 antialiasing in accordance with an embodiment of the present invention.
FIG. 4 is a block diagram representation of a partial rasterizing engine illustrating elements used for antialiasing in accordance with an embodiment of the present invention. 10
FIG. 5 is an illustration of a line segment and a quad of pixels.
FIG. 6 is a block diagram of a line gamma correction block in a rasterizing engine in accordance with an embodi- ^ ment of the present invention.
A novel method and apparatus for line antialiasing by gamma-corrected area calculation in a computer graphics 20 system is described herein. Line antialiasing is desirable in a raster-scan computer graphics system where objects and lines are represented by a set of discrete points on horizontal scan lines on the screen. Referring to FIG. 1A, a diagonal line 1 that is not pixelated is shown. Unlike a representation 25 of the diagonal line on a computer display, the edges of the line are smooth and continuous, without any abrupt vertical or horizontal steps. Referring to FIG. IB, a 45° line on a pixelated display is shown. In contrast to the line of FIG. 1A, the line is represented by a series of rectangular non- 30 adj acent pixels 2-8. The two edges of the line are not smooth diagonal surfaces, rather they are formed by a series of horizontal and vertical pixel boundaries, creating an undesirable staircase effect. Referring to FIG. 1C, the staircase effect is shown on a relatively wide line 9 at an angle of 35 approximately 30°. In a line that is more than one pixel wide, the pixels that are bounded by edge pixels and are inside the line are not antialiased.
In the present invention, antialiasing is accomplished by varying the pixel intensity in relation to the amount of pixel area covered by the line segment. Although calculating the area of pixel coverage typically requires extensive computations, the present invention provides an improved technique by which the pixel coverage area may be computed using arithmetic, cross products and limited division.
Because of the non-linearity of the gamma correction curve and the logarithmic nature of human perception of intensity, incrementally changing the pixel intensity cannot be accurately achieved by direct linear mapping of a change 50 in pixel intensity to the change in driver voltage (e.g., reducing the driver voltage by 30% will not necessarily reduce associated pixel (or sub-pixel) intensity by 30%). Therefore, it is necessary to evaluate the gamma correction curve at the desired pixel intensity to determine the output 55 level needed to achieve the desired intensity. In the present invention, the gamma correction curve is characterized as a cubic spline and the desired output level is determined by linear interpolation applying the de Casteljau algorithm, eliminating the need for extensive storage and/or transfer of g0 gamma correction curve tables.
In an embodiment of the present invention, the pixel color attributable to the antialiased line segment is alpha blended with the background color where the degree of alpha blending is proportional to area of pixel coverage. 65
Referring to FIG. 2, a line segment with a first edge 10 and a second edge 20 is shown crossing a plurality of pixels 30,
including pixel 40. Pixel 40 has four corners 41, 42, 43 and 44; and four boundaries corresponding to the sides of pixel 40 connecting the four corners (i.e., the four line segments from 41 to 42, from 42 to 44, from 41 to 43, and from 43 to 44).
In accordance with the present invention, each pixel intersected by an edge of the line segment is antialiased by changing the pixel intensity by an amount proportional to the area of the pixel covered by the line segment. Determination of the area of pixel coverage is a multiple step process which may be advantageously performed using line equations generated to draw the line segment and accordingly do not need to be computed separately solely for determination of pixel coverage.
The area of the pixel covered by a line segment may be readily determined from the intersection points of the line segment edges and the pixel boundaries. These intersection points may, in turn, be advantageously determined from the triangles formed between the edges and each of the four pixel corners. Referring to FIG. 2, the edge 10 intersects a vertical boundary of pixel 40 at point 45. All the corners of pixel 40 are known, including the lower left corner 41 and upper left corner 42.
Referring to FIG. 3, the edge end points, which are needed for the line equations defining the line segment edges irrespective of antialiasing, are made available to the antialiasing subsystem or algorithm as shown by input/output block 110. Referring again to FIG. 2, the end points 11 and 12 of line segment edge 10 are therefore known. As the area of a triangle formed by three known points can be readily determined using basic geometry, the areas of the eight triangles formed by the end points of the line segment edges 10 and 20 and the four corners of pixel 40 are readily calculated using addition, subtraction, multiplication and binary division.
Referring again to FIG. 2, triangle 50 is formed by the end points 11 and 12 and pixel corner 41. In a similar manner, triangle 60 is formed by the endpoints 11 and 12 and pixel corner 42. The location of the edge intercept 45 on the pixel boundary between pixel corners 41 and 42 is determined from the ratio of the triangle areas. This process is simultaneously or sequentially performed for each edge and each pixel boundary as indicated by processing block 120 of FIG. 3.
The three vertices of the triangle and the triangle ratio are also used to determine whether an edge intersects a pixel boundary and, if so, which of the pixel corners are inside the line segment (or polygon) of which the edge is a part. When the area of a triangle is determined from the three vertices using analytic geometry, the result is signed, as shown by equation 1 below