All Topics  
Anti-aliasing

 

 

 

 

 

Anti-aliasing


 
 


In digital signal processingDigital signal processing

Digital signal processing is the study of signals in a digital representation and the processing methods of these signals....
, anti-aliasing is the technique of minimizing the distortion artifacts known as aliasingAliasing

In statistics, signal processing, and related disciplines, aliasing is an effect that causes different continuous signals to...
 when representing a high-resolution signal at a lower resolution. Anti-aliasing is used in digital photographyDigital photography

Digital photography, as opposed to film photography, uses electronic devices to record the image as binary data....
, computer graphicsComputer graphics

Computer graphics is the field of visual computing, where one utilizes computers both to generate visual synthetically and...
, digital audioDigital audio

Digital audio comprises audio signals stored in a digital format....
, and many other applications.

In the image domain, aliasing artifacts can appear as wavy lines or bands, moiré patterns, popping, strobing, or as unwanted sparkling. In the sound domain they can appear as rough, dissonant, or spurious tones, or as noise.

Anti-aliasing means removing signal components that have a higher frequencyFrequency

Frequency is the measurement of the number of times that a repeated event occurs per unit of time....
 than is able to be properly resolved by the recording (or sampling) device. This removal is done before (re)sampling at a lower resolution. When sampling is performed without removing this part of the signal, it causes undesirable artifacts such as the black-and-white noise near the top of figure 1-a below.

In signal acquisition and audio, anti-aliasing is often done using an analog anti-aliasing filterAnti-aliasing filter

An anti-aliasing filter is a filter used before a signal sampler, to restrict the bandwidth of a signal to approximately sat...
 to remove the out-of-band component of the input signal prior to sampling with an analog-to-digital converterAnalog-to-digital converter

An analog-to-digital converter is an electronic circuit that converts continuous signals to discrete digital numbers....
. In digital photographyDigital photography

Digital photography, as opposed to film photography, uses electronic devices to record the image as binary data....
, optical anti-aliasing filterAnti-aliasing filter

An anti-aliasing filter is a filter used before a signal sampler, to restrict the bandwidth of a signal to approximately sat...
s are made of birefringent materials, and smooth the signal in the spatial optical domain. The anti-aliasing filter essentially blurs the image slightly in order to reduce resolution to below the limit of the digital sensor (the larger the pixel pitch, the lower the achievable resolution at the sensor level).

See the articles on signal processing and aliasingAliasing

In statistics, signal processing, and related disciplines, aliasing is an effect that causes different continuous signals to...
 for more information about the theoretical justifications for anti-aliasing. The remainder of this article is dedicated to anti-aliasing methods in computer graphicsComputer graphics

Computer graphics is the field of visual computing, where one utilizes computers both to generate visual synthetically and...
.

Examples

(a)
(b)
(c)
 
Figure 1



Figure 1-a illustrates the visual distortion that occurs when anti-aliasing is not used. Notice that near the top of the image, where the checkerboard is very distant, the image is impossible to recognize, and is not aesthetically appealing. By contrast, figure 1-b is anti-aliased. The checkerboard near the top blends into gray, which is usually the desired effect when the resolutionImage resolution

Image resolution describes the detail an image holds....
 is insufficient to show the detail. Even near the bottom of the image, the edges appear much smoother in the anti-aliased image. Figure 1-c shows another anti-aliasing algorithmAlgorithm

In mathematics and computing, an algorithm is a procedure for accomplishing some task which, given an initial state, will t...
, based on the sinc filterSinc filter Summary

In signal processing, a sinc filter is an idealized filter that removes all frequency components above a given bandwidth and...
, which is considered better than the algorithm used in 1-b.
Figure 2 shows magnified portions of Figure 1 for comparison. The left half of the image is taken from Figure 1-a, and the right half of the image is taken from Figure 1-c. Observe that the gray pixelPixel

A pixel is a single point in a graphic image....
s help make 1-c much smoother than 1-a, though they are not very attractive at the scale used in Figure 2.

Fig 3 shows how anti-aliasing smooths the outline. Text is affected in just the same way.

First-principles approach to anti-aliasing


The idealized image has infinite detail, and is represented by a functionFunction (mathematics)

In mathematics, a function relates each of its inputs to exactly one output....
 f(x,y) where x and y are real numberReal number

In mathematics, the set of real numbers, denoted R, is the set of all rational numbers and irrational numbers....
s defining coordinates.

There are infinitely many such functions. However, the computer screen is capable of displaying only finitely many different images. Indeed, an ordinary computer screen has no more than a few million pixels, and each pixel only has a finite number of colors it can display.

Hence, an image f(x,y) must be simplified in order to be converted into a displayable form. By the pigeonhole principlePigeonhole principle

The pigeonhole principle, also known as Dirichlet's box principle, states that if n pigeons are put into m pig...
, sometimes two different ideal images f(x,y) and g(x,y) will unavoidably be converted to the same picture on the screen. The question is how to select the best possible reduced image.

An example of a poor choice is illustrated in Figure 1-a. The most direct way to simplify an image for display is to use a sample of the image at f(i,j) for each pixel (i,j), as illustrated. At the top of the checkerboard, multiple black and white tiles may be represented by a single pixel. But since only black and white points occur in the ideal image, an area containing both colors in similar proportion will be represented with a strange pattern of black and white. This type of aliasing is called a Moiré effect.

A better approach is, for each pixel, to use the average intensity of a rectangular area in the scene corresponding to the surface area of the pixel. This gives a better, but not yet ideal, "anti-aliased" appearance; figure 1-b was generated this way. To see why this works better, it helps to look at the problem from a signal-processing perspective.

Signal processing approach to anti-aliasing


In this approach, the ideal image is regarded as a signal, the image displayed on the screen is taken as samples, at each (x,y) pixel position, of a filtered version of the signal. Ideally, we would understand how the human brain would process the original signal, and provide an image on screen that will yield the most similar response by the brain.

The most widely accepted analytic tool for such problems is the Fourier transformFacts About Fourier transform

The Fourier transform, named after Joseph Fourier, is a reversible integral transform of one function into another....
. The Fourier transform decomposes our signal into basic wavesWAVES Overview

The WAVES were a World War II era division of the U.S....
 of different frequencies, and gives us the amplitudeAmplitude

Amplitude is a nonnegative scalar measure of a wave's magnitude of oscillation, that is, magnitude of the maximum disturbanc...
 of each wave in our signal. The waves are of the form:




where j and k are arbitrary non-negative integers. (In fact, there are also waves involving the sineSiné

Maurice Sinet, known as Sin? is a French cartoonist....
, but for the purpose of this discussion, the cosine will suffice; see Fourier transformFourier transform

The Fourier transform, named after Joseph Fourier, is a reversible integral transform of one function into another....
 for technical details.)

The numbers j and k together are the frequency of the wave: j is the frequency in the x direction, and k is the frequency in the y direction.

As has been proved in the Nyquist–Shannon sampling theoremNyquist–Shannon sampling theorem Overview

The NyquistShannon sampling theorem is a fundamental result in the field of information theory, in particular telecommunicat...
, to uniquely specify a signal of not more than n frequencies, you need at least 2n sampleSample (signal) Overview

A sample refers to a value or set of values at a point in time and/or space....
 points (assuming the inclusion of the sines that we omitted above).

The eye is predominantly sensitive to lower frequencies. And so, in signal processingSignal processing

Signal processing is the processing, amplification and interpretation of signals and deals with the analysis and manipulatio...
, we choose to eliminate all high frequencies from the signal, keeping only the frequencies that are low enough to be sampled correctly by our sample rate.

The goal of sharply cutting off frequencies above a certain limit, known as the Nyquist frequencyNyquist frequency

The Nyquist frequency, named after Harry Nyquist or the NyquistShannon sampling theorem, is half the sampling frequency of a...
, can not be realized exactly, even with Fourier techniques, so it is always approximated, with many different choices of detailed algorithm. Our knowledge of human visual perception is not sufficient, in general, to say what approach will look best, but in general better approximations to the Fourier ideal tend to look better.

Figure 1-c was generated with the frequency-cutoff approach. It was not possible to do an exact Fourier series truncation; however, an approximation was used which we hope comes close to the correct image. To highlight the differences between 1-b and 1-c, observe that 1-c manages to be a bit clearer further up on the image than 1-b does. We are able to distinguish some texture other than uniform gray higher up on the image in 1-c than in 1-b.

The basic waves need not be cosine waves. See, for instance, waveletWavelet

In mathematics, wavelets, wavelet analysis, and the wavelet transform refers to the representation of a signal i...
s. If one uses basic waves which are not cosine waves, one obtains a slightly different image. Some basic waves yield anti-aliasing algorithms that are not so good. For instance, the Haar wavelet gives the uniform averaging algorithm. However, some wavelets are good, and it is possible that some wavelets are better at approximating the functioning of the human brain than the cosine basis.

Two dimensional considerations


The above assumes that the rectangular mesh sampling is the dominant part of the problem.
It should seem odd that the filter usually considered optimal is not rotationally symmetrical, as shown in this first figure. Since eyes can rotate in their sockets, this must have to do with the fact that we are dealing with data sampled on a square latticeSquare lattice

The square lattice is one of the five 2D lattice types....
 and not with a continuous image. This must be the justification for doing signal processing, along each axis, as it is traditionally done on one dimensional data. Lanczos resamplingLanczos resampling

Lanczos resampling is the use of a windowed sinc function as a convolution kernel for image resampling....
 is based on convolution of the data with a discrete representation of the sinc function.


If the resolution is not limited by the rectangular sampling rate of either the source or the target image, then one should ideally use rotationally symmetrical filter or interpolation functions, as though the data were a two dimensional function of continuous x and y. The sinc function of the radius, in the second figure, has too long a tail to make a good filter (it is not even square-integrable). A more appropriate analog to the one-dimensional sinc is the two-dimensional Airy discAiry disc

Due to the wave nature of light, light passing through apertures is diffracted, and the diffraction increases with decreasing aper...
 amplitude, the 2D Fourier transform of a circular region in 2D frequency space, as opposed to a square region.


One might consider a Gaussian plus enough of its second derivative to flatten the top (in the frequency domain) or sharpen it up (in the spatial domain). This function is shown also. Functions based on the Gaussian function are natural choices, because convolution with a Gaussian gives another Gaussian, whether applied to x and y or to the radius. Another of its properties is that it (similarly to wavelets) is half way between being localized in the configuration (x and y) and in the spectral (j and k) representation. As an interpolation function, a Gaussian alone seems too spread out to preserve the maximum possible detail, which is why the second derivative is added.

As an example, when printing a photographic negative, with plentiful processing capability, on a printer with a hexagonal pattern, there is no reason to use sinc function interpolation. This would treat diagonal lines differently from horizontal and vertical lines, which is like a weak form of aliasing.

Practical real-time anti-aliasing approximations


There are only a handful of primitivesPrimitive type

In computer science, primitive types as distinct from composite types are data types provided by a programming language ...
 used at the lowest level in a real-time rendering engine (either software or hardware accelerated.) These include "points", "lines" and "triangles". If one is to draw such a primitive in white against a black background, it is possible to design such a primitive to have fuzzy edges, achieving some sort of anti-aliasing. However, this approach has difficulty dealing with adjacent primitives (such as triangles that share an edge.)

To approximate the uniform averaging algorithm, one may use an extra buffer for sub-pixel data. The initial, and least memory-hungry approach, used 16 extra bits per pixel, in a 4×4 grid. If one renders the primitives in a careful order, for instance front-to-back, it is possible to create a reasonable image.

Since this requires that the primitives be in some order, and hence interacts poorly with an application programming interface such as OpenGLOpenGL

OpenGL is a standard specification defining a cross-language cross-platform API for writing applications that produce 3D co...
, the latest attempts simply have two or more full sub-pixels per pixel, including full color information for each sub-pixel. Some information may be shared between the sub-pixels (such as the Z-buffer.)

Mipmapping


There is also an approach specialized for texture mappingTexture mapping Overview

Texture mapping is a method of adding detail, surface texture, or colour to a computer-generated graphic or 3D model....
 called mipmapFacts About Mipmap

In 3D computer graphics texture filtering, MIP maps are pre-calculated, optimized collections of bitmap images that accompan...
ping, which works by creating lower resolution, prefiltered versions of the texture map. When rendering the image, the appropriate resolution mip-map is chosen and hence the texture pixels (texels) are already filtered when they arrive on the screen. Mipmapping is generally combined with various forms of texture filteringTexture filtering

In computer graphics, texture filtering is the method used to determine the texture color for a texture mapped pixel, using ...
 in order to improve the final result.

An example of an image with extreme pseudo-random aliasing

Because fractals have unlimited detail and no noise other than arithmetic roundoff error, they illustrate aliasing more clearly than do photographs or other measured data. The dwells, which are converted to colors at the exact centers of the pixels, go to infinity at the border of the set, so colors from centers near borders are unpredictable, due to aliasing. This example has edge in about half of its pixels, so it shows much aliasing. The first image is uploaded at its original sampling rate. Since most modern software anti-aliases, one may have to download the full size version to see all of the aliasing.
The second image is calculated at five times the sampling rate and down-sampledDownsampling Summary

Downsampling is the process of reducing the sampling rate of a signal....
 with anti-aliasing. Assuming that we would really like something like the average color over each pixel, this one is getting closer. It is clearly more orderly than the first.

Click each image to see it big enough to get the point.

It happens that, in this case, there is additional information that can be used. By re-calculating with the distance estimator, points were identified that are very close to the edge of the set, so that unusually fine detail is aliased in from the rapidly changing dwell values near the edge of the set. The colors derived from these calculated points have been identified as unusually unrepresentative of their pixels. Those points were replaced, in the third image, by interpolating the points around them. This reduces the noisiness of the image but has the side effect of brightening the colors. So this image is not exactly the same that would be obtained with an even larger set of calculated points.



To show what was discarded, the rejected points, bled into a grey background, are shown in the fourth image.

Finally, "Budding Turbines" is so regular that systematic (Moiré) aliasing can clearly be seen near the main "turbine axis" when it is downsized by taking the nearest pixel. The aliasing in the first image appears random because it comes from all levels of detail, below the pixel size. When the lower level aliasing is suppressed, to make the third image and then that is down-sampled once more, without anti-aliasing, to make the fifth image, the order on the scale of the third image appears as systematic aliasing in the fifth image.

The best anti-aliasing and down-sampling method here depends on one's point of view. When fitting the most data into a limited array of pixels, as in the fifth image, sinc function anti-aliasing would seem appropriate. In obtaining the second and third images, the main objective is to filter out aliasing "noise", so a rotationally symmetrical function may be more appropriate.

Full-scene anti-aliasing


Modern graphics cards usually support some method of full-scene anti-aliasing (FSAA) to help avoid aliasingAliasing

In statistics, signal processing, and related disciplines, aliasing is an effect that causes different continuous signals to...
 (or "jaggiesJaggies

"Jaggies" is the informal name for aliasing artifacts in raster images, often caused by non-linear mixing effects producing ...
") on full-screen images. The resulting image may seem softer, and should also appear more realistic. One tried and true method of avoiding or removing aliasingAliasing

In statistics, signal processing, and related disciplines, aliasing is an effect that causes different continuous signals to...
 artifactsArtifact (observational)

In natural science and signal processing, an artifact is any perceived distortion or other data error caused by the instrume...
 on full-screen imagesDigital image

A digital * multi-spectral* thematic...
 is supersamplingSupersampling

Supersampling is an antialiasing technique, the process of eliminating jagged and pixelated edges....
.

However, while useful for photo-like images, a simple anti-aliasing approach (such as supersampling and then averaging) may actually worsen the appearance of some types of line art or diagrams (making the image appear fuzzy), especially where most lines are horizontal or vertical. In these cases, a prior grid-fitting step may be useful (see hinting).

In general, supersampling is a technique of collecting data points at a greater resolutionImage resolution

Image resolution describes the detail an image holds....
 (usually by a power of two) than the final data resolution. These data points are then combined (down-sampled) to the desired resolution, often just by a simple averageFacts About Average

In mathematics, an average or central tendency of a set of data refers to a measure of the "middle" of the data set....
. The combined data points have less visible aliasing artifacts (or moiré patternMoiré pattern Overview

A moir pattern is an interference pattern created, for example, when two grids are overlaid at an angle, or when they have s...
s).

Full-scene anti-aliasing by supersampling usually means that each full frame is renderedRendering (computer graphics) Summary

Rendering is the process of generating an image from a model, by means of software programs....
 at double (2x) or quadruple (4x) the displayFacts About Computer display

Creaky voice , is a special kind of phonation in which the arytenoid cartilages in the larynx are drawn together; as a resul...
 resolution, and then down-sampled to match the display resolution. So a 4x FSAA would render four supersampled pixels for each single pixel of each frame.

More often than not, FSAA is implemented in hardware in such a way that a graphical application is unaware the images are being supersampled and then down-sampled before being displayed.

Object-based anti-aliasing


A graphics rendering system creates an image based on objects constructed of polygonal primitives whereby the aliasing effects in the image are reduced by applying an anti-aliasing scheme only to the areas of the image representing silhouette edges of the objects. The silhouette edges are anti-aliased by creating anti-aliasing primitives which vary in opacity. These anti-aliasing primitives are joined to the silhouetted edges, and create a region in the image where the objects appear to blend into the background. The method has some important advantages over the classical methods based on accumulation buffer since it generates full-scene anti-aliasing in two passes only and since it does not require the use of the additional memory represented by the accumulation buffer. Object-based anti-aliasing was first developed at Silicon GraphicsSilicon Graphics

Silicon Graphics, Inc., also known as SGI, began as a maker of graphics display terminals in 1982....
 for the SGI IndySGI Indy

Introduced in 1993, the Indy was the fruit of SGI's effort to muscle into the market for desktop publishing, low-end CAD, an...
 workstation.

History

Important early works in the history of anti-aliasing include:

  • Freeman, H.Herbert Freeman

    Dr. Herbert Freeman is a computer scientist who made important contributions to the field of computer graphics, including an...
    . "Computer processing of line drawing images", ACM Computing Surveys vol. 6(1), March 1974, pp. 57–97.
  • Crow, Franklin C.Franklin C. Crow

    Dr. Franklin C. Crow is a computer scientist who has made important contributions to computer graphics, including some of th...
    . "The aliasing problem in computer-generated shaded images", Communications of the ACMCommunications of the ACM Overview

    Communications of the ACM is the flagship monthly magazine of the Association for Computing Machinery....
    , vol. 20(11), November 1977, pp. 799–805.
  • Catmull, EdwinEdwin Catmull

    Edwin Catmull, Ph.D. is a computer scientist and current President of film animation studios, the Disney-Pixar Studios....
    . "A hidden-surface algorithm with anti-aliasing", Proceedings of the 5th annual conference on Computer graphics and interactive techniques, p.6–11, August 23–25, 1978.

See also

  • SupersamplingSupersampling

    Supersampling is an antialiasing technique, the process of eliminating jagged and pixelated edges....
    , a method of antialiasing
  • Statistical samplingSampling (statistics)

    Sampling is that part of statistical practice concerned with the selection of individual observations intended to yield some...
  • Temporal anti-aliasingTemporal anti-aliasing

    Temporal anti-aliasing seeks to reduce or remove the effects of temporal aliasing, which results from insufficient temporal sampli...
  • Anisotropic filteringAnisotropic filtering

    In 3D computer graphics, Anisotropic filtering is a method of enhancing the image quality of textures on surfaces that are f...
    , another method for improving image quality by enhancing textures
  • Measure theory
  • Font rasterizationFont rasterization Summary

    Font rasterization is the process of converting text from a vector description to a raster or bitmap description....
  • Color theoryColor theory

    In the arts of painting, graphic design, and photography, color theory is a body of practical guidance to color mixing and t...
     for certain physical details pertinent to color images
  • Reconstruction filterReconstruction filter

    In a mixed-signal system, a reconstruction filter is used to construct a smooth analogue signal from the output of a digital...
  • QuincunxQuincunx

    A quincunx is the arrangement of five units in the pattern corresponding to the five-spot on dice, playing cards, or dominoe...
     (pattern used for anti-aliasing)
  • Subpixel renderingSubpixel rendering

    Subpixel rendering is a way to increase the apparent resolution of a computer's liquid crystal display....
    , an application of anti-aliasing using the properties of a color LCD screen
  • Xiaolin Wu's line algorithmXiaolin Wu's line algorithm

    Xiaolin Wu's line algorithm is an algorithm for line antialiasing, which was presented in the article An Efficient Antiali...
     fast real-time anti-aliasing
  • Multisample anti-aliasingMultisample Anti-Aliasing

    Multisample anti-aliasing is a type of anti-aliasing, a technique used in computer graphics to improve image quality....


External links

  • : Explains interaction between antialiasing and transparency, especially when dealing with web graphics
  • In most real-world systems, gamma correctionGamma correction

    Gamma correction, gamma nonlinearity, gamma encoding, or often simply gamma, is the name of a nonlinear op...
     is required to linearize the response curve of the sensor and display systems. If this is not taken into account, the resultant non-linear distortion will defeat the purpose of anti-aliasing calculations based on the assumption of a linear system response.