Anti-Aliasing and Resampling Artwork - Part 1

By Gary David Bouton

Dateline: May 5, 2003
Volume 1, Number 5
Earlier columns
Computer Art Lessons forum

I'd planned to discuss the fundamental differences between vector and bitmap graphics this month, but along the way I got a little carried away with one of the fundamentals of bitmap images: anti-aliasing. It's a fair enough topic for beginners and it's not a bad read for those of us who've been around the pixel once or twice. In the first of a two-part series, I'll begin by discussing the procedure by which art applications disguise the reality that diagonal lines and curves cannot be faithfully, artistically represented using rectangular pixels – "helper pixels" are required around the edge of such shapes. I'll take you through how anti-aliasing works, whether you're drawing a line or resizing a bitmap graphic.

"Aliasing" is the false presentation of visual data and is the result of an application rendering an image area without enough visual information. In the first illustration, you can see a spaceship at the top with an aliased outline – there are supposed to be curved and smooth diagonal lines around its outline, but instead there are stairsteps. "Anti-aliasing", shown applied to the same spaceship at the bottom, is a method for accurately representing image data.

Image Resolution and Granularity

To better demonstrate the effects of aliasing and anti-aliasing, I've chosen a visual example of a checkerboard that extends into the horizon. To remove user input and simply show how an application handles anti-aliasing, let's say that this checkerboard scene is being rendered in a modeling application, in which you define the scene and the application does the rendering work. The squares that are closest to the viewer are white or black; there is no ambiguity about the color of the large squares. However, as the squares diminish in size towards the horizon, each square is perceived using a smaller number of photo-receptors in the eye, until the horizon appears to be a solid tone instead of alternating colors. Your eye cannot distinguish clearly which squares are white and which are black, because the "granularity" – the number of photo-receptors in your eye – is a fixed amount.

When this checkerboard scene is rendered by a computer application to bitmap format, the application performing the rendering has two choices to make: to alias the horizon – to choose either white or black at any given pixel – or to anti-alias – to average the color for a given pixel, to create an image area closer to the way a human eye would see the actual scene. In the illustration above, imagine that the square next to the call-out is a single pixel, a pixel whose size cannot change and can contain only one color.

The visual content at this point in the picture, however, consists of more than one color – there can be a number of white and black squares close to the horizon – with only a single image pixel to represent them. So, what's it going to be: a black or a white pixel? To make such a decision is called aliasing; if you fill this pixel with white, you're negating the black squares within this sample area. To reconcile the impossibility of filling a single pixel with more than one color, anti-aliasing of the scene fills the pixel with a shade of black, because in reality the pixel sample area should contain a blend of both black and white sample information. Anti-aliasing can be added to artwork by most graphics applications on three occasions:

  • When you make a brush stroke.
  • When a brush stroke is made for you, as with a modeling/rendering application.
  • When pixels are added or deleted from an image. This is called "resampling".
Anti-aliasing does more than simply reconcile pixel colors when the image information is too large to fit in a single pixel. Let's now take a look at how curves and diagonal lines – geometry that cannot realistically be displayed on a monitor – can be made smooth in appearance by anti-aliasing. Note: "super-sampling" is a term used in modeling applications to describe yet another type of anti-aliasing. The mechanism for super-sampling works like this: the user defines a specific size for the scene to be rendered. The application images the scene at two times the requested size, holds the image in memory, and then creates the image at the requested size while averaging tones for the image's pixels from the larger image in memory. This super-sampling process can use more than one image in memory, so you could request that an 8x image, a 4x and a 2x image should be used to average and calculate final pixel colors.

Anti-aliasing and Brush Strokes

Curves and diagonal lines are particularly difficult for a monitor to display with image fidelity, because a monitor, and the pixel framework of digital images, have no mechanism for displaying anything beyond a rectangular quiltwork of image elements. To keep the edges of these geometric shapes smooth in appearance, anti-aliasing is used by applications to place pixels of different opacity along "problem areas" of curves and diagonal lines.

In the illustration below you can see a pair of diagonal lines; the one at left has several pixels of different opacity that "fill in" the abrupt edges where the line is not perfectly parallel to the grid of pixels that make up the image. At right, an aliased version of the diagonal line shows harsh, unappealing "stairsteps".

A fair question at this point would be, "How does the application know where to put the different anti-aliased pixels? The answer lies in averaging image area tones, and interpolating the correct shade of pixel to lie on the edge of the line or curve. We'll get into the various methods of interpolation next month. In the next illustration you can see a close-up of a rounded shape, with and without anti-aliasing. At a close view, the outline of the anti-aliased shape looks fuzzy, but at 1:1 viewing resolution the curve is both crisp and soft.

If you zoom very closely on a diagonal line with anti-aliased edges, you will observe the following phenomenon: pixels at the edge of the line gradually are composed of less line color and more image background color the farther a pixel is from the line. Below you can see callouts for the percentage mixture of anti-aliased pixels on the edge of a vertical line.

The idea behind anti-aliasing a shape you create is to make a smooth transition between the interior of a shape and its background. Besides the anti-aliasing that goes on in modeling and painting programs, there is a third type of anti-aliasing that occurs when you resize a bitmap image. Next month I'll cover the different sorts of interpolation ("interpretation") graphics apps use to make the resizing of an image come out more smoothly. I'll also tell you what sort of image editor you might want to buy, to make sure that product X can do bicubic interpolation, for example.

But I'm getting a month ahead of myself.

My Best,
Gary David Bouton

Discuss this column with Gary in the Computer Art Lessons forum.
Don't miss the next installment of this column. Get the free Graphics.com newsletter in your mailbox each week (and win great graphics products). Click here to subscribe.

Gary David Bouton is an author and artist who is largely responsible for the book "Inside Adobe Photoshop 7" and wouldn't mind at all if you bought a copy . Gary hosts a thread on the Photoshop Gurus site and is the moderator of a 3D modeling forum. His guide to Caligari's free trueSpace 3D app is available online. Besides being an educator/artist/all-around-nice-guy, Gary also has the largest bottle cap collection on the East Coast, and wants to be Scott Turow (or at least Mr. Turow's bank account) when he grows up.