Anti-aliasing is a way of reducing the jagged edges in an image. If you point a video camera at a black diagonal line on a white background, you find that the image is not just black-and-white. Those pixels that had part of the line in them are grey. These make it look a bit blurry, but smoother. Anti-aliasing applies the same pixel-mixing to all edges, noticeably improving the appearance of curves, diagonal lines, and fonts.

Sub-pixel rendering like Cleartype looks similar.
Anti-aliasing uses the alpha value(transparency) of a pixel to create blending.

How it works
When you are displaying data in video memory, there are usually four components to each pixel, a value for the amount of red, green, blue and an alpha value for the transparency. You take this alpha value and use it to calculate a transparency value for that pixel. This will mix the background color with the color you are putting on top of it, eliminating jagged edges (actually called jaggies) in pictures.

Pixels that are dark and in the middle of the image have an alpha value of zero, because you want them to show up 100%. However at the edges you assign a slowly increasing alpha value. The alpha value is usually one word ranging from a value of 0 - 255. The very outer pixels of the image you are trying to display may have very high alpha values

Calculation
So, lets say you have a small letter of text that you want to put on the screen, the letter 'O'. In the center of the letter, the alpha values will be really high ~250 so that the background can show through and same with the very outer edges of letter. Directly around the ring which makes up the letter 'O' the alpha values will be very low ~5 so that the text can show up on the screen. Use this formula on each pixel before displaying it on the screen.

(alpha/255) * new_pixel   +    [1-(alpha/255)] * background_pixel = new_blended_pixel

As you can see from this formula, the new pixel is a mix between a portion of each of the original pixels, hence the blending. This can be used in many scenarios like dissolving a picture onto or off of the screen, blending from one screen to another, or smoothing out edges on font characters.

In ray tracing programs, or other software where the image is being generated from input which allows an arbitrary resolution, anti-aliasing is accomplished by supersampling - colour values are assigned by calculating the values obtained for a number of points inside each pixel, and then averaging these, to get the final value for the rendered pixel.

Imagine our ray tracer is rendering a sloping dark object, against a white background.

Using one ascii character per pixel, with no antialiasing, we get something like:


             ####
           ######
          #######
        #########
       ##########
     ############

With antialiasing, we 'zoom in' on each pixel and calculate a colour value at several points 'inside':
   
     ---------------------
     |    |    |    |####|
     |    |    |   #|####|
     |    |    | ###|####|
     ---------------------
     |    |    |####|####|
     |    |  ##|####|####|
     |    |####|####|####|
     ---------------------
     |   #|####|####|####|
     | ###|####|####|####|
     |####|####|####|####|
     ---------------------

(each 'box' represents one pixel.)

Averaging the dark and light 'hits' on the edge area then produces a final 'rendering' something more like


            o####
          .######
         o#######
       .#########
      o##########
     ############

(where 'o' and '.' are intended to represent intermediate (gray) shades between the light and dark)

Though the final image is still pixelated at the same resolution, the 'grayness' around the edges fools the eye of the viewer into thinking the diagonal line is smoother than in the non-anti-aliased version.

As usual in ray tracing, there is no gain in image quality without considerable pain - the extra calculations increase the rendering time by a factor roughly equal to the number of samples per pixel.

Log in or register to write something here or to contact authors.