NAME
midpoint_filter - typically used to filter images containing
short tailed noise such as Gaussian and uniform noises.
SYNOPSIS
#include <CVIPtoolkit.h>
#include <CVIPdef.h>
#include <CVIPspfltr.h>
#include <float.h>
Image *midpoint_filter(Image *imageP, int mask_size)
<imageP> - pointer to Image structure.
<mask_size> - size of the filtering window
(e.g., 3->3x3).
PATH
$CVIPHOME/SPATIALFILTER/spatial_filter.c
OPTIONS
None.
DESCRIPTION
Returns the midpoint value of the set of pixels contained in
the N x N filter window. The filter calculates the maximum
and minimum values in the window and returns their sum
divided by 2. Size of filter should be an odd integer lim-
ited from < 3 - 31 >.
TIPS
Works best on images containing short tailed noise such as
uniform and Gaussian noise. Keep filter mask small to
minimize blurring.
DIAGNOSTICS
Returns a pointer to the modified Image structure on suc-
cess. Returns a NULL pointer if the input Image datatype is
not CVIP_BYTE and can't be cast to CVIP_FLOAT.
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_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);
/* the following call replaces each pixel value
by the average of the maximum and minimum in a
3 x 3 window */
cvipImage = midpoint_filter(cvipImage,3);
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);
}
BUGS
None.
AUTHOR
Copyright (C) 1992, 1996 SIUE - by Scott E. Umbaugh and John
A Creighton.