home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 343_01 / edge.c < prev    next >
Text File  |  1991-04-20  |  18KB  |  743 lines

  1.  
  2.        /***********************************************
  3.        *
  4.        *       file d:\cips\edge.c
  5.        *
  6.        *       Functions: This file contains
  7.        *          detect_edges
  8.        *          setup_masks
  9.        *          get_edge_options
  10.        *          perform_convolution
  11.        *          quick_edge
  12.        *          fix_edges
  13.        *
  14.        *       Purpose:
  15.        *          These functions implement several
  16.        *          types of basic edge detection.
  17.        *
  18.        *       External Calls:
  19.        *          wtiff.c - does_not_exist
  20.        *                    round_off_image_size
  21.        *                    create_allocate_tiff_file
  22.        *                    write_array_into_tiff_image
  23.        *          tiff.c - read_tiff_header
  24.        *          rtiff.c - read_tiff_image
  25.        *          numcvrt.c - get_integer
  26.        *
  27.        *
  28.        *       Modifications:
  29.        *          27 January 1991 - created
  30.        *
  31.        *************************************************/
  32.  
  33. #include "d:\cips\cips.h"
  34.  
  35.  
  36.  
  37.  
  38.  
  39. short quick_mask[3][3] =  {
  40.        {-1,  0, -1},
  41.        { 0,  4,  0},
  42.        {-1,  0, -1} };
  43.  
  44.  
  45.    /***************************
  46.    *
  47.    *   Directions for the masks
  48.    *  3 2 1
  49.    *  4 x 0
  50.    *  5 6 7
  51.    *
  52.    ****************************/
  53.  
  54.    /* masks for kirsch operator */
  55. short kirsch_mask_0[3][3] =  {
  56.        { 5,  5,  5},
  57.        {-3,  0, -3},
  58.        {-3, -3, -3} };
  59.  
  60. short kirsch_mask_1[3][3] =  {
  61.        {-3,  5,  5},
  62.        {-3,  0,  5},
  63.        {-3, -3, -3} };
  64.  
  65. short kirsch_mask_2[3][3] =  {
  66.        {-3, -3,  5},
  67.        {-3,  0,  5},
  68.        {-3, -3,  5} };
  69.  
  70. short kirsch_mask_3[3][3] =  {
  71.        {-3, -3, -3},
  72.        {-3,  0,  5},
  73.        {-3,  5,  5} };
  74.  
  75. short kirsch_mask_4[3][3] =  {
  76.        {-3, -3, -3},
  77.        {-3,  0, -3},
  78.        { 5,  5,  5} };
  79.  
  80. short kirsch_mask_5[3][3] =  {
  81.        {-3, -3, -3},
  82.        { 5,  0, -3},
  83.        { 5,  5, -3} };
  84.  
  85. short kirsch_mask_6[3][3] =  {
  86.        { 5, -3, -3},
  87.        { 5,  0, -3},
  88.        { 5, -3, -3} };
  89.  
  90. short kirsch_mask_7[3][3] =  {
  91.        { 5,  5, -3},
  92.        { 5,  0, -3},
  93.        {-3, -3, -3} };
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.    /* masks for prewitt operator */
  101.  
  102. short prewitt_mask_0[3][3] =  {
  103.        { 1,  1,  1},
  104.        { 1, -2,  1},
  105.        {-1, -1, -1} };
  106.  
  107. short prewitt_mask_1[3][3] =  {
  108.        { 1,  1,  1},
  109.        { 1, -2, -1},
  110.        { 1, -1, -1} };
  111.  
  112. short prewitt_mask_2[3][3] =  {
  113.        { 1,  1, -1},
  114.        { 1, -2, -1},
  115.        { 1,  1, -1} };
  116.  
  117. short prewitt_mask_3[3][3] =  {
  118.        { 1, -1, -1},
  119.        { 1, -2, -1},
  120.        { 1,  1,  1} };
  121.  
  122. short prewitt_mask_4[3][3] =  {
  123.        {-1, -1, -1},
  124.        { 1, -2,  1},
  125.        { 1,  1,  1} };
  126.  
  127. short prewitt_mask_5[3][3] =  {
  128.        {-1, -1,  1},
  129.        {-1, -2,  1},
  130.        { 1,  1,  1} };
  131.  
  132. short prewitt_mask_6[3][3] =  {
  133.        {-1,  1,  1},
  134.        {-1, -2,  1},
  135.        {-1,  1,  1} };
  136.  
  137. short prewitt_mask_7[3][3] =  {
  138.        { 1,  1,  1},
  139.        {-1, -2,  1},
  140.        {-1, -1,  1} };
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.    /* masks for sobel operator */
  148.  
  149. short sobel_mask_0[3][3] =  {
  150.        { 1,  2,  1},
  151.        { 0,  0,  0},
  152.        {-1, -2, -1} };
  153.  
  154. short sobel_mask_1[3][3] =  {
  155.        { 2,  1,  0},
  156.        { 1,  0, -1},
  157.        { 0, -1, -2} };
  158.  
  159. short sobel_mask_2[3][3] =  {
  160.        { 1,  0, -1},
  161.        { 2,  0, -2},
  162.        { 1,  0, -1} };
  163. short sobel_mask_3[3][3] =  {
  164.        { 0, -1, -2},
  165.        { 1,  0, -1},
  166.        { 2,  1,  0} };
  167.  
  168. short sobel_mask_4[3][3] =  {
  169.        {-1, -2, -1},
  170.        { 0,  0,  0},
  171.        { 1,  2,  1} };
  172.  
  173. short sobel_mask_5[3][3] =  {
  174.        {-2, -1,  0},
  175.        {-1,  0,  1},
  176.        { 0,  1,  2} };
  177.  
  178. short sobel_mask_6[3][3] =  {
  179.        {-1,  0,  1},
  180.        {-2,  0,  2},
  181.        {-1,  0,  1} };
  182.  
  183. short sobel_mask_7[3][3] =  {
  184.        { 0,  1,  2},
  185.        {-1,  0,  1},
  186.        {-2, -1,  0} };
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.   /**************************************************
  194.   *
  195.   *   detect_edges(...
  196.   *
  197.   *   This function detects edges in an area of one
  198.   *   image and sends the result to another image
  199.   *   on disk.  It reads the input image from disk,
  200.   *   calls a convolution function, and then writes
  201.   *   the result out to disk.  If needed, it
  202.   *   allocates space on disk for the output image.
  203.   *
  204.   ***************************************************/
  205.  
  206.  
  207.  
  208.  
  209. detect_edges(in_name, out_name, the_image, out_image,
  210.              il, ie, ll, le, detect_type, threshold,
  211.              high)
  212.    char   in_name[], out_name[];
  213.    int    detect_type, high, il, ie,
  214.           ll, le, threshold;
  215.    short  the_image[ROWS][COLS], out_image[ROWS][COLS];
  216.  
  217. {
  218.    int    i, j, k, length, width;
  219.    struct tiff_header_struct image_header;
  220.  
  221.  
  222.    if(does_not_exist(out_name)){
  223.       read_tiff_header(in_name, &image_header);
  224.       round_off_image_size(&image_header,
  225.                            &length, &width);
  226.       image_header.image_length = length*ROWS;
  227.       image_header.image_width  = width*COLS;
  228.       create_allocate_tiff_file(out_name, &image_header,
  229.                                 out_image);
  230.    }  /* ends if does_not_exist */
  231.    read_tiff_image(in_name, the_image, il, ie, ll, le);
  232.  
  233.    read_tiff_header(in_name, &image_header);
  234.  
  235.    perform_convolution(the_image, out_image,
  236.                        detect_type, threshold,
  237.                        &image_header, high);
  238.  
  239.    fix_edges(out_image, 1);
  240.  
  241.    write_array_into_tiff_image(out_name, out_image,
  242.                                il, ie, ll, le);
  243. }  /* ends detect_edges */
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.      /**********************************************************
  252.      *
  253.      *   perform_convolution(...
  254.      *
  255.      *   This function performs convolution between the input
  256.      *   image and 8 3x3 masks.  The result is placed in
  257.      *   the out_image.
  258.      *
  259.      ********************************************************/
  260.  
  261. perform_convolution(image, out_image,
  262.                     detect_type, threshold,
  263.                     image_header, high)
  264.    short image[ROWS][COLS],
  265.          out_image[ROWS][COLS];
  266.    int   detect_type, high, threshold;
  267.    struct tiff_header_struct *image_header;
  268. {
  269.  
  270.    int a,
  271.        b,
  272.        i,
  273.        is_present,
  274.        j,
  275.        sum;
  276.  
  277.    short  mask_0[3][3],
  278.           mask_1[3][3],
  279.           mask_2[3][3],
  280.           mask_3[3][3],
  281.           mask_4[3][3],
  282.           mask_5[3][3],
  283.           mask_6[3][3],
  284.           mask_7[3][3],
  285.           max,
  286.           min,
  287.           new_hi,
  288.           new_low;
  289.  
  290.  
  291.    setup_masks(detect_type, mask_0, mask_1,
  292.                mask_2, mask_3, mask_4, mask_5,
  293.                mask_6, mask_7);
  294.  
  295.    new_hi  = 250;
  296.    new_low = 16;
  297.    if(image_header->bits_per_pixel == 4){
  298.        new_hi  = 10;
  299.        new_low = 3;
  300.    }
  301.  
  302.    min = 0;
  303.    max = 255;
  304.    if(image_header->bits_per_pixel == 4)
  305.       max = 16;
  306.  
  307.      /* clear output image array */
  308.    for(i=0; i<ROWS; i++)
  309.       for(j=0; j<COLS; j++)
  310.          out_image[i][j] = 0;
  311.  
  312.    printf("\n ");
  313.  
  314.    for(i=1; i<ROWS-1; i++){
  315.       if( (i%10) == 0) printf("%3d", i);
  316.       for(j=1; j<COLS-1; j++){
  317.  
  318.  
  319.          /* Convolve for all 8 directions */
  320.  
  321.          /* 0 direction */
  322.  
  323.       sum = 0;
  324.       for(a=-1; a<2; a++){
  325.          for(b=-1; b<2; b++){
  326.             sum = sum + image[i+a][j+b] *
  327.                   mask_0[a+1][b+1];
  328.          }
  329.       }
  330.          if(sum > max) sum = max;
  331.          if(sum < 0)   sum = 0;
  332.       out_image[i][j]   = sum;
  333.  
  334.  
  335.          /* 1 direction */
  336.  
  337.       sum = 0;
  338.       for(a=-1; a<2; a++){
  339.          for(b=-1; b<2; b++){
  340.             sum = sum + image[i+a][j+b] * mask_1[a+1][b+1];
  341.          }
  342.       }
  343.          if(sum > max) sum = max;
  344.          if(sum < 0)   sum = 0;
  345.       out_image[i][j]   = sum;
  346.  
  347.  
  348.          /* 2 direction */
  349.  
  350.       sum = 0;
  351.       for(a=-1; a<2; a++){
  352.          for(b=-1; b<2; b++){
  353.             sum = sum + image[i+a][j+b] * mask_2[a+1][b+1];
  354.          }
  355.       }
  356.          if(sum > max) sum = max;
  357.          if(sum < 0)   sum = 0;
  358.       out_image[i][j]   = sum;
  359.  
  360.  
  361.          /* 3 direction */
  362.  
  363.       sum = 0;
  364.       for(a=-1; a<2; a++){
  365.          for(b=-1; b<2; b++){
  366.             sum = sum + image[i+a][j+b] * mask_3[a+1][b+1];
  367.          }
  368.       }
  369.          if(sum > max) sum = max;
  370.          if(sum < 0)   sum = 0;
  371.       out_image[i][j]   = sum;
  372.  
  373.  
  374.          /* 4 direction */
  375.  
  376.       sum = 0;
  377.       for(a=-1; a<2; a++){
  378.          for(b=-1; b<2; b++){
  379.             sum = sum + image[i+a][j+b] * mask_4[a+1][b+1];
  380.          }
  381.       }
  382.          if(sum > max) sum = max;
  383.          if(sum < 0)   sum = 0;
  384.       out_image[i][j]   = sum;
  385.  
  386.  
  387.          /* 5 direction */
  388.  
  389.       sum = 0;
  390.       for(a=-1; a<2; a++){
  391.          for(b=-1; b<2; b++){
  392.             sum = sum + image[i+a][j+b] * mask_5[a+1][b+1];
  393.          }
  394.       }
  395.          if(sum > max) sum = max;
  396.          if(sum < 0)   sum = 0;
  397.       out_image[i][j]   = sum;
  398.  
  399.  
  400.          /* 6 direction */
  401.       sum = 0;
  402.       for(a=-1; a<2; a++){
  403.          for(b=-1; b<2; b++){
  404.             sum = sum + image[i+a][j+b] * mask_6[a+1][b+1];
  405.          }
  406.       }
  407.          if(sum > max) sum = max;
  408.          if(sum < 0)   sum = 0;
  409.       out_image[i][j]   = sum;
  410.  
  411.  
  412.          /* 7 direction */
  413.  
  414.       sum = 0;
  415.       for(a=-1; a<2; a++){
  416.          for(b=-1; b<2; b++){
  417.             sum = sum + image[i+a][j+b] * mask_7[a+1][b+1];
  418.          }
  419.       }
  420.          if(sum > max) sum = max;
  421.          if(sum < 0)   sum = 0;
  422.       out_image[i][j]   = sum;
  423.  
  424.  
  425.       }  /* ends loop over j */
  426.    }  /* ends loop over i */
  427.  
  428.  
  429.      /* if desired, threshold the output image */
  430.    if(threshold == 1){
  431.        for(i=0; i<ROWS; i++){
  432.           for(j=0; j<COLS; j++){
  433.              if(out_image[i][j] > high){
  434.                   out_image[i][j] = new_hi;
  435.              }
  436.              else{
  437.                   out_image[i][j] = new_low;
  438.              }
  439.           }
  440.        }
  441.    }  /* ends if threshold == 1 */
  442.  
  443. }  /* ends perform_convolution */
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.      /*******************************************
  452.      *
  453.      *   quick_edge(...
  454.      *
  455.      *   This function finds edges by using
  456.      *   a single 3x3 mask.
  457.      *
  458.      *******************************************/
  459.  
  460.  
  461. quick_edge(in_name, out_name, the_image, out_image,
  462.              il, ie, ll, le, threshold, high)
  463.    char   in_name[], out_name[];
  464.    int    high, il, ie, ll, le, threshold;
  465.    short  the_image[ROWS][COLS], out_image[ROWS][COLS];
  466.  
  467. {
  468.    int    a, b, i, j, k,
  469.           length, max, new_hi, new_low,
  470.           sum, width;
  471.    struct tiff_header_struct image_header;
  472.  
  473.  
  474.    if(does_not_exist(out_name)){
  475.       printf("\n\n output file does not exist %s", out_name);
  476.       read_tiff_header(in_name, &image_header);
  477.       round_off_image_size(&image_header,
  478.                            &length, &width);
  479.       image_header.image_length = length*ROWS;
  480.       image_header.image_width  = width*COLS;
  481.       create_allocate_tiff_file(out_name, &image_header,
  482.                                 out_image);
  483.    }  /* ends if does_not_exist */
  484.  
  485.    read_tiff_header(in_name, &image_header);
  486.    new_hi  = 250;
  487.    new_low = 16;
  488.    if(image_header.bits_per_pixel == 4){
  489.        new_hi  = 10;
  490.        new_low = 3;
  491.    }
  492.  
  493.    max = 255;
  494.    if(image_header.bits_per_pixel == 4)
  495.       max = 16;
  496.  
  497.  
  498.    read_tiff_image(in_name, the_image, il, ie, ll, le);
  499.  
  500.          /* Do convolution over image array */
  501.    printf("\n");
  502.    for(i=1; i<ROWS-1; i++){
  503.       if( (i%10) == 0) printf("%d ", i);
  504.       for(j=1; j<COLS-1; j++){
  505.          sum = 0;
  506.          for(a=-1; a<2; a++){
  507.             for(b=-1; b<2; b++){
  508.                sum = sum +
  509.                      the_image[i+a][j+b] *
  510.                      quick_mask[a+1][b+1];
  511.             }
  512.          }
  513.          if(sum < 0)   sum = 0;
  514.          if(sum > max) sum = max;
  515.          out_image[i][j]   = sum;
  516.  
  517.       }  /* ends loop over j */
  518.    }  /* ends loop over i */
  519.  
  520.      /* if desired, threshold the output image */
  521.    if(threshold == 1){
  522.        for(i=0; i<ROWS; i++){
  523.           for(j=0; j<COLS; j++){
  524.              if(out_image[i][j] > high){
  525.                   out_image[i][j] = new_hi;
  526.              }
  527.              else{
  528.                   out_image[i][j] = new_low;
  529.              }
  530.           }
  531.        }
  532.    }  /* ends if threshold == 1 */
  533.  
  534.    fix_edges(out_image, 1);
  535.  
  536.    write_array_into_tiff_image(out_name, out_image,
  537.                                il, ie, ll, le);
  538.  
  539. }  /* ends quick_edge */
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.    /***********************************************
  549.     *
  550.     *    setup_masks(...
  551.     *
  552.     *    This function copies the mask values defined
  553.     *    at the top of this file into the mask
  554.     *    arrays mask_0 through mask_7.
  555.     *
  556.     ***********************************************/
  557.  
  558.  
  559.  
  560. setup_masks(detect_type, mask_0, mask_1, mask_2, mask_3,
  561.             mask_4, mask_5, mask_6, mask_7)
  562.    int    detect_type;
  563.    short  mask_0[3][3],
  564.           mask_1[3][3],
  565.           mask_2[3][3],
  566.           mask_3[3][3],
  567.           mask_4[3][3],
  568.           mask_5[3][3],
  569.           mask_6[3][3],
  570.           mask_7[3][3];
  571. {
  572.    int i, j;
  573.  
  574.    if(detect_type == KIRSCH){
  575.       for(i=0; i<3; i++){
  576.         for(j=0; j<3; j++){
  577.           mask_0[i][j] = kirsch_mask_0[i][j];
  578.           mask_1[i][j] = kirsch_mask_1[i][j];
  579.           mask_2[i][j] = kirsch_mask_2[i][j];
  580.           mask_3[i][j] = kirsch_mask_3[i][j];
  581.           mask_4[i][j] = kirsch_mask_4[i][j];
  582.           mask_5[i][j] = kirsch_mask_5[i][j];
  583.           mask_6[i][j] = kirsch_mask_6[i][j];
  584.           mask_7[i][j] = kirsch_mask_7[i][j];
  585.         }
  586.       }
  587.    }  /* ends if detect_type == KIRSCH */
  588.  
  589.  
  590.    if(detect_type == PREWITT){
  591.       for(i=0; i<3; i++){
  592.         for(j=0; j<3; j++){
  593.           mask_0[i][j] = prewitt_mask_0[i][j];
  594.           mask_1[i][j] = prewitt_mask_1[i][j];
  595.           mask_2[i][j] = prewitt_mask_2[i][j];
  596.           mask_3[i][j] = prewitt_mask_3[i][j];
  597.           mask_4[i][j] = prewitt_mask_4[i][j];
  598.           mask_5[i][j] = prewitt_mask_5[i][j];
  599.           mask_6[i][j] = prewitt_mask_6[i][j];
  600.           mask_7[i][j] = prewitt_mask_7[i][j];
  601.         }
  602.       }
  603.    }  /* ends if detect_type == PREWITT */
  604.  
  605.  
  606.    if(detect_type == SOBEL){
  607.       for(i=0; i<3; i++){
  608.         for(j=0; j<3; j++){
  609.           mask_0[i][j] = sobel_mask_0[i][j];
  610.           mask_1[i][j] = sobel_mask_1[i][j];
  611.           mask_2[i][j] = sobel_mask_2[i][j];
  612.           mask_3[i][j] = sobel_mask_3[i][j];
  613.           mask_4[i][j] = sobel_mask_4[i][j];
  614.           mask_5[i][j] = sobel_mask_5[i][j];
  615.           mask_6[i][j] = sobel_mask_6[i][j];
  616.           mask_7[i][j] = sobel_mask_7[i][j];
  617.         }
  618.       }
  619.    }  /* ends if detect_type == SOBEL */
  620.  
  621.  
  622.  
  623. }  /* ends setup_masks */
  624.  
  625.  
  626.  
  627.    /***********************************************
  628.     *
  629.     *    get_edge_options(...
  630.     *
  631.     *    This function queries the user for the
  632.     *    parameters need to perform edge
  633.     *    detection.
  634.     *
  635.     ***********************************************/
  636.  
  637.  
  638. get_edge_options(detect_type, threshold, high, size)
  639.     int *detect_type, *high, *size, *threshold;
  640. {
  641.     int not_finished, response;
  642.     not_finished = 1;
  643.     while(not_finished){
  644.  
  645.       printf("\nThe Edge Detector options are:\n");
  646.       printf("\n\t1.  Type of edge detector is %d", *detect_type);
  647.       printf("\n\t      (recall 1=Prewitt     2=Kirsch");
  648.       printf("\n\t              3=Sobel       4=quick");
  649.       printf("\n\t              5=homogeneity 6=difference");
  650.       printf("\n\t              7=contrast    8=gaussian");
  651.       printf("\n\t2.  Threshold output is %d (0=off 1=on)", *threshold);
  652.       printf("\n\t3.  High threshold is %d", *high);
  653.       printf("\n\t4.  Size is %d (gaussian only)", *size);
  654.       printf("\n\nEnter choice (0 = no change) _\b");
  655.  
  656.  
  657.       get_integer(&response);
  658.  
  659.       if(response == 0){
  660.         not_finished = 0;
  661.       }
  662.  
  663.  
  664.       if(response == 1){
  665.         printf("\n\nEnter type of edge detector");
  666.         printf("\n\t      (recall 1=Prewitt     2=Kirsch");
  667.         printf("\n\t              3=Sobel       4=quick");
  668.         printf("\n\t              5=homogeneity 6=difference");
  669.         printf("\n\t              7=contrast    8=gaussian");
  670.         printf("\n  _\b");
  671.         get_integer(detect_type);
  672.       }
  673.  
  674.       if(response == 2){
  675.         printf("\n\nEnter threshold output (0=off 1=on)");
  676.         printf("\n  _\b");
  677.         get_integer(threshold);
  678.       }
  679.  
  680.       if(response == 3){
  681.         printf("\n\nEnter high threshold");
  682.         printf("\n  _\b");
  683.         get_integer(high);
  684.       }
  685.  
  686.       if(response == 4){
  687.         printf("\n\nEnter size for gaussian (7 or 9)");
  688.         printf("\n  _\b");
  689.         get_integer(size);
  690.       }
  691.     }  /* ends while not_finished */
  692.  
  693. }  /* ends get_edge_options */
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.    /***********************************************
  701.     *
  702.     *    fix_edges(...
  703.     *
  704.     *    This function fixes the edges of an image
  705.     *    array after convolution was performed.
  706.     *    It copies the points near the edge of the
  707.     *    array out to the edge of the array.
  708.     *
  709.     ***********************************************/
  710.  
  711.  
  712.  
  713. fix_edges(im, w)
  714.       int   w;
  715.       short im[ROWS][COLS];
  716. {
  717.    int i, j;
  718.  
  719.  
  720.       /* four corners */
  721.    for(i=w; i>0; i--){
  722.     im[i-1][i-1] = im[i][i];
  723.     im[i-1][COLS-(i-1)] = im[i][COLS-1-(i-1)];
  724.     im[ROWS-(i-1)][i-1] = im[ROWS-1-(i-1)][i];
  725.     im[ROWS-(i-1)][COLS-(i-1)] = im[ROWS-1-(i-1)][COLS-1-(i-1)];
  726.    }  /* ends four corners loop */
  727.  
  728.    for(i=0; i<ROWS; i++){
  729.       for(j=w; j>0; j--){
  730.        im[i][j-1] = im[i][j];
  731.        im[i][COLS-j] = im[i][COLS-j-1];
  732.       }
  733.    }
  734.  
  735.    for(j=0; j<COLS; j++){
  736.       for(i=w; i>0; i--){
  737.        im[i-1][j] = im[i][j];
  738.        im[ROWS-i][j] = im[ROWS-i-1][j];
  739.       }
  740.    }
  741.  
  742. }  /* ends fix_edges */
  743.