47
\$\begingroup\$

I always hear about aliasing and anti-aliasing and I know what it looks like but what I don't understand is what causes it. Is it a physical phenomenon? Or a numerical one?

If it helps to explain, I have some programming knowledge, but not in video games or graphics.

\$\endgroup\$
0

4 Answers 4

59
\$\begingroup\$

Is it a physical phenomena ? or numerical ?

This question sorta implies to me that you don't actually know what aliasing/anti-aliasing means. I mean, you say you "know what it looks like" but if you actually knew what the terms mean, you'd probably realize your question is nonsensical. Aliasing is a side-effect of how computer graphics are rendered, and computer graphics are pretty much by definition not physical phenomena.

"Aliasing" just refers to the stair-step look on angled lines because computer graphics are actually comprised of lots of tiny squares in a grid. Here's an image to illustrate what I'm talking about: enter image description here

This is an issue whenever you render the pixels in an image, whether you're drawing freehand or are writing an algorithm to calculate the pixels for a 3D polygon. It's just a side-effect of the fact that the image is a square grid of pixels. "Anti-aliasing" is when you disguise the stair-step look by blending the colors together along the edge pixels.

\$\endgroup\$
12
  • 18
    \$\begingroup\$ @Kruncho Never be sorry for being wrong, unless you are teaching others your mistakes! Only be sorry when you don't try to understand or are unwilling to be corrected. Your mistake actually helped to clarify what exactly you were asking to know about: ('how' does aliasing happen in computer graphics?). Btw, while this answer is best to illustrate the what, how and why, it is a numerical issue. You could think of it as a limitation of trying to represent fractional numbers using only whole integers. There is no half pixels, etc. So you end up with blocky looking images. \$\endgroup\$ Commented Aug 19, 2015 at 17:57
  • 5
    \$\begingroup\$ @jhocking A pedantic correction: the squareness of the pixels is not actually relevant. Aliasing would happen just the same if each pixel were round dots of all the same size. \$\endgroup\$ Commented Aug 19, 2015 at 18:05
  • 10
    \$\begingroup\$ @jhocking "Square grid" won't cut it either. You'd still get aliasing (looking a bit different) if your pixels were arranged in a hexagonal grid. All that matters is that the pixels are arranged in a regular pattern and are of non-zero size, and both of those conditions are true for any conceivable display technology. \$\endgroup\$
    – Mike Scott
    Commented Aug 19, 2015 at 18:33
  • 3
    \$\begingroup\$ You're getting hung up on the word "square" when that's just a descriptor for "grid". \$\endgroup\$
    – jhocking
    Commented Aug 19, 2015 at 18:36
  • 11
    \$\begingroup\$ @MikeScott: Even with irregularly arranged pixels the aliasing will show up. :))) The important condition for aliasing to appear is that the maximum frequency of the original signal (the original image) is higher than 2*(1/T) (where T is the interval between the samples = the distance between the pixels). --- When the original image has sharp edges (like the black line on a white background) then its maximum frequency is infinite. \$\endgroup\$ Commented Aug 19, 2015 at 21:47
124
\$\begingroup\$

The accepted answer is not strictly correct, although it addresses the most common usage in computer graphics. Aliasing is a fundamental concept in signal processing and the mathematical theory of it predates computer displays. It is also not really true that "it is a side effect of the fact that pixels are square". Aliasing exists any time you discretely sample a signal at a rate below the Nyquist rate for that signal and affects digital audio as well as images and many other types of discretely sampled signals. Aliasing in computer graphics is a side effect of discrete sampling, not of the shape of the pixels.

Anti-aliasing in computer graphics is a deep and complex topic and there's a lot more to it than just edge anti-aliasing. Again, there's a lot of underlying theory from signal processing and it's an active area of research in computer graphics how to anti-alias effectively, not just for edges but also for temporal aliasing, for aliasing when reconstructing a BRDF in pixel shaders, for shadow edges and in many other areas. Mip-mapping of textures in 3D graphics is a well established anti-aliasing technique that is addressing an important problem other than edge anti-aliasing for example.

It's really a mathematical phenomenon more than a physical one but it shows up in engineering in many areas other than computer graphics. I wouldn't really describe it as a numerical phenomenon either - it's a result of discrete sampling, not of the discrete representation of numerical values on a computer, although that can cause aliasing effects too. Understanding the fundamentals of signal processing is a good foundation for understanding how aliasing manifests in computer graphics and for understanding how to go about reducing it.

\$\endgroup\$
8
  • 6
    \$\begingroup\$ On the one hand, hey I learned something new today, never heard of aliasing in any context other than graphics edges. That said, this additional technical detail doesn't seem to contradict the explanation "it is a side effect of the fact that pixels are square". "Discrete sampling" is just a fancy way of saying "the edge is actually a bunch of discrete pixels, not a continuous line". \$\endgroup\$
    – jhocking
    Commented Aug 19, 2015 at 17:35
  • 15
    \$\begingroup\$ +1 for technical correctness. Although a bit too technical given the level of the question asked and doesn't actually address the implied question. The accepted answer is more suitable to the intent of the question. I learned something new though, so thanks for the elaboration :) \$\endgroup\$ Commented Aug 19, 2015 at 17:36
  • 6
    \$\begingroup\$ @jhocking sorry, us graphics programmers tend to get a bit worked up over aliasing :) I think your answer addresses the question but if someone wants to go any deeper in computer graphics I think it's helpful to understand that aliasing is a mathematical phenomena with a bunch of theory behind it. All that technical detail comes in handy for the ultimate goal of making pretty pictures in our games :) \$\endgroup\$ Commented Aug 19, 2015 at 17:39
  • 4
    \$\begingroup\$ @jhocking The point is that it doesn't matter what shape the pixels are -- so it is not a side effect of the fact that pixels are square, it is a side effect of the fact that pixels don't change color over their extent. And anyway, a pixel is not a little square. \$\endgroup\$ Commented Aug 20, 2015 at 4:26
  • 1
    \$\begingroup\$ Your answer is missing pictures, otherwise it would definitely be the accepted one. Apart from the edge anti-aliasing example it needs: 1) animated gif of car wheels rotating clockwise and suddenly stopping and changing direction. 2) a 3D chess board (you know the one going to infinity)... I also studied signal processing. \$\endgroup\$ Commented Aug 22, 2015 at 0:30
68
\$\begingroup\$

Adding to the other two answers, here is a more intuitive explanation of what happens.

Aliasing in a 2D polygon

The grid squares represent pixels. The red polygon on the left is the shape being drawn, represented internally as a sequence of points. When it is rendered, it is converted from a list of points to a buffer of pixel colors. The discrete sampling determines which pixels are dark and which pixels are light, based on how much of the polygon covers each pixel.

To answer your question, this is a numerical/mathematical phenomenon because information about the original shape is lost due to approximation.

Antialiasing

Anti-aliasing is when the rendering attempts to correct for aliasing by making partially-covered pixels less intense.

\$\endgroup\$
3
  • 5
    \$\begingroup\$ Here's the first answer that really explains what's going on. Well done. \$\endgroup\$
    – Beska
    Commented Aug 20, 2015 at 12:37
  • 1
    \$\begingroup\$ "making partially covered pixels less intense" is not exactly as I understand it. I believe that most Anti Aliasing algorithms apply a Low Pass Filter (same as a blur filter), sometimes across the entire rendered frame (as with FXAA) or more intelligent algorithms perform it only across edge boundaries. MSAA does it a different way, but the overall effect remains that of a LPF over hard edge boundaries. \$\endgroup\$
    – Luke
    Commented Aug 21, 2015 at 10:54
  • 1
    \$\begingroup\$ @Luke I didn't intend for the last paragraph to be an explanation of how things work; it's just describing the outcome of anti-aliasing. "Intense" isn't the correct term to use, but it applies when anti-aliasing is done on a shape whose color is more intense than the background. That's all I was saying. \$\endgroup\$
    – aebabis
    Commented Aug 21, 2015 at 16:45
3
\$\begingroup\$

In signal processing field, aliasing refer to the misidentification of signal frequency. For example, due to the lack of the adequate consideration in under-sampling step it may lead to the generating errors and distortion. It can be generalized to the 2D discrete signal such as an image.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .