8#include "tpcclibConfig.h"
23static char *info[] = {
24 "Invert mask image in ECAT 6.3 or 7.x, NIfTI-1, or Analyze 7.5 format.",
25 "Pixels with value zero are set to 1, and other pixels are set to 0.",
27 "Usage: @P [Options] maskfile [invertedfile]",
32 "See also: maskconj, maskdila, maskeros, imgmask, imgthrs, masklbl, img2dft",
34 "Keywords: image, mask, invert",
53int main(
int argc,
char **argv)
55 int ai, help=0, version=0, verbose=1;
57 char maskfile[FILENAME_MAX], outfile[FILENAME_MAX];
64 if(argc==1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
65 maskfile[0]=outfile[0]=(char)0;
67 for(ai=1; ai<argc; ai++)
if(*argv[ai]==
'-') {
68 cptr=argv[ai]+1;
if(*cptr==
'-') cptr++;
if(cptr==NULL)
continue;
70 fprintf(stderr,
"Error: invalid option '%s'.\n", argv[ai]);
75 if(help==2) {
tpcHtmlUsage(argv[0], info,
"");
return(0);}
80 if(ai<argc) {
strlcpy(maskfile, argv[ai], FILENAME_MAX); ai++;}
81 if(ai<argc) {
strlcpy(outfile, argv[ai], FILENAME_MAX); ai++;}
82 if(ai<argc) {fprintf(stderr,
"Error: too many arguments.\n");
return(1);}
86 fprintf(stderr,
"Error: missing command-line argument; use option --help\n");
90 strcpy(outfile, maskfile);
96 printf(
"maskfile := %s\n", maskfile);
97 printf(
"outfile := %s\n", outfile);
107 if(verbose>0) {printf(
"reading %s\n", maskfile); fflush(stdout);}
110 fprintf(stderr,
"Error: %s\n", mask.
statmsg);
111 if(verbose>1) printf(
"ret := %d\n", ret);
115 fprintf(stderr,
"Error: mask cannot be dynamic image.\n");
122 fprintf(stderr,
"Warning: initial mask contains no positive voxels.\n");
127 printf(
"initial_nr_of_positive_voxels := %u\n", mn);
135 if(verbose>0) {printf(
"inverting\n"); fflush(stdout);}
140 fprintf(stderr,
"Warning: all voxels are zeroes; empty mask not saved.\n");
145 printf(
"nr_of_positive_voxels := %u\n", mn);
152 if(verbose>2) printf(
"writing mask\n");
155 fprintf(stderr,
"Error: %s\n", mask.
statmsg);
159 if(verbose>0) printf(
"mask written.\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.
long long imgMaskCount(IMG *img)
void imgMaskInvert(IMG *img)
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)