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
/
extractpieces.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-31
|
3KB
|
94 lines
/*
* ------------------------------------------------------------------
* extractpieces.c - Program to extract 512x512 pieces from a huge image
* Created by Robert Heller on Wed Feb 5 08:51:16 1992
* ------------------------------------------------------------------
* Modification History:
* ------------------------------------------------------------------
* Contents:
* ------------------------------------------------------------------
*
* Copyright (c) 1992 by University of Massachuetts
* All Rights Reserved
*
*/
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <llvs_per_plane.h>
extern void extract_plane();
main (argc, argv)
int argc;
char* argv[];
{
static PLANE *inpl, *outpl;
static PLANE_INFO *inpl_info, *outpl_info;
static char *inassoc, outfile[256], basename[256], infile[256];
register char *p;
register int rowoffset, coloffset, error;
static LIMITS limits;
if (argc != 2) usage_abort();
strcpy(infile,argv[1]);
p = strrchr(infile,'.');
if (p == NULL) strcat(infile,".plane");
else if (strchr(p,'/') != NULL) strcat(infile,".plane");
if (read_plane(&inpl,&inpl_info,&inassoc,infile) < 0) {
error = errno;
perror("extractpieces: read_plane");
fprintf(stderr,"extractpieces: read_plane: could not read in plane %s\n",
infile);
exit(error);
}
strcpy(basename,infile);
p = strrchr(basename,'.');
if (p != NULL) *p = '\0';
if (new_plane(&outpl,&outpl_info,inpl_info->datatype,inpl_info->level,
512,512,0,0,&inpl_info->background) < 0) {
error = errno;
perror("extractpieces: new_plane");
fprintf(stderr,"extractpieces: new_plane: could not allocate plane\n");
exit(error);
}
limits.level = inpl_info->level;
limits.deltarow = 1;
limits.deltacol = 1;
for (rowoffset = inpl_info->row_location;
rowoffset < (inpl_info->row_location + inpl_info->row_dimension);
rowoffset += 512) {
for (coloffset = inpl_info->column_location;
coloffset < (inpl_info->column_location +
inpl_info->column_dimension);
coloffset += 512) {
limits.startrow = rowoffset;
limits.startcol = coloffset;
limits.endrow = rowoffset + 511;
limits.endcol = coloffset + 511;
outpl_info->row_location = rowoffset;
outpl_info->column_location = coloffset;
memset(outpl,0,plane_size(outpl_info));
extract_plane(inpl,inpl_info,outpl,outpl_info,&limits);
sprintf(outfile,"%sR%dC%d.plane",basename,
rowoffset,coloffset);
if (write_plane(outpl,outpl_info,"NIL",outfile) < 0) {
error = errno;
perror("extractpieces: write_plane");
fprintf(stderr,"extractpieces: write_plane: could not create plane %s\n",
outfile);
exit(error);
}
}
}
}
usage_abort()
{
printf("usage: extractpices planefile\n");
exit(EINVAL);
}