Figure 1: Halftoning Algorithm

Define:

     I(R,C) - input image with R rows and C columns
     Ep(m,n) - sum of the errors propogated to position (m,n) due
         to prior assignments
     Eg(m,n) - the total error generated at position (m,n).
     C(i,j) - the error distribution function with I rows and J
         columns


1.  Set Ep(m,n) = Eg(m,n) = 0 for R rows and C columns 

2.  loop m=1,R 

     3.  loop n=1,C

         4.  Calculate the total propogated error at (m,n) due to
              prior assignments

              
              Equation 2

         5.  Sum the current pixel value and the total propogated
              error:  T = I(m,n) + Ep(m,n)

         6. IF T > threshold
              THEN do steps 7. and 8.
              ELSE do steps 9. and 10.

              7.  Set pixel (m,n) on

              8.  Calculate error generated at current location
                   Eg(m,n) = T - 2*threshold

              9.  Set pixel (m,n) off

              10. Calculate error generated at current location
                   Eg(m,n) = threshold

     3.  end loop over n

2.  end loop over m