The Aliasing Problem in Computer-Generated Shaded Images
The Aliasing Problem in Computer-Generated Shaded Images
The Aliasing Problem in Computer-Generated Shaded Images
Shaded computer-synthesized images of opaque objects with only visible surfaces displayed have become relatively common in recent years. The primary commercial use of such images has been visual simulators, which require the most realistic possible image obtainable at real-time rates. To create realistic images, relatively complicated scenes must be depicted, and defects due to the quantization necessary for computer generation must be minimized. A close look at virtually any shaded synthetic image reveals that major problems exist in the rendition of detail (Figures 1 and 4). These problems characteristically occur in three specific situations: (1) along edges on the silhouette of an object or a crease in a surface, (2) in very small objects, and (3) in areas of complicated detail. The most obvious problems occur on object silhouettes, where edges often have an annoyingly jagged appearance. If computer-synthesized images are to achieve a greater degree of realism, it will be necessary to generate images of arbitrarily complicated scenes which contain many potentially jagged edges, small objects, and details. Small objects pose a problem because they can disappear between the dots. This occurs because each dot in the image represents a sample point in the scene, an infinitely small spot on some surface being depicted. If an object is small enough it is possible that no part of it will coincide with a sample point. Therefore a very small object may disappear entirely; a long thin object may appear in some places and not in others, giving the appearance of a string of beads; and a highly detailed object such as a human face may lose some of its features. In animated sequences of images these problems become very obvious. Armies of ants appear to run along edges as their slopes change; small objects and details flash on and off distractingly; slightly larger objects appear to change shape and size without reason; even a simple horizontal edge which looks fine in a still picture can be seen to jump from one raster line to another as it moves vertically in the display. There are essentially three techniques for improving the rendition of detail. The first is to increase the resolution, causing sample points to occur more frequently. This allows representation of finer details and
Fig. 1. Jagged edges can be attenuated by convolutional filtering. The horizontal resolution in this image is approximately 128 samples. Copyright 1977, Association for Computing Machinery, Inc. General permission to republish, but not for profit, all or part of this material is granted provided that ACM's copyright notice is given and that reference is made to the publication, to its date of issue, and to the fact that reprinting privileges were granted by permission of the Association for Computing Machinery. The work reported in this paper took place at the University of Utah and was supported in part by the Advanced Research Projects Agency of the Department of Defense under Contracts DAHC1573-C-0363 and F30602-80-C-0300. Author's address: Department of Computer Sciences, Painter Hall 3.28, The University of Texas at Austin, Austin, TX 78712. 799 Communications of the ACM November 1977 Volume 20 Number 11
J. Foley Editor
Certain defects, such as jagged edges and disappearing detail, have long been an annoyance in digitally generated shaded images. Although increasing the resolution or defocusing the display can attenuate them, an understanding of these defects leads to more effective methods. This paper explains the observed defects in terms of the aliasing phenomenon inherent in sampled signals and discusses prerdtering as a recognized cure. A method for evaluating filters is presented, the application of prefiltering to hidden-surface algorithms is discussed, and an implementation of a filtering tiler is shown accompanied by examples of its effectiveness. Key Words and Phrases: aliasing, computer graphics, convolutional faltering, hidden-surface removal, sampling CR Categories: 8.2
diminishes the obtrusion of jagged edges. However, it is impractical to increase the resolution sufficiently to accommodate small, bright objects owing to the increased cost of image production. The expense of the most commonly used hidden-surface algorithms is proportional to the resolution, and the number of dots which must be produced grows as the square of the resolution. The second technique is to process the output image by blurring it or applying contour-smoothing algorithms such as those suggested by Freeman [3]. Although this approach can lessen the impact of jagged edges, it can do nothing to restore objects or details which have been lost. Furthermore, the image loses sharpness which may be retained by other methods. The third and most attractive technique is to make each sample point represent a finite area in the scene rather than an infinitesimal spot. Thus a very small object would occupy a part of such a small area, causing the intensity of the corresponding dot in the output image to be computed as a weighted average of the colors of the small object and its local background. This approach corresponds closely to what actually takes place in television and screen printing processes [5, 10]. While the first two techniques offer somewhat ad hoc approaches to improving rendition of detail, it will be seen that the third technique is based on sound principles. Making each sample represent a finite area has the effect of applying a convolutional filter before the scene is sampled. It is well known that a signal may be faithfully reproduced from digital samples only if the highest frequency in the signal does not exceed onehalf the sampling frequency [7]. Convolutional filtering may be used to satisfy this condition closely enough to greatly improve the output image. The consequence of failing to filter the signal properly before sampling is known as "aliasing." Aliasing occurs when a lower frequency signal appears as an "alias" of a high frequency signal after sampling (Figure 2). Therefore highly periodic images of scenes involving, for example, picket fences or venetian blinds may appear, when sampled, to be made up of a few broad strips rather than many fine lines. Reproducing the signal involves representing each sample in such a way that the reproduced signal has no frequencies higher than the original signal. This can be
accomplished by representing each sample as a rectangular pulse and then low-pass filtering the resulting signal. In the two-dimensional case, the result of failing to filter the signal properly during reconstruction is known as "rastering." Rastering is an artifact of the structure of the displayed image. If the beam in a television monitor is incorrectly focused, the resulting effects are due to rastering.
Fig. 2. Aliasing. x ' s represent a sampling rate of 10 samples per unit on 12 cycle and 2 cycle signals. Samples are the same in both cases.
G(i,j)= ~
F(k,m)H(i-k,j-m).
(1)
k=-o~ m=-oo
H(i, j) = H~(i)H~q).
800
(2)
G(i,j) = ~
F(k,m)Hi(i - k)H~(j - m)
(3)
]~=--w m=--oo
Fig. 3. Test pattern consisting of closely spaced parabolic arcs (moire patterns in this figure and some of those in Figures 5-8 are caused by the half-tone printing process).
where G represents the filtered scene produced by convolving the scene F with the filter H. Furthermore, if the function F is approximated by rectangular blocks, then the function over any such block becomes constant. This greatly simplifies evaluation of the filtered function. The summation can now be rearranged so that the contribution of each rectangular block is independent. The function G then becomes
ql 81
G(i,j) = ~
qn $n
C~Hi(i - k)Hjq
- -
m) + ...
k=p, m=r,
(4)
Fig. 4. Test pattern synthesized at a resolution of 256 samples by using techniques similar to those of conventional hidden-surface algorithms.
+
I~=p n r a = r n
c.ni(i
- k)nj(i
- m)
where [p,, q,] and [r,, s,] represent the bounds of a given rectangular block of intensity C, and n such blocks give the approximation to the filtered scene at
(i,j). To allow Hi and Hj to be considered separately for a given rectangular block, the summation can be rearranged as follows:
qn 8n
~
k=p n m=r n
C.H,(i - k ) H j q - m)
qn $n
= C. ~
k=p n
Hi(i - k) ~
m=r n
Hjq - m).
(5)
The implementation of an algorithm for discrete convolution over the scene description becomes relatively easy as a result of this rearrangement. Note that by making the rectangular blocks arbitrarily small an arbitrarily good approximation to G can be obtained. Implementing the algorithm involves building lookup tables for summations over the functions H~ and Hi. Since H is always of limited nonzero extent, two finite tables can be built, one for Hi and the other for Hj (in practice these have usually been the same). Each table will consist of entries which represent partial sums across the function from the lower nonzero bound to each point below the upper nonzero bound. To obtain the sum over the function between any two nonzero points, it is sufficient to find the difference between the table entries for these two points. With the help of lookup tables, any of the independent summations (see eq. (5)) giving the approximation to G for a given i and ] can be found with four lookups, two subtractions, and two multiplications. To evaluate the filter functions used with the convolution algorithm, a test pattern which emphasizes the defects due to aliasing may be used. A test pattern has been invented which generates moire patterns in response to improperly represented edges and detail. The pattern is produced by generating almost parallel sections of parabolas by using second-order differences (Figure 3). The curvatures of the parabolas
801
decrease linearly from a maximum on the left to zero on the right. In addition, the distance between any two adjacent parabolas decreases linearly from left to right across the pattern, causing jaggedness along edges to be repeated with slight variation from curve to curve. The effects along groups of curves form elliptical patterns which are much easier to detect than jaggedness along a single edge. Furthermore, toward the right side of the pattern where the detail is too fine to be resolved by the display, similar patterns are caused by improper summing of the details represented in a sample (Figure 4). A program has been developed to display the pattern convolved with various filters. An interactive filter design routine allows quick design and modification of a filter. The pattern can then be regenerated in a few minutes to allow visual evaluation. Equipment calibration routines are also included; the test pattern sensitivity is great enough to make consistent calibration an absolute necessity. Figures 5-8 illustrate the effectiveness of various filters. In each figure, the curve at the lower left represents the presampling filter while the upper left curve represents the calibration function. Having developed a method for applying convolutional filters and having found effective filters, we must find methods to restrict filtering to those parts of the image where it is necessary. In other words, the filtering process must be made adaptive.
Communications of the ACM November 1977 Volume 20 Number 11
Fig. 5. Pattern convolved with a filter consisting of nine equally weighted discrete points (equivalent to tripling the resolution),
Fig. 7. Pattern convolved with a roughly triangular filter having a base width of one sample interval.
Fig. 6. Pattern convolved with a filter consisting of 25 unequally weighted discrete points.
Fig. 8. Pattern convolved with a roughly triangular filter having a base width of two sample intervals.
border, there can be two sets of vertices defining the edge which joins the two polygons. Therefore creases and color changes define two different edges over the same position, and this property can be used to isolate such edges. Since the most noticeable jaggedness occurs on the silhouettes of objects, it is clearly necessary to find those edges which lie on the silhouettes. Any edge which lies on the silhouette must join a polygon facing the viewer to one facing away from the viewer. O f course an edge associated with only one polygon may also lie on the silhouette of an object. In this case the edge must be a surface edge as opposed to a silhouette edge. A surface edge occurs wherever the surface halts, for example, at the edge of a sheet of p a p e r or a hole in a surface (Figure 9). To save space, polygons facing away from the viewer (backfacing polygons) are often discarded before the hidden-surface computations are done, in which case silhouette edges b e c o m e surface edges (and therefore belong to only one polygon). Note that this step cannot be taken until all vertex coordinates have been transformed into the perspective space in which the image will be computed. After backfacing polygons have been discarded, creases, color changes, and silhouette edges occur at edges belonging to only One polygon, a characteristic which can be used to find and tag all such edges. Although an exhaustive search could be used to find all the edges associated with a single polygon, a far m o r e attractive alternative is to add an adjacent polygons list to the data for each object, providing a pointer to the adjacent polygon for each polygon edge. Communications of the ACM November 1977 Volume 20 Number 11
802
(i)
- FIRST RIGHT EDGE BLOCK FORMED FROM TOPMOST VERTEX ( 4 ) AND PRECEDING VERTEX ( 3 )
All neighboring polygons are then immediately accessible. With this arrangement, a null pointer immediately indicates an edge associated with a single polygon. Without the adjacent polygons list, tagging edges which are adjacent to polygons facing away from the viewer is a difficult task. With the list, a graph in which all adjacent nodes are bidirectionally linked is provided and tagging silhouette edges by nullifying appropriate adjacent polygon pointers is straightforward. It is then necessary to consider the problem of small objects. It is quite possible to encounter a sharp change in intensity which is not caught by edge tagging. Consider the case of a cube with rounded corners defined by three or four polygons running the length of each edge. When the image of such a cube is large enough that each edge polygon spans several dots in the output image, no problems occur; the rounded edges appear rounded. However, when the cube is viewed from a considerable distance, the total span of the edge polygons may be considerably less than a single dot. In this case, the edge will appear as jagged as it would if the cube were made from the usual six square polygons. Therefore, in addition to tagging edges, it would be wise to tag small or thin polygons. Having developed a method for efficient application of adaptive convolutional filtering, we must now integrate this method into ordinary hidden-surface algorithms. The following discussion outlines this integration with respect to different classes of hiddensurface algorithms.
algorithms, in which the order of generation is immaterial [9]. In order to properly compute the intensity at a sample point, all visible surfaces which lie under nonzero areas of the superposed filter must be taken into account. Of the three classes of hidden-surface algorithms, only the scanning algorithms make all necessary information simultaneously available. Both the depthpriority algorithms and depth-buffer algorithms deliver the necessary information for a given sample at intervals while accumulating the image in a frame buffer, and there is no way of knowing whether two surfaces involved in the same sample lie next to each other or overlap. By using pointers to neighboring polygons, some of these problems can be resolved since neighboring polygons must lie next to each other. This allows creases to be handled correctly. However, where silhouette and surface edges are involved, a correct intensity cannot be guaranteed. If surfaces are rendered in strictly back-to-front order as in some depthpriority algorithms [6], an acceptable edge can be obtained under most conditions. However, the depthbuffer algorithms, which render surfaces in any order, clearly violate this constraint. To be able to calculate the proper intensities where a surface appears behind a previously rendered edge, the intensity of the edge and the extent of its contribution to the sample must be recorded. A more complete discussion of these problems can be found in [2]. It should be noted that where scanning algorithms are used with a frame buffer to achieve greater image complexity by separating foreground and background objects, all the problems of the depth-priority algorithms can be expected. Therefore, if a correct intensity must be guaranteed at every sample point, a singlepass scanning algorithm is required. However, if an occasional error may be accommodated or sufficient memory space and processor time may be devoted to maintaining records on all filtered samples, the framebuffer-based algorithms can be used. In the interests of simplicity, the results obtainable with convolutional filtering are demonstrated by using a filtering tiler (a tiler is a procedure which generates Communications of the ACM November 1977 Volume 20 Number 11
803
the individual dots, or "tiles," from the description of a polygon). The tiler is simple enough to be described in this space yet demonstrates generally applicable techniques for displaying surfaces.
IJ
EDGE BLOCK DONE LEFT VERTEX EDGE BLOCK
12o
~ I G H T EDGE BI.O~ DONE?
NO
~_~
]
CEo M
,GHED,) n
,,@
o E TO
INITIALIZE : - FIND TOP VERTEX - FIDO NEXT LEFT VERTEX - F~DO NEXT RIGHT VERTEX - FIDO BOTTOM VERTEX
i:
1~0
VEETEX )
.t
DOGH
4
17 s
SUBTRACT WEIGHTED AREA FOR HIGHT EDGE FROM CORREsPONDInG DOTS
--IEt~ Q B B U UPoz~rFRJ----
C~
o~ E~GHTDouBQ~E 9
I YES
no
I INC~
Communications of the A C M
Conclusion
J
Left A r e a s Right Areas Area
Fig. 14. Three images each from the filtering tiler (left side), the conventional tiler (middle, top to bottom), and a doubled-resolution tiler (lower right) displayed together.
The intention here has been to provide a discussion of the aliasing problem and to offer a solution based on the theory of sampling and reproduction of twodimensional signals. The examples shown here have been chosen to illustrate aliasing at its worst. Although such cases can sometimes be avoided in still pictures, animated sequences virtually always exhibit obvious defects due to aliasing. It follows that genuinely realistic images will require more than token efforts at resolving the problems discussed above. A general approach to a solution has been offered here. Further ideas and more specific suggestions are offered in [2].
Acknowledgments. This paper has been greatly improved by the helpful comments of the referees. They deserve praise for their careful reading of an earlier version. It should also be noted that the presence of excellent research groups in both computer graphics and signal processing at the University of Utah made this work possible.
Fig. 15. A particularly difficult object, a slender, nearly horizontal triangle, rendered by the conventional tiler (top four), the filter tiler (middle five) and the doubled-resolution tiler (bottom four).
References
The process of filtering the left and right edges proceeds as described earlier. The approximate area lying to the right of each left edge in each intersecting filtered area is weighted and then added to the intensity for the corresponding image dot. Conversely, the areas lying to the right of right-hand edges are subtracted from the intensity for the affected image dots. Note that since the final sum is the weighted area covered by the polygon, very small polygons are treated correctly (Figure 13). Figures 14 and 15 compare the filtering tiler with conventional tilers. A detailed evaluation of the performance of the filtering tiler in comparison with conventional tilers awaits further research. However, observed execution times were two to five times longer for the filtering tiler than for a conventional tiler working at the same resolution. Such figures can be expected to range widely, varying inversely with the size of the polygons displayed and the amount of computing overhead included.
805
1. Bui Tuong Phong. Illumination for computer-generated images. UTEC-CSc-73-129, Dept. Comptr. Sci., U. of Utah, Salt Lake City, Utah, July 1973. Abridged in Comm. ACM 18, 6 (June 1975), 311-317. 2. Crow, F.C. The aliasing problem in computer-synthesized shaded images. UTEC-CSc-76-015, Dept. Comptr. Sci., U. of Utah, Salt Lake City, Utah, March 1976. 3. Freeman, H. Computer processing of line-drawing images. Computing Surveys 6, 1 (March 1974), 57-97. 4. Gouraud, H. Computer display of curved surfaces. UTEC-CSc71-113, Comptr. Sci., U. of Utah, June 1971. Abridged in IEEE Trans. Comptrs. C-20 (June 1971). 5. Hunt, R.W.G., The Reproduction of Colour in Photography, Printing and Television. Fountain Press, England, 3rd Ed., 1975. 6. Newell, M.G., Newell, R.G., and Sancha, T.L. A solution to the hidden-surface problem. Proc. ACM 1972 Annual Conf., Boston, Mass., Vol. I, pp. 443-450. 7. Oppenheim, A.V., and Schafer, R.W. Digital Signal Processing. Prentice-Hall, Englewood Cliffs, N.J., 1975. 8. Stockham, T.G. Jr., High-speed convolution and correlation. Proc. AFIPS 1966 SJCC, Vol. 28, AFIPS Press, Montvale, N.J., pp. 229-233. 9. Sutherland, I.E., Sproull, R.F., and Schumaker, R.G. A characterization of ten hidden-surface algorithms. Computing Surveys 6, 1 (March 1974), 1-55. 10. Zworykin, V.K., and Morton, G.A. Television. Wiley, New York, 2nd Ed., 1954.