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 smooth, continuous curves are rasterized using pixels. The cause of anti-aliasing is Undersampling.
Undersampling results in a loss of information about the picture. Undersampling occurs when sampling is done at a frequency lower than the Nyquist Sampling Frequency. To avoid this loss, we need to have our sampling frequency at least twice that of the highest frequency occurring in the object.
This minimum required frequency is referred to as Nyquist sampling frequency (fs). It can be stated as:
This can also be stated that our sampling interval should be no larger than half the cycle interval. This maximum required sampling interval is called the Nyquist Sampling Interval (Δxs), which can be stated as:
Δxs = Δxcycle/2
Methods of Anti-Aliasing (AA)
There are four methods of Anti-Aliasing. These methods are mentioned below.
- High-Resolution Display
- Pixel Phasing
1. Using High-Resolution Display
One way to reduce the aliasing effect and increase the sampling rate is to simply display objects at a higher resolution. Using high resolution, the jaggies become so small that they become indistinguishable from the human eye. Hence, jagged edges get blurred out and edges appear smooth.
Practical applications: For example, retina displays in Apple devices, and OLED displays have high pixel density due to which jaggies formed are so small that they blurred and are indistinguishable by our eyes.
2. 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 the average intensity of the pixel is found from the average of intensities of subpixels. Thus we do sampling at a higher resolution and display the image at a 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.
Practical Applications: In gaming, SSAA (Supersample Antialiasing) or FSAA (Full-Scene Antialiasing) is used to create the best image quality. It is often called pure AA and hence is very slow and has a very high computational cost. This technique was widely used in the 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 Anti-Aliasing is MSAA (Multisampling Antialiasing) which is a faster and more approximate style of supersampling AA. It has a lesser computational cost. Better and more sophisticated supersampling techniques are developed by graphics card companies like CSAA by NVIDIA and CFAA by AMD.
3. Pre-Filtering (Area Sampling)
In area sampling, pixel intensities are calculated proportionally to areas of overlap of each pixel with objects to be displayed. Here pixel color is computed based on the overlap of the scene’s objects with a pixel area.
Example: Suppose, a line passes through two pixels. The pixel covering a bigger portion(90%) of the line displays 90% intensity while less area(10%) covering the pixel displays 10-15% intensity. If the 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.
4. 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.
Types of Anti-Aliasing
Anti-Aliasing can be broadly classified into two broad categories. These two categories are listed below.
- Spatial Anti-Aliasing: Spatial Anti-Aliasing is a technique that is used in cases when a low-resolution picture has jaggies. It is used to minimize the distortion effects upon the representation of the higher image to a lower image. These are classified as:
- Super Sampling Anti-Aliasing
- Multi-Sample Anti-Aliasing
- Post-Process Anti-Aliasing: Post-Processing Anti-Aliasing is a technique used when every process is blurred in the rendering processing. It is a quicker technique in comparison to Spatial Anti-Aliasing. It is of the following types:
- Temporal AntiAliasing
- Enhanced Subpixel Morphological Antialiasing
For more, refer to Types of Anti-Aliasing Techniques.
Applications of Anti-Aliasing Techniques
- Compensating for Line Intensity Differences: When a horizontal line and a diagonal line are plotted on the raster display, the number of pixels required to display both lines is the 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 the 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.
FAQs on Anti-Aliasing
1. What does Anti-Aliasing Do?
Anti-Aliasing is the technique of making or transforming the images so that their visual looks good and can be easily recognized.
2. Is it better to use Higher Anti-Aliasing?
Higher Anti-Aliasing is a good option as it increases the number of pixels and make images sharper, but it requires high and powerful GPU with extra memory.
3. Which Anti-Aliasing technique is best?
SSAA (Super Sampling Anti-Aliasing) is the best technique for anti-aliasing.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!
Share your thoughts in the comments
Please Login to comment...