home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
vis-ftp.cs.umass.edu
/
vis-ftp.cs.umass.edu.tar
/
vis-ftp.cs.umass.edu
/
pub
/
Software
/
ASCENDER
/
ascendMar8.tar
/
UMass
/
BoldtNew
/
LLVS
/
convolve.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-31
|
2KB
|
85 lines
#include <stdio.h>
#include <stdlib.h>
#include "signal2D.h"
#include "llvs_per_plane.h"
/* CONVOLVE LLVS PLANE WITH A TEMPLATE */
void main(int argc, char *argv[])
{
char *imagefilename, *templatefilename, *resultfilename;
PLANE *inplane, *outplane;
PLANE_INFO *inplane_info, *outplane_info;
static char *inassoc;
Signal_2D template;
float backval = 0.0;
Bool suc;
if (!(argc == 4)) {
fprintf(stderr,
"Usage: convolve inimage.plane template.txt outimage.plane\n");
return;
}
imagefilename = argv[1];
templatefilename = argv[2];
resultfilename = argv[3];
/* READ IN 2D CONVOLUTION TEMPLATE */
suc = read_signal_2D(templatefilename, &template);
if(! suc) return;
/* READ INPUT IMAGE PLANE */
if (read_plane(&inplane,&inplane_info,&inassoc,imagefilename) < 0) {
perror("convolve: read_plane");
fprintf(stderr,"convolve: read_plane could not read in plane %s\n",
imagefilename);
return;
}
if (!((inplane_info->datatype == LLVS_BYTE) ||
(inplane_info->datatype == LLVS_SHORT))) {
fprintf(stderr,"convolve: input plane type must be byte or short int\n");
fprintf(stderr,"convolve: input file name was %s\n", imagefilename);
return;
}
/* CREATE (FLOATING POINT) OUTPUT IMAGE PLANE */
if (new_plane(&outplane,&outplane_info,LLVS_FLOAT,inplane_info->level,
inplane_info->row_dimension, inplane_info->column_dimension,
inplane_info->row_location, inplane_info->column_location,
&backval) < 0) {
perror("convolve: new_plane");
fprintf(stderr,"convolve: new_plane could not allocate plane\n");
return;
}
/* PERFORM THE CONVOLUTION */
if (inplane_info->datatype == LLVS_BYTE)
suc = byteIn_floatOut_signal_2D_convolve_edgecut(
(unsigned char*)inplane->plane_base,
inplane_info->column_dimension,
inplane_info->row_dimension,
&template,
(float*)outplane->plane_base);
else
suc = shortIn_floatOut_signal_2D_convolve_edgecut(
(short int*)inplane->plane_base,
inplane_info->column_dimension,
inplane_info->row_dimension,
&template,
(float*)outplane->plane_base);
if(!suc) return;
/* WRITE RESULT PLANE */
suc = write_plane(outplane,outplane_info,"NIL",resultfilename);
if(! suc) return;
free_signal_2D(&template);
free(inplane); free(inplane_info);
free(outplane); free(outplane_info);
return;
}