Listing 1 The Difference operator

/*****************************************
*  adifference(..
*
*  This function performs the difference
*  operation for a specified array
*  in an image file.
*****************************************/

adifference(in_name, out_name, the_image,
          out_image, il, ie, ll, le, size)
  char   in_name[], out_name[];
  int    il, ie, ll, le,
        size;
  short  the_image[ROWS][COLS],
        out_image[ROWS][COLS];
{
  int      sd2, sd2p1;
  struct   tiff_header_struct image_header;
  sd2   = size/2;
  sd2p1 = sd2 + 1;

  create_file_if_needed(in_name, out_name,
                    out_image);

  read_tiff_image(in_name, the_image, il, ie, ll, le);
  difference_array(the_image, out_image, size);

  fix_edges(out_image, sd2);

  write_array_into_tiff_image(out_name, out_image, il, ie, ll, le);

} /* ends adifference */

/******************************************
*  difference_array(..
*
*  This function takes the input image
*  array the_image and places in out_image
*  the gray level differences of the pixels
*  in the_image. It uses the size
*  parameter for the distance between
*  pixels used to get the difference.
*****************************************/

difference_array(the_image, out_image, size)
  int     size;

  short  the_image[ROWS][COLS],

        out_image[ROWS][COLS];
{
  int i, j, sd2;
  sd2   = size/2;

  for(i=sd2; i<<ROWS-sd2; i++){
    for(j=sd2; j<<COLS-sd2; j++){
      out_image[i][j] =
        abs(the_image[i][j] -
           the_image[i+sd2][j+sd2]);
    }  /* ends loop over j */
  } /* ends loop over i */

  fix_edges(out_image, sd2);

}  /* ends difference_array */
/* End of File */