Antialiasing is a technique used in computer graphics to remove the aliasing effect. The aliasing effect is the appearance of jagged edges or “jaggies” in a rasterized image (an image rendered using pixels). The problem of jagged edges technically occurs due to distortion of the image when scan conversion is done with sampling at a low frequency, which is also known as Undersampling. Aliasing occurs when real-world objects which comprise of smooth, continuous curves are rasterized using pixels.
Cause of anti-aliasing is Undersampling. Undersampling results in loss of information of the picture. Undersampling occurs when sampling is done at a frequency lower than Nyquist sampling frequency. To avoid this loss, we need to have our sampling frequency atleast twice that of highest frequency occurring in the object.
This minimum required frequency is referred to as Nyquist sampling frequency (fs):
This can also be stated as that our sampling interval should be no larger than half the cycle interval. This maximum required the sampling interval is called Nyquist sampling interval Δxs:
Δxs = Δxcycle/2 Where Δxcycle=1/fmax
Methods of Antialiasing (AA) –
Aliasing is removed using four methods: Using high-resolution display, Post filtering (Supersampling), Pre-filtering (Area Sampling), Pixel phasing. These are explained as following below.
- Using high-resolution display:
One way to reduce aliasing effect and increase sampling rate is to simply display objects at a higher resolution. Using high resolution, the jaggies become so small that they become indistinguishable by the human eye. Hence, jagged edges get blurred out and edges appear smooth.
For example retina displays in Apple devices, OLED displays have high pixel density due to which jaggies formed are so small that they blurred and indistinguishable by our eyes.
- Post filtering (Supersampling):
In this method, we are increasing the sampling resolution by treating the screen as if it’s made of a much more fine grid, due to which the effective pixel size is reduced. But the screen resolution remains the same. Now, intensity from each subpixel is calculated and average intensity of the pixel is found from the average of intensities of subpixels. Thus we do sampling at higher resolution and display the image at lower resolution or resolution of the screen, hence this technique is called supersampling. This method is also known as post filtration as this procedure is done after generating the rasterized image.
In gaming, SSAA (Supersample Antialiasing) or FSAA (full-scene antialiasing) is used to create best image quality. It is often called the pure AA and hence is very slow and has a very high computational cost. This technique was widely used in early days when better AA techniques were not available. Different modes of SSAA available are: 2X, 4X, 8X, etc. denoting that sampling is done x times (more than) the current resolution.
A better style of AA is MSAA (multisampling Antialiasing) which is a faster and approximate style of supersampling AA.It has lesser computational cost. Better and sophisticated supersampling techniques are developed by graphics card companies like CSAA by NVIDIA and CFAA by AMD.
- Pre-filtering (Area Sampling):
In area sampling, pixel intensities are calculated proportional to areas of overlap of each pixel with objects to be displayed. Here pixel color is computed based on the overlap of scene’s objects with a pixel area.
For example: Suppose, a line passes through two pixels. The pixel covering bigger portion(90%) of line displays 90% intensity while less area(10%) covering pixel displays 10-15% intensity. If pixel area overlaps with different color areas, then the final pixel color is taken as an average of colors of the overlap area. This method is also known as pre-filtering as this procedure is done BEFORE generating the rasterized image. It’s done using some graphics primitive algorithms.
- Pixel phasing:
It’s a technique to remove aliasing. Here pixel positions are shifted to nearly approximate positions near object geometry. Some systems allow the size of individual pixels to be adjusted for distributing intensities which is helpful in pixel phasing.
Other Applications of antialiasing techniques:
- Compensating for line intensity differences:
When a horizontal line and a diagonal line plotted on the raster display, the number of pixels required to display both lines is same, even though the diagonal line is 1.414 times larger than the horizontal line. This leads to a decrease in the intensity of the longer line. To compensate for this decrease in intensity, the intensity of pixels is assigned according to the length of line using anti-aliasing techniques.
- Anti-aliasing area boundaries:
Anti-aliasing concepts can also be applied to remove jaggies along area boundaries. These procedures can be applied to scanline algorithms to smoothen out area boundaries .if repositioning of pixels is possible then pixel positions are adjusted to positions closer to area boundaries. Other methods adjust pixel intensity at a boundary position according to the percent of pixel area inside the boundary. These methods effectively smoothen out area boundaries.
- Segments in Computer Graphics
- Applications of Computer Graphics
- Computer Graphics | The RGB color model
- Translation of objects in computer graphics
- Display Processor in Computer Graphics
- DDA Line generation Algorithm in Computer Graphics
- Draw a moving car using computer graphics programming in C
- 2D Transformation in Computer Graphics | Set 1 (Scaling of Objects)
- Point Clipping Algorithm in Computer Graphics
- Window to Viewport Transformation in Computer Graphics with Implementation
- Computer Graphics | Refresh type output devices
- Computer Graphics | Cathode ray tube (video display device)
- bar() function in C graphics
- Draw Rectangle in C graphics
- Draw circle in C graphics
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.