8#include "tpcclibConfig.h"
23static char *info[] = {
24 "Invert the pixel values in image file, that is, calculates 1/y.",
26 "Usage: @P [Options] imgfile [outputfile]",
28 "Image file can be in ECAT 6.3 or 7.x, NIfTI-1, or Analyze 7.5 format.",
29 "If name for output file is not given, then the original image is overwritten.",
30 "Pixel values that are negative or close to zero will be set to zero.",
35 "See also: tacinv, imgcalc, imgthrs, imgpeak, imgflip",
37 "Keywords: image, tool",
56int main(
int argc,
char **argv)
58 int ai, help=0, version=0, verbose=1;
59 char imgfile[FILENAME_MAX], outfile[FILENAME_MAX];
65 if(argc==1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
66 imgfile[0]=outfile[0]=(char)0;
68 for(ai=1; ai<argc; ai++)
if(*argv[ai]==
'-') {
71 fprintf(stderr,
"Error: invalid option '%s'.\n", argv[ai]);
76 if(help==2) {
tpcHtmlUsage(argv[0], info,
"");
return(0);}
81 if(ai<argc) {
strlcpy(imgfile, argv[ai], FILENAME_MAX); ai++;}
82 if(ai<argc) {
strlcpy(outfile, argv[ai], FILENAME_MAX); ai++;}
83 if(ai<argc) {fprintf(stderr,
"Error: too many arguments.\n");
return(1);}
87 fprintf(stderr,
"Error: missing command-line argument; use option --help\n");
90 if(!outfile[0]) strcpy(outfile, imgfile);
95 printf(
"imgfile := %s\n", imgfile);
96 printf(
"outfile := %s\n", outfile);
103 if(verbose>0) printf(
"reading %s\n", imgfile);
106 fprintf(stderr,
"Error: %s\n", img.
statmsg);
110 printf(
"dimt := %d\n", img.
dimt);
111 printf(
"dimx := %d\n", img.
dimx);
112 printf(
"dimy := %d\n", img.
dimy);
113 printf(
"dimz := %d\n", img.
dimz);
120 if(verbose>0) printf(
"processing...\n");
122 fprintf(stderr,
"Error: cannot inverse pixel values.\n");
130 if(verbose>0) printf(
"writing image %s\n", outfile);
132 fprintf(stderr,
"Error: %s\n", img.
statmsg);
136 if(verbose>0) printf(
"done.\n\n");
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)