NAME
bilinear_interp - shrinks or enlarges an image
SYNOPSIS
#include <stdio.h>
#include <CVIPimage.h>
#include <CVIPdef.h>
#include "bilinear.h"
Image *bilinear_interp(Image *inImg, float factor)
<inImg> - pointer to an Image structure
<factor> - factor > 1 to enlarge, factor < 1 to shrink
PATH
$CVIPHOME/GEOMETRY/bilinear.c
DESCRIPTION
This function shrinks or enlarges an image using bilinear
interpolation to calculate the gray-level value of new pix-
els. This technique provides a smooth appearance, especially
when enlarging an image. The newly-created pixel values are
linearly interpolated from formerly adjacent pixels, thus
producing even transitions.
TYPES AND CONSTANTS
#define LOOP_BILINEAR(type,row,Mcol,int_map,delta_map,_Dptr, _Nptr) {
type **_Rowp=(type **)(_Dptr);
type *NEWP=(type *)(_Nptr);
int rI; for(rI=0; rI < (int)Mcol ; rI++) {
*NEWP++=BILINEAR((float)delta_map[row],(float)delta_map[rI],
_Rowp[(int)int_map[row]][(int)int_map[rI]],
_Rowp[(int)int_map[row]][(int)int_map[rI+1]],
_Rowp[(int)int_map[row+1]][(int)int_map[rI]],
_Rowp[(int)int_map[row+1]][(int)int_map[rI+1]], type);
}
RETURN VALUES
A scaled image
HISTORY
History information recorded: None
EXAMPLE
#include <CVIPtoolkit.h>
#include <CVIPdef.h>
#include <CVIPimage.h>
#include <CVIPconvert.h>
#include <CVIPimage.h>
#include "bilinear.h"
#include <stdio.h>
void main()
{
Image *cvipImage;
IMAGE_FORMAT format;
char *inputfile, *outputfile;
float factor;
setDisplay_Image("RamViewer", "Default");
print_CVIP("\n\t\tEnter the Input File Name: ");
inputfile =(char *) getString_CVIP();
format = getFormat_CVIP(inputfile);
cvipImage = read_Image(inputfile, 1);
print_CVIP("\n");
print_CVIP("\n\t\tEnter a scaling factor (from 0.1 to 3.0):
");
factor = getFloat_CVIP( 0.1, 3.0 );
cvipImage = bilinear_interp(cvipImage, factor)
fflush(stdin);
print_CVIP("\n\t\tEnter the Output File Name: ");
outputfile = getString_CVIP();
write_Image(cvipImage,outputfile,CVIP_NO,CVIP_NO,format,1);
display_Image(outputfile,format);
free(inputfile);
free(outputfile);
}
BUGS
The function cannot accept the value '0.3'; it causes a pro-
gram crash.
SEE ALSO
libgeometry
AUTHOR
Copyright (C) 1996 SIUE - by Scott E. Umbaugh and Arve
Kjoelen.