## NAME

         geometric_mean - performs a parametric wiener filter

## SYNOPSIS

          #include "CVIPimage.h"
          #include "CVIPtransform.h"
          #include "CVIPxformfilter.h"
          #include "CVIPdef.h"

         Image *geometric_mean(Image  *degr,  Image  *degr_fn,  Image
         *p_noise,  Image  *p_orig,  float  gamma,  float  alpha, int
         choice, int cutoff)

          <degr>    - pointer to the degraded image
          <degr_fn> - pointer to the degradation function
          <p_noise> - pointer to the noise power spectral density
          <p_orig>  - pointer to the original  image  power  spectral
         density
          <gamma>   - 'gamma' in the generalized restorationequation.
          <alpha>   - 'alpha' in the  generalized  restoration  equa-
         tion.
          <choice>  - 1 to let R(u,v) = 1, or 2 to let R(u,v) = 0
                      (R(u,v) is restoration filter, this is used
                      when denominator=0)
          <cutoff>  - cutoff frequency for filtering

## PATH

         $CVIPHOME/XFORMFILTER/InverseFilter.c

## DESCRIPTION

         This function performs a parametric wiener filter.  See  any
         image processing textbook for info on Wiener Filters.

         The function does its own memory management, freeing  every-
         thing  passed to it, so if you need your images intact, make
         a copy of them before calling this function.

         The function tries to determine whether an FFT has been per-
         formed on the passed images.  If not, the function will per-
         form the FFT.  This is especially important to note for  the
         power  images.   If  the  power  images  are  in the spatial
         domain, they will have an FFT performed on them, before  the
         squared  magnitude  is calculated.  If an FFT is detected in
         the history of any  of  the  power  images,  that  image  is
         assumed  to  be  representing  a power image, and no squared
         magnitude is calculated.

         The function will also extend the sizes of the passed images
         as best it can when they are of unequal size.

         Also note that the passed images must have the  same  number
         of (color) bands.

## TYPES AND CONSTANTS

         None

## RETURN VALUES

         A pointer to the restored (filtered) image

## HISTORY

         History information recorded:

           parameter #1 = filter cutoff.
           parameter #2 = method 1: F(u,v)=G(u,v) when H(u,v)=0
                          method 2: F(u,v)=0 when H(u,v)=0

## 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,*cvipImage3;
          IMAGE_FORMAT format;
          char *inputfile,*outputfile;
          char *inputfile1,*inputfile2;

          (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 original
          power spectrum image:  ");
          inputfile1 =(char *) getString_CVIP();
          format = getFormat_CVIP(inputfile1);
          cvipImage2 = read_Image(inputfile1,1);
          view_Image(cvipImage2, inputfile1);
          free(inputfile1);
          print_CVIP("\n\t\tEnter the File Name of the noise
          power spectrum image:  ");
          inputfile2 =(char *) getString_CVIP();
          format = getFormat_CVIP(inputfile2);
          cvipImage3 = read_Image(inputfile2,1);
          view_Image(cvipImage3, inputfile2);
          free(inputfile2);
          /* the following call performs the geometric mean on the
          input image with the gaussian mask,alpha equal to .25,gamma
          equal to .5 and the cut off frequency equal to 32  */
          cvipImage3=(Image *)geometric_mean(cvipImage,cvipImage1,
          cvipImage2,cvipImage3,.25,.5,1,32);
          cvipImage=(Image *)ifft_transform(cvipImage3,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.