Previous | ToC | Next Labs: Error Correction and Compression. Part 2. Math Alive

Vertical Differencing and Averaging


Since images are 2-dimensional, we have to do this averaging and differencing in two dimensions as well. We can first do it within every row, transforming our 256x256 image into two arrays (one of averages, one of differences) of 256x128 entries each; for each of these we can then do the same vertically, so that in the end we have four arrays of 128x128. Here is a simple example:

45 47 101 101
46 46 103 103
47 47 103 101
48 48 55 55

After averaging and differencing within every row:

averages differences
46 101   -2   0
46 103   0   0
47 102   0   2
48 55   0   0

After averaging and differencing in two directions:

horizontal
averages
horizontal
differences
vertical
averages
46 102   -1   0
47.5 78.5   0   1
vertical
differences
0 -2   -2   0
-1 47   0   2

In these four little arrays, the top left one corresponds to averaging in both directions; this array typically has sizeable entries for all pixels. The other three arrays typically have most of their entries very small, and can thus be highly compressed.

Practice
Averaging and Differencing

Try to perform averaging and differencing for the following example:

54 56 22 22
108 108 25 27
99 101 0 2
100 102 10 2

Input the answer and press tab or click in another window. After averaging and differencing within every row:

averages differences

Now perform averaging and differencing within every column:

horizontal
averages
horizontal
differences
vertical
averages
vertical
differences


Previous | ToC | Next Last Modified: August 2008