8#include "tpcclibConfig.h"
23static char *info[] = {
24 "List the pixel coordinates in a mask image.",
25 "Pixels with |value| >= 0.5 in mask image are considered as part of mask,",
26 "and their coordinates (x,y,z,f) are written in specified file or stdout.",
28 "Usage: @P [Options] maskfile [pxlfile]",
33 "See also: pxl2mask, maskinv, maskconj, maskdila, pxl2tac, imgprofi",
35 "Keywords: image, mask, pixel",
54int main(
int argc,
char **argv)
56 int ai, help=0, version=0, verbose=1;
58 char maskfile[FILENAME_MAX], pxlfile[FILENAME_MAX];
65 if(argc==1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
66 maskfile[0]=pxlfile[0]=(char)0;
68 for(ai=1; ai<argc; ai++)
if(*argv[ai]==
'-') {
69 cptr=argv[ai]+1;
if(*cptr==
'-') cptr++;
if(cptr==NULL)
continue;
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(maskfile, argv[ai], FILENAME_MAX); ai++;}
82 if(ai<argc) {
strlcpy(pxlfile, 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");
94 printf(
"maskfile := %s\n", maskfile);
95 if(pxlfile[0]) printf(
"pxlfile := %s\n", pxlfile);
105 if(verbose>0) {printf(
"reading %s\n", maskfile); fflush(stdout);}
108 fprintf(stderr,
"Error: %s\n", mask.
statmsg);
109 if(verbose>1) printf(
"ret := %d\n", ret);
113 fprintf(stderr,
"Error: mask cannot be dynamic image.\n");
121 if(verbose>0) {printf(
"processing the mask\n"); fflush(stdout);}
125 fprintf(stderr,
"Error: no voxels are part of mask; empty list not saved.\n");
130 printf(
"nr_of_mask_voxels := %u\n", ret);
143 FILE *fp; fp=fopen(pxlfile,
"w");
145 fprintf(stderr,
"Error: cannot open file for writing (%s).\n", pxlfile);
151 fprintf(stderr,
"Error: cannot write in file %s.\n", pxlfile);
154 if(verbose>0) printf(
"Mask pixel coordinates written in %s\n", pxlfile);
void imgEmpty(IMG *image)
int imgRead(const char *fname, IMG *img)
Header file for libtpcimgio.
void pxlFree(IMG_PIXELS *pxl)
int pxlWrite(IMG_PIXELS *pxl, FILE *fp, char *status)
void pxlInit(IMG_PIXELS *pxl)
long long int pxlAddFromMask(IMG_PIXELS *list, IMG *img)
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)