NAME

     least_squares - performs least_squares restoration filtering

SYNOPSIS

      #include "CVIPimage.h"
      #include "CVIPxformfilter.h"

     Image  *least_squares(Image  *degr,  Image  *degr_fn,  Image
     *snr_approx, float gamma, int choice, int cutoff)

      <degr> - pointer to the degraded image
      <degr_fn> - pointer to the degradation function
      <snr_approx> - pointer  to  smoothness  criterion  function
     image, P(u,v)
      <gamma> - gamma in least_squares equation.
      <choice> - 1 to let R(u,v) = 1, or 2 to let R(u,v) = 0
                 (R(u,v) = restoration filter, this is used
                 when the denominator = 0)
      <cutoff> - cutoff frequency

PATH

     $CVIPHOME/XFORMFILTER/InverseFilter.c

DESCRIPTION

     This function performs an inverse filter, a frequency domain
     filter defined:
                                            G(u,v)
               F(u,v) = --------------------------------
                                        2
                 H(u,v) + gamma*(Pfn)

     where F(u,v) is the Fourier transform of the restored image,
     G(u,v)  is  the Fourier transform of the degraded image, and
     H(u,v) is the Fourier transform of the degradation function.
     Pfn is an approximation of the noise-to-power ratio.

TYPES AND CONSTANTS

     None

RETURN VALUES

     A pointer to the restored image

HISTORY

     History information recorded:

       parameter #1 = gamma

EXAMPLE

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

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

      (void) setDisplay_Image(VIEWER,"default");
      print_CVIP("\n\t\tEnter the File Name of the
      degraded image:  ");
      inputfile =(char *) getString_CVIP();
      format = getFormat_CVIP(inputfile);
      cvipImage = read_Image(inputfile,1);
      view_Image(cvipImage, inputfile);
      free(inputfile);
      /* the following call creates a gaussian mask of size
      3  * 3 */
      cvipImage1 = (Image *)h_image(3,3,3);
      print_CVIP("\n\t\tEnter the File Name of the smooth
      constraint image:  ");
      inputfile1 =(char *) getString_CVIP();
      format = getFormat_CVIP(inputfile1);
      cvipImage2 = read_Image(inputfile1,1);
      view_Image(cvipImage2, inputfile1);
      free(inputfile1);
      /* the following call performs the least squares filter
      on the input image with the gaussian mask,gamma equal
      to .5 and the cut off frequency equal to 32  */
      cvipImage2=(Image *)least_squares(cvipImage,cvipImage1,
      cvipImage2,.5,1,32);
      cvipImage=(Image *)ifft_transform(cvipImage2,256);
      print_CVIP("\n\t\tEnter the Output File Name:  ");
      outputfile = getString_CVIP();
      view_Image(cvipImage,outputfile);
      write_Image(cvipImage,outputfile,CVIP_NO,CVIP_NO,format,1);
      free(outputfile);
      }

SEE ALSO

     libxformfilter

AUTHOR

     Copyright (C) 1996 SIUE -  by  Scott  E.  Umbaugh  and  Arve
     Kjoelen.