Cornell CS 465 Fall 2003

Solutions for Homework 1b (discussion questions)
------------------------------------------------

1. Sketch graphs of the brush's alpha channel along a line through the
   brush center for p = 0.5, 1.0, and 2.0.  Pay attention to continuity
   and zero crossings.

(see sketch)


2. The result of painting on the top layer should be the same as painting in
   the bottom layer.  What property of Porter and Duff's over operation
   ensures this?

Because this question was universally misinterpreted, despite my attempts to
clarify it after the fact, we did not grade it.  Here is the intended
solution:

When you paint a stroke onto the top layer, you are doing many compositing
operations.  For example, suppose there were three mouse motion events in a
particular stroke; then:

  top = br_3 over (br_2 over (br_1 over transparent))

and what you see on the screen is

  top over bottom = 
      (br_3 over (br_2 over (br_1 over transparent))) over bottom 

On the other hand, if you paint straight on the bottom layer with the same
stroke you get:

  bottom = br_3 over (br_2 over (br_1 over bottom))

and what you see on the screen is

  top over bottom =
      transparent over (br_3 over (br_2 over (br_1 over bottom)))

Given that a transparent image acts as the identity for the over operation,
the two results are

  paint on top:
    (br_3 over (br_2 over br_1)) over bottom 

  paint on bottom:
    br_3 over (br_2 over (br_1 over bottom))

The reason these are equivalent is the associative property.


3. Suppose you start with the top layer completely transparent (this is its
   initial condition), put down exactly one brush image by clicking without
   dragging, then do exactly one erase operation by selecting the erase tool
   and clicking without dragging in exactly the same location.

   a. Does this erase the paint completely?  Explain.

No, it does not.  The eraser completely erases only at the very center;
elsewhere it partially erases the partially painted pixels.

   b. Ignoring discretization effects due to finite resolution and precision,
      sketch a graph of the contents of the top layer's alpha channel after
      these operations, along a line through the brush center. Pay attention
      to continuity and zero crossings.

I didn't specify what p was for this problem so I'll use p = 1, which is
particularly easy to analyze.

The painting operation on a transparent background just leaves a copy of the
brush:

  alpha_bg(x) = 1 - |x|/R

(I left out the max and am assuming we know just to look at -R < x < R.)

The erasing operation scales that value by 1 - alpha_brush:

  alpha_bg(x) = (1 - alpha_brush) alpha_bg
              = (|x|/R) (1 - |x|/R)

To simplify, looking at just the right side and letting R be 1,

  alpha_bg(x) = x (1 - x)

(see sketch for graph)