Aliasing & Anti-aliasing
Aliasing is the visual stair-stepping of edges that occurs in an image when the resolution is too low. Anti-aliasing is the smoothing of jagged edges in digital images by averaging the colors of the pixels at a boundary.
The letter on the left is aliased. The letter on the right has had anti-aliasing applied to make the edges appear smoother.
Antialiasing is a computer graphics method that removes the aliasing effect. The aliasing effect occurs when rasterised images have jagged edges, sometimes called "jaggies" (an image rendered using pixels). Technically, jagged edges are a problem that arises when scan conversion is done with low-frequency sampling, also known as under-sampling, this under-sampling causes distortion of the image. Moreover, when real-world objects made of continuous, smooth curves are rasterised using pixels, aliasing occurs.
Under-sampling is an important factor in anti-aliasing. The information in the image is lost when the sample size is too small. When sampling is done at a frequency lower than the Nyquist sampling frequency, under-sampling takes place. We must have a sampling frequency that is at least two times higher than the highest frequency appearing in the image in order to prevent this loss.
Anti-Aliasing Methods:
A high-resolution display, post-filtering (super-sampling), pre-filtering (area sampling), and pixel phasing are the techniques used to remove aliasing. The explanations of these are given below:
- Using High-Resolution Display - Displaying objects at a greater resolution is one technique to decrease aliasing impact and boost the sampling rate. When using high resolution, the jaggies are reduced to a size that renders them invisible to the human eye. As a result, sharp edges get blurred and appear smooth.
Real-Life Applications:
For example, OLED displays and retina displays in Apple products both have high pixel densities, which results in jaggies that are so microscopic that they are blurry and invisible to the human eye. - Post-Filtering or Super-Sampling - With this technique, we reduce the adequate pixel size while improving the sampling resolution by treating the screen as though it were formed of a much finer grid. The screen resolution, however, does not change. Now, the average pixel intensity is determined from the average of the intensities of the subpixels after each subpixel's intensity has been calculated. In order to display the image at a lesser resolution or screen resolution, we do sampling at a higher resolution, a process known as supersampling. Due to the fact that this process is carried out after creating the rasterised image, this technique is also known as post filtration.
Real-Life Applications:
The finest image quality in gaming is produced with SSAA (Super-sample Antialiasing) or FSAA (full-scene Antialiasing). It is frequently referred to as the "pure AA," which is extremely slow and expensive to compute. When no better AA techniques were available, this technique was frequently utilised in the beginning. Other SSAA modes are available, including 2X, 4X, 8X, and others that indicate sampling that is done x times (greater than) the present resolution.
MSAA (multisampling Antialiasing), a quicker and more accurate version of super-sampling AA, is a better AA type.
Its computational cost is lower. Companies that produce graphics cards, such as CSAA by NVIDIA and CFAA by AMD, are working to improve and advance super-sampling techniques. - Pre-Filtering or Area-Sampling - The areas of each pixel's overlap with the objects displayed are taken into account while calculating pixel intensities in area sampling. In this case, the computation of pixel colour is centred on the overlap of scene objects with a pixel region.
Example: Let's say a line crosses two pixels. A pixel that covers a larger amount of a line (90%) displays 90% intensity, whereas a pixel that covers a smaller piece (10%) displays 10-15% intensity. If a pixel region overlaps with multiple colour areas, the final pixel colour is calculated as the average of those colours. Pre-filtering is another name for this technique because it is used before rasterising the image. Some basic graphics algorithms are used to complete it. - Pixel Phasing - It is a method to eliminate aliasing. In this case, pixel coordinates are altered to virtually exact positions close to object geometry. For dispersing intensities and aiding with pixel phasing, some systems let you change the size of individual pixels.
Application of Anti-Aliasing:
- Compensating for Line Intensity Differences - Despite the diagonal line being 1.414 times larger than the horizontal line when a horizontal line and a diagonal line are plotted on a raster display, the amount of pixels needed to depict both lines is the same. The extended line's intensity decreases as a result. Anti-aliasing techniques are used to allocate the intensity of pixels in accordance with the length of the line to make up for this loss of intensity.
- Anti-Aliasing Area Boundaries - Jaggies along area boundaries can be eliminated using anti-aliasing principles. These techniques can be used to smooth out area borders in scanline algorithms. If moving pixels is an option, they are moved to positions nearer the edges of the area. Other techniques modify the amount of pixel area inside the boundary by adjusting the pixel intensity at the boundary position. Area borders are effectively rounded off using these techniques.