You are viewing the course site for a past offering of this course. The current offering may be found here.
Lecture 3: Sampling and Aliasing (18)
Staffjamesfong1

(Seed for discussion)

This slide suggests an algorithm for rasterizing triangles without aliasing. First blur your triangle, and then sample.

But how would you actually implement this in practice? Remember, the triangle is described mathematically by the intersection of three half-planes. How would you "blur" those math equations?

rsha256

We know that the high-frequencies are where color changes and we know that occurs at the lines. So around the lines, we can give a blurred image by blending stuff a bit from each side perpendicular to its direction. And then uniformly fill in a uniform color everywhere else inside/outside?

sberkun

Here's a desmos demo that demonstrates one potential idea. It essentially shifts the lines of the triangle to create the boundaries of the "blur".

sberkun

[deleted]

sZwX74

Unless I've misunderstood @jamesfong1's question, I think we remove the high frequencies after we've created this triangle indicator function, rather than trying to directly use math equations to create a blurred triangle, before sampling. To add on to @rsha256;s comment, the highest frequencies are where the color changes are the sharpest, so by removing them, we have a smoother transition at the border of the triangle.

eric-li-2

One possible implementation for blurring the triangle is to use a gaussian distribution with the distance to the edge of the triangle as input. The output of the gaussian could represent what proportion of the pixel is red or white. I feel like this would be tricky to implement on corners though since our definition of distance to the edge is ambiguous.

JustinHuey1

I remember in lecture that prof said that it wouldn't work to sample and then filter, but I forgot why. Could someone remind me of that?

StaffDanCubed

@JustinHuey1 I think that slide 22 from this lecture shows a pretty nice visualization of the difference between sampling first and filtering first. If you sample then filter, you simply get blurred jaggies. I think what the sample then filter method gets wrong is that it assume filtering can reverse the damage done by the process that created jaggies, while that's simply not what filtering aims to address.

StaffDanCubed

To add on to that, one simple analogy I kinda liked was that sampling is kind of similar to rounding a number: let's say we have 4.6, then according to the rules we must round it to 5, altering the original number. However, filter is like turning the number into an interval: if we expand the number 4.6 by 0.5 on either side, we get the interval [4.1, 5.1], and now the number 5 lies within our given range. You can see how filtering doesn't "undo" jaggies now: if we first turn 4.6 into 5, then turn it into an interval, it becomes [4.5, 5.5], a range that no longer has 4.6 as its median. The filtering softened, but still preserved the damage done by the bad sampling.

Messier-16

I'm not sure if I'm understanding this correctly, but it's interesting how we have to do this resampling for both increasing and decreasing resolution. For example, if I make the triangle smaller, in the limit, I would get a very jagged triangle. If I make it bigger, then from far away it will look great. But close up, it will once again look jagged the same way a low-res version will look jagged at any distance...

Is that right?

You must be enrolled in the course to comment