home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_02 / 1102066a < prev    next >
Text File  |  1992-12-13  |  1KB  |  37 lines

  1.       /********************************************
  2.       * 
  3.       *   smooth_histogram(...        
  4.       * 
  5.       *   This function smoothes the input histogram
  6.       *   and returns it.  It uses a simple averaging
  7.       *   scheme where each point in the histogram
  8.       *   is replaced by the average of itself and
  9.       *   the two points on either side of it.
  10.       * 
  11.       *********************************************/
  12.  
  13. smooth_histogram(histogram)
  14.    unsigned long histogram[];
  15. {
  16.    int i;
  17.    unsigned long new_hist[GRAY_LEVELS+1];
  18.  
  19.    zero_histogram(new_hist);
  20.  
  21.    new_hist[0] = (histogram[0] + histogram[1])/2;
  22.    new_hist[GRAY_LEVELS] =
  23.       (histogram[GRAY_LEVELS] + 
  24.        histogram[GRAY_LEVELS-1])/2;
  25.  
  26.    for(i=1; i<GRAY_LEVELS; i++){
  27.       new_hist[i] = (histogram[i-1] +
  28.                      histogram[i]   +
  29.                      histogram[i+1])/3;
  30.    }
  31.  
  32.    for(i=0; i<=GRAY_LEVELS; i++)
  33.       histogram[i] = new_hist[i];
  34.  
  35. }  /* ends smooth_histogram */
  36.  
  37.