8#include "tpcclibConfig.h"
23static char *info[] = {
24 "Shrink the size of a dynamic or static PET image to take less memory and",
25 "disk space, and to reduce noise and computation time when testing",
26 "pixel-by-pixel modeling methods.",
27 "Eight neighbouring pixels are averaged into one pixel; thus image size",
28 "will be shrunk into 1/8 of the size of the original image.",
29 "ECAT 6.3, 7.x, and Analyze 7.5 and NIfTI-1 formats are accepted.",
31 "Usage: @P [Options] image shrunkenimage",
35 " Nr of image planes (z dimension) is halved (default) or not changed.",
39 " @P i5998dy1.v i5998dy1_shrunken.v",
41 "See also: imgslim, e7vplavg, imgdim, esplit, imgbox, imgswell, imginteg",
43 "Keywords: image, compression, smoothing, cropping, software testing",
62int main(
int argc,
char **argv)
64 int ai, help=0, version=0, verbose=1;
65 char petfile[FILENAME_MAX], outfile[FILENAME_MAX];
74 if(argc==1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
75 petfile[0]=outfile[0]=(char)0;
77 for(ai=1; ai<argc; ai++)
if(*argv[ai]==
'-') {
79 cptr=argv[ai]+1;
if(*cptr==
'-') cptr++;
if(cptr==NULL)
continue;
80 if(strncasecmp(cptr,
"Z=", 2)==0) {
82 if(strncasecmp(cptr,
"YES", 1)==0) {shrink_planes=1;
continue;}
83 if(strncasecmp(cptr,
"NO", 1)==0) {shrink_planes=0;
continue;}
85 fprintf(stderr,
"Error: invalid option '%s'.\n", argv[ai]);
90 if(help==2) {
tpcHtmlUsage(argv[0], info,
"");
return(0);}
95 if(ai<argc) {
strlcpy(petfile, argv[ai++], FILENAME_MAX);}
96 if(ai<argc) {
strlcpy(outfile, argv[ai++], FILENAME_MAX);}
98 fprintf(stderr,
"Error: invalid argument '%s'.\n", argv[ai]);
104 fprintf(stderr,
"Error: missing command-line argument; use option --help\n");
110 printf(
"petfile := %s\n", petfile);
111 printf(
"outfile := %s\n", outfile);
112 printf(
"shrink_planes := %d\n", shrink_planes);
120 if(verbose>0) fprintf(stdout,
"reading image %s\n", petfile);
124 fprintf(stderr,
"Error: %s\n", img.
statmsg);
if(verbose>1)
imgInfo(&img);
128 printf(
"image dimensions: %d %d %d\n", img.
dimz, img.
dimy, img.
dimx);
129 printf(
"image frame nr: %d\n", img.
dimt);
133 fprintf(stderr,
"Error: %s is not an image.\n", petfile);
137 if(verbose>0) fprintf(stderr,
"Warning: missing pixel values.\n");
143 if(verbose>0) fprintf(stdout,
"shrinking...\n");
145 ret=
imgShrink(&img, &out, shrink_planes);
147 fprintf(stderr,
"Error: cannot shrink image.\n");
148 if(verbose>1) printf(
"ret=%d\n", ret);
159 if(verbose>1) fprintf(stdout,
"writing shrunken image in %s\n", outfile);
162 fprintf(stderr,
"Error: %s\n", out.
statmsg);
165 if(verbose>0) fprintf(stdout,
"Shrunk image was written in %s\n", outfile);
unsigned long long imgNaNs(IMG *img, int fix)
void imgEmpty(IMG *image)
int imgRead(const char *fname, IMG *img)
int imgWrite(const char *fname, IMG *img)
Header file for libtpcimgio.
Header file for libtpcimgp.
Header file for libtpcmisc.
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
size_t strlcpy(char *dst, const char *src, size_t dstsize)
int tpcHtmlUsage(const char *program, char *text[], const char *path)
void tpcPrintBuild(const char *program, FILE *fp)
void tpcPrintUsage(const char *program, char *text[], FILE *fp)