Previous Table of Contents Next


Running Computations

This is the chapter’s final topic and sets the stage for the following chapter. It provides an introduction to the following imaging concepts:

These three concepts share a common concept—running calculations.

Running Calculation Overview

Consider the following number sequence:

0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8
2, 2, 4, 4, 6, 6, 8, 8, 8, 8
6, 4, 2, 2, 2
8, 8, 8, 2, 2, 2
8, 8, 8, 4, 4, 4
8, 8, 8, 6, 6, 6
8, 6, 4, 2, 0
8, 8, 8, 7, 6, 5, 4, 3, 2, 1, 0

Rather than look at numbers, it’s easier to look at a chart that shows the number pattern (Figure 11-3).

 14 |------------------------------------------------------------ | 14
 13 |------------------------------------------------------------ | 13
 12 |------------------------------------------------------------ | 12
 11 |------------------------------------------------------------ | 11
 10 |------------------------------------------------------------ | 10
  9 |------------------------------------------------------------ | 9
  8 |--------***------****-----***---***---***---*----***-------- | 8
  7 |-------****------****-----***---***---***---*----****------- | 7
  6 |------*****----*******----***---***---********---*****------ | 6
  5 |-----******----*******----***---***---********---******----- | 5
  4 |----*******--**********---***---***************--*******---- | 4
  3 |---********--**********---***---***************--********--- | 3
  2 |--**********************************************-*********-- | 2
  1 |-***********************************************-**********- | 1
  0
+ ------------------------------------------------------------  +
0
Input:012345678882244668888642228882228884448886668642088876543210
============================================================

Figure 11-3: Sample number sequence

Now, the number sequence has a shape. From left to right it:

Smoothing

Smoothing removes high frequency variations using averaging techniques. Remember the Wedge’s small choppy wave? To remove it, leaving the large lumbering wave essentially intact, use smoothing. Let’s see how it works with our number sequence.

First, image processing operations typically receive digital image input number sequences which processes use to derive output sequences. Processing usually leaves the original data intact as it produces derived sequences—important because subsequent calculations often reference the original data as we’ll soon see.

Second, if smoothing uses averaging, one salient question is, What kind of averaging? In our first example, we generate an averaging curve by adding three adjacent sequence values and dividing the sum by three using integer arithmetic, generating an arithmetic mean (average). This mean value is output at the middle number’s location in the output curve.

For example, the first three numbers, 0, 1, and 2, add up to 3. Dividing by 3 produces 1. Therefore the middle input sequence number with a value of 1 has an output point value of 1. In the case of the sequence numbers 8, 4, and 4, their sum is 16 and dividing by 3 using integer arithmetic produces 5. So, the middle input number with a value of 4 has an output value of 5. If we replaced the 4 with a 5 in the input sequence, the next calculation would incorrectly use the 5 instead of the correct value—4.

This approach works for interior sequence numbers but fails for the starting and ending values, which both have a zero value. In this instance, we use the end points twice in the sum before dividing the sum by 3. This approach is purely a matter of convenience—other strategies work.

Now consider the output curve using this averaging scheme (Figure 11-4 on the following page):

  14 |------------------------------------------------------------ | 14
  13 |------------------------------------------------------------ | 13
  12 |------------------------------------------------------------ | 12
  11 |------------------------------------------------------------ | 11
  10 |------------------------------------------------------------ | 10
   9 |------------------------------------------------------------ | 9
   8 |---------*--------**-------*-----*-----*----------*--------- | 8
   7 |-------***-------****------*-----*-----**---------***------- | 7
   6 |------*****-----******----***---***---********----****------ | 6
   5 |-----******----*******----***---****-*********---******----- | 5
   4 |----********--*********--*****-****************--*******---- | 4
   3 |---*********-**********--*****-****************-*********--- | 3
   2 |--********************************************************-- | 2
   1 |-**********************************************************- | 1
   0
+------------------------------------------------------------+
0
Input:012345678882244668888642228882228884448886668642088876543210

========-=-+=-=-=-==-====+-=-+=+-=-+=+-=-===-===+-=-========

Figure 11-4: Smoothing 1/3 [+1,+1,+1] output array

The figure’s title indicates we use three input points to calculate an output value. We multiply each input point’s value by +1 and then add, dividing the sum by 3 using integer arithmetic. The result is the output value for the center sequence number. The notation 1/3 [+1, +1, +1] is referred to as the process’s filter kernel or set of weighting coefficients. A filter kernel nearly always uses an odd number of values symmetrically surrounding a center point.


Previous Table of Contents Next