## NAME

         convolve_filter - convolves an image with a filter kernel.

## SYNOPSIS

          #include "CVIPtools.h"
          #include "CVIPimage.h"
          #include "CVIPdef.h"
          #include "CVIPfs.h"
          #include "CVIPmatrix.h"

          Image *convolve_filter(Image *imageP, Matrix *filP)

          <imageP> - pointer to an Image
          <filP> - pointer to a Matrix containing the kernel
                   to be convolved with <imageP>

## PATH

          $CVIPHOME/SPATIALFILTER/spatial_tools.c

## DESCRIPTION

         The convolve function performs a spatial convolution  of  an
         input image with an input matrix. The input image must be of
         type CVIP_BYTE or CVIP_SHORT.  The filter matrix must be  of
         type  CVIP_FLOAT.  The  output  image  returned  is  of type
         CVIP_SHORT.

         This function assumes mirror (DCT) symmetry  on  edges,  but
         does NOT flip the convolution mask before use.

         A related function, get_default_filter, can be used to  pro-
         vide the kernel <filP>.

## TYPES AND CONSTANTS

         None

## RETURN VALUES

         Returns pointer to output image.

## EXAMPLE

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

          void main()
          {
          Image *cvipImage,*cvipImage1;
          IMAGE_FORMAT format;
          char *inputfile,*outputfile;
          Matrix *mat;
          int i,j;
          unsigned int row=3;
          unsigned int col=3;

          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);
          mat=new_Matrix(row,col,CVIP_FLOAT,REAL);
          if(mat==NULL)
                 printf("NULL");
          /*Provides the filter kernel*/
          for(i=0;i<3;i++)
           for(j=0;j<3;j++)
                 ((float **)(mat->rptr))[i][j]=0.5;
          /*The following call convolves the image with the
          lowpass filter kernel got by the get_default_filter */
          cvipImage1 = (Image *)convolve_filter(cvipImage,mat);
          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);
          }

## BUGS

         None at this time

## SEE ALSO

         new_Matrix

## AUTHOR

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