NAME

     edge_detect_filter - perform edge detection

SYNOPSIS

      #include "CVIPimage.h"
      #include "CVIPdef.h"
      #include "CVIPfs.h"
      #include <limits.h>

     Image *edge_detect_filter(Image *imageP,  int  program,  int
     mask_choice,  int mask_size, int keep_dc, int threshold, int
     threshold1, int thresh,int thr)

      <imageP> - pointer to an Image
      <program> - desired edge detector
      <mask_choice> - type of smoothing filter
      <mask_size> - Laplacian mask (1 or 2)
      <keep_dc> - 0 (no) or 1 (yes)
      <threshold> - value for binary threshold
      <threshold1> - Frei-Chen projection method
      <thresh> - Frei-Chen projection threshold
      <thr> - angle (in radians) for Frei-Chen edge
              or line projection threshold

PATH

     $CVIPHOME/SPATIALFILTER/edge_detect.c

DESCRIPTION

     This function applies various edge detection  algorithms  to
     <imageP>.    The   difference   between  this  function  and
     edge_detect_setup  is  that  this  function  gets  all   the
     required  input  from the parameters, instead from the stan-
     dard input.  Edge detectors available for <program> are:
                            EDGE_KIRSCH
                            EDGE_ROBINSON
                            EDGE_PYRAMID
                            EDGE_LAPLACIAN
                            EDGE_SOBEL
                            EDGE_ROBERTS
                            EDGE_PREWITT
                            EDGE_FREI

     If a smoothing filter is desired as  a  preprocessing  step,
     set <mask_choice> to:
                       1 = Gaussian blur
                       2 = generic lowpass 1
                       3 = generic lowpass 2
                       4 = neighborhood average

     For <mask_size>:
     If you select EDGE_LAPLACIAN, set <mask_size>:
                    1 = [0,-1,0; -1,4,-1; 0,-1,0]
                    2 = [1,-2,1; -2,4,-2; 1,-2,1]

     If you select EDGE_SOBEL, set <mask_size>:
     kernel size (3,5,or 7)

     If you select EDGE_ROBERTS, set <mask_size>:
     1 = G[f(x,y)]=[f(x,y)-f(x+1,y)]^2+[f(x,y)-f(x,y+1)]^2}^1/2)
     2 = G[f(x,y)]=|f(x,y)-f(x+1,y+1)|+|f(x+1,y)-f(x,y+1)|

     If you select EDGE_PREWITT, set <mask_size> to desired
     kernel size

     If you select EDGE_FREI, you  need  to  set  the  following:
     <threshold1> :
                    1 = Project onto edge subspace
                    2 = Project onto line subspace
                    3 = Show complete projection

     <thresh> :
                 1 = Set threshold on edge projection
                 2 = Set threshold on line projection
                 3 = Smallest angle between the above

     If <thresh> = 1 or 2, set <thr> = threshold angle (radians)

     NOTE: FOR ALL OF THE ABOVE PARAMETERS, USE THE VALUE -1  FOR
     ANY PARAMETER NOT NEEDED.

TYPES AND CONSTANTS

     None

RETURN VALUES

     An edge-detected image

HISTORY

     History information recorded: None

EXAMPLE

      #include <CVIPtoolkit.h>
      #include <CVIPimage.h>
      #include <CVIPdef.h>
      #include <CVIPspfltr.h>
      #include <CVIPconvert.h>
      #include <CVIPview.h>
      #define VIEWER "picture"
      #define VIDEO_APP "SunVideo &"

      void main()
      {
      Image *cvipImage;
      Image *cvipImage4;
      IMAGE_FORMAT format;
      char *inputfile,*outputfile;

      setDisplay_Image(VIEWER, "Default");

      print_CVIP("\n\t\tEnter the  Input File Name:  ");
      inputfile =(char *) getString_CVIP();
      format = getFormat_CVIP(inputfile);
      cvipImage = read_Image(inputfile, 1);
      view_Image(cvipImage, inputfile);
      free(inputfile);
      cast_Image(cvipImage,CVIP_SHORT);
      /* the following function performs EDGE_FREI edge
      detection.Projection is done onto the edge subspace
      with the threshold angle equal to 1.05 radians */
      cvipImage4=edge_detect_filter(cvipImage,EDGE_FREI,-1,
      -1,-1,-1,1,1,1.05);
      print_CVIP("\n\t\tEnter the Output File Name:  ");
      outputfile = getString_CVIP();
      view_Image(cvipImage4,outputfile);
      write_Image(cvipImage4,outputfile,CVIP_NO,CVIP_NO,format,1);
      free(outputfile);
      }

      #include <CVIPtoolkit.h>
      #include <CVIPimage.h>
      #include <CVIPdef.h>
      #include <CVIPspfltr.h>
      #include <CVIPconvert.h>
      #include <CVIPview.h>
      #define VIEWER "picture"
      #define VIDEO_APP "SunVideo &"

      void main()
      {
      Image *cvipImage;
      IMAGE_FORMAT format;
      char *inputfile,*outputfile;
      Image *cvipImage1;
      Image *cvipImage2;
      Image *cvipImage3;

      (void) setDisplay_Image(VIEWER);
      print_CVIP("\n\t\tEnter the  Input File Name:  ");
      inputfile =(char *) getString_CVIP();
      format = getFormat_CVIP(inputfile);
      cvipImage = read_Image(inputfile, 1);
      view_Image(cvipImage, inputfile);
      cast_Image(cvipImage,CVIP_SHORT);
      /* for all the edge detecting functions there is no
      preprocessing step */
      /* Laplacian edge detection */
      /* the mask is [0,-1,0; -1,4,-1; 0,-1,0]*/
      cvipImage1=edge_detect_filter(cvipImage,EDGE_LAPLACIAN,
      -1,1,-1,-1,-1,-1,-1);
      print_CVIP("\n\t\tEnter the Output File Name:  ");
      outputfile = getString_CVIP();
      view_Image(cvipImage1,outputfile);
      write_Image(cvipImage1,outputfile,CVIP_NO,CVIP_NO,format,1);
      free(outputfile);

      /* Sobel edge detection */
      /* mask size is 3 */
      cvipImage = read_Image(inputfile, 1);
      cast_Image(cvipImage,CVIP_SHORT);
      cvipImage2=edge_detect_filter(cvipImage,EDGE_SOBEL,-1,3,
      -1,-1,-1,-1,-1);
      print_CVIP("\n\t\tEnter the Output File Name:  ");
      outputfile = getString_CVIP();
      view_Image(cvipImage2,outputfile);
      write_Image(cvipImage2,outputfile,CVIP_NO,CVIP_NO,format,1);
      free(outputfile);

      /* Roberts edge detection */
      /* type -1:Regular gradient
             G[f(x,y)] = {[f(x,y)-f(x+1,y)]^2 +
                             [f(x,y)-f(x,y+1)]^2}^1/2 */
      cvipImage = read_Image(inputfile, 1);
      cast_Image(cvipImage,CVIP_SHORT);
      cvipImage3=edge_detect_filter(cvipImage,EDGE_ROBERTS,
      -1,1,-1,-1,-1,-1,-1);
      print_CVIP("\n\t\tEnter the Output File Name:  ");
      outputfile = getString_CVIP();
      view_Image(cvipImage3,outputfile);
      write_Image(cvipImage3,outputfile,CVIP_NO,CVIP_NO,format,1);
      free(outputfile);
      free(inputfile);
      }

SEE ALSO

     libspatialfiltr, edge_detect_setup

AUTHOR

     Copyright (C) 1996 SIUE - by Scott Umbaugh, Greg Hance,  and
     Kun Luo.