Page 122 -
P. 122

3.2 Linear filtering                                                                    101















                          zero                  wrap                  clamp                 mirror










                       blurred zero        normalized zero         blurred clamp         blurred mirror
               Figure 3.13 Border padding (top row) and the results of blurring the padded image (bottom row). The normalized
               zero image is the result of dividing (normalizing) the blurred zero-padded RGBA image by its corresponding soft
               alpha value.


               where the (sparse) H matrix contains the convolution kernels. Figure 3.12 shows how a
               one-dimensional convolution can be represented in matrix-vector form.

               Padding (border effects)

               The astute reader will notice that the matrix multiply shown in Figure 3.12 suffers from
               boundary effects, i.e., the results of filtering the image in this form will lead to a darkening of
               the corner pixels. This is because the original image is effectively being padded with 0 values
               wherever the convolution kernel extends beyond the original image boundaries.
                  To compensate for this, a number of alternative padding or extension modes have been
               developed (Figure 3.13):

                  • zero: set all pixels outside the source image to 0 (a good choice for alpha-matted cutout
                    images);

                  • constant (border color): set all pixels outside the source image to a specified border
                    value;

                  • clamp (replicate or clamp to edge): repeat edge pixels indefinitely;

                  • (cyclic) wrap (repeat or tile): loop “around” the image in a “toroidal” configuration;

                  • mirror: reflect pixels across the image edge;

                  • extend: extend the signal by subtracting the mirrored version of the signal from the
                    edge pixel value.
   117   118   119   120   121   122   123   124   125   126   127