CS 248: Midterm Solutions

Question 2

2a

Grader: Maneesh

C = Cb UNDER Cf. As many of you realized, the UNDER operator is almost the same as the OVER operator except the operands are reversed. Thus the answer for the first part of this question was:

C = AfCf + (1-Af)AbCf

For the second part of this question you must compute A1 = Ab UNDER AF and A2 = Af UNDER Ab and check if they are the same.

A1 = Af + (1-Af)Ab = Af + Ab - AfAb

A2 = Ab + (1-Ab)Af = Ab + Af - AbAf

If you manipulate these equations a bit you will realize that they are equal. This means that given a fragment F and a fragment B the alpha value of B UNDER F is the same as F UNDER B. That is the percentage of the pixel covered is the same in either case as we would expect.

Many people wrote the correct equations for A1 and A2 but thought they were not equal. Also if you defined UNDER incorrectly but correctly determined whether A1 = A2 or not you still got 1 point.


2b

Grader: Matt A number of answers were possible here. In general, points were marked off if some idea of why wasn't given for these reasons. For example "compositing operations are more efficient" didn't get full credit without a little bit of further explination.

 

Many people answered that an advantage of premultiplied alpha is that it can easily be converted to non premultiplied alpha. This is true, but it isn't an advantage of premultiplied alpha per se.

 


2c

Grader: James This question was about the right way to interpolate pixel colors. Some points were allocated for understanding what interpolation is, and realizing that in this particular case bilinear interpolation reduces to averaging the four corners since the desired new pixel position is exactly in the middle. The main part of this question asked you to realize that seperately interpolating RGBA color channels without addressing the premultiplied alpha or non-premultiplied alpha question is naive. You do not get the same results in both cases. The correct answer depends on exactly the effect you are trying to
achieve, but let me argue for the case of using premultiplied alpha. Lets do an example in 1D. Suppose we have non-premultiplied values for a red point (1,0,0,1) and a transparent blue point (0,0,1,0). What should be the color in the middle. Since the transparent blue point is not contributing any color (its transparent), you might think there should be no blue in the final answer. If we average these we get (.5,0,.5,.5). A half transparent magenta point. Hmm.. not good. In the case of premultiplied alpha we would have a half transparent red point (.5,0,0,.5). This is  closer to intuition. Another way to think of this is in terms of pixel coverage, as in the Porter/Duff paper. This also leads to using premultiplied alpha. You can of course work out the math in either case, it's just that using the wrong storage method, can cause a lot of extra multiplies and divides by alpha to come to the answer you desire. Part of this question was about picking the storage method that matches your desired interpolation behavior to greatly increases efficiency.