int main(int argc, char *argv[]) { char *me, **name; int lenName, ni, reverse, quiet, noAction, mac; hestOpt *hopt = NULL; airArray *mop; me = argv[0]; hestOptAdd(&hopt, "r", NULL, airTypeInt, 0, 0, &reverse, NULL, "convert back to DOS, instead of converting from DOS to normal"); hestOptAdd(&hopt, "q", NULL, airTypeInt, 0, 0, &quiet, NULL, "never print anything to stderr, even for errors."); hestOptAdd(&hopt, "m", NULL, airTypeInt, 0, 0, &mac, NULL, "deal with legacy MAC text files."); hestOptAdd(&hopt, "n", NULL, airTypeInt, 0, 0, &noAction, NULL, "don't actually write converted files, just pretend to. " "This is useful to see which files WOULD be converted. "); hestOptAdd(&hopt, NULL, "file", airTypeString, 1, -1, &name, NULL, "all the files to convert. Each file will be over-written " "with its converted contents. Use \"-\" to read from stdin " "and write to stdout", &lenName); hestParseOrDie(hopt, argc-1, argv+1, NULL, me, info, AIR_TRUE, AIR_TRUE, AIR_TRUE); mop = airMopNew(); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); for (ni=0; ni<lenName; ni++) { undosConvert(me, name[ni], reverse, mac, quiet, noAction); } airMopOkay(mop); return 0; }
int main(int argc, char *argv[]) { char *me; hestOpt *hopt = NULL; int center; double minPos, maxPos, pos, index, size; me = argv[0]; hestOptAdd(&hopt, NULL, "center", airTypeEnum, 1, 1, ¢er, NULL, "which centering applies to the quantized position.\n " "Possibilities are:\n " "\b\bo \"cell\": for histogram bins, quantized values, and " "pixels-as-squares\n " "\b\bo \"node\": for non-trivially interpolated " "sample points", NULL, nrrdCenter); hestOptAdd(&hopt, NULL, "minPos", airTypeDouble, 1, 1, &minPos, NULL, "smallest position associated with index 0"); hestOptAdd(&hopt, NULL, "maxPos", airTypeDouble, 1, 1, &maxPos, NULL, "highest position associated with highest index"); hestOptAdd(&hopt, NULL, "num", airTypeDouble, 1, 1, &size, NULL, "number of intervals into which position has been quantized"); hestOptAdd(&hopt, NULL, "index", airTypeDouble, 1, 1, &index, NULL, "the input index, to be converted to position"); hestParseOrDie(hopt, argc-1, argv+1, NULL, me, info, AIR_TRUE, AIR_TRUE, AIR_TRUE); pos = NRRD_POS(center, minPos, maxPos, size, index); printf("%g\n", pos); hestParseFree(hopt); hestOptFree(hopt); exit(0); }
int unrrdu_shuffleMain(int argc, const char **argv, const char *me, hestParm *hparm) { hestOpt *opt = NULL; char *out, *err; Nrrd *nin, *nout; unsigned int di, axis, permLen, *perm, *iperm, *whichperm; size_t *realperm; int inverse, pret; airArray *mop; /* so that long permutations can be read from file */ hparm->respFileEnable = AIR_TRUE; hestOptAdd(&opt, "p,permute", "slc0 slc1", airTypeUInt, 1, -1, &perm, NULL, "new slice ordering", &permLen); hestOptAdd(&opt, "inv,inverse", NULL, airTypeInt, 0, 0, &inverse, NULL, "use inverse of given permutation"); OPT_ADD_AXIS(axis, "axis to shuffle along"); OPT_ADD_NIN(nin, "input nrrd"); OPT_ADD_NOUT(out, "output nrrd"); mop = airMopNew(); airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); USAGE(_unrrdu_shuffleInfoL); PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); /* we have to do error checking on axis in order to do error checking on length of permutation */ if (!( axis < nin->dim )) { fprintf(stderr, "%s: axis %d not in valid range [0,%d]\n", me, axis, nin->dim-1); airMopError(mop); return 1; } if (!( permLen == nin->axis[axis].size )) { char stmp[AIR_STRLEN_SMALL]; fprintf(stderr, "%s: permutation length (%u) != axis %d's size (%s)\n", me, permLen, axis, airSprintSize_t(stmp, nin->axis[axis].size)); airMopError(mop); return 1; } if (inverse) { iperm = AIR_CALLOC(permLen, unsigned int); airMopAdd(mop, iperm, airFree, airMopAlways); if (nrrdInvertPerm(iperm, perm, permLen)) { fprintf(stderr, "%s: couldn't compute inverse of given permutation\n", me); airMopError(mop); return 1; } whichperm = iperm; } else {
int main(int argc, char *argv[]) { char *me; hestOpt *hopt=NULL; airArray *mop; unsigned int *srcA, *srcB, *dstC, *_srcA, *_srcB, numA, numB, numC, idx; me = argv[0]; hestOptAdd(&hopt, "a", "vals", airTypeUInt, 1, -1, &srcA, NULL, "list of values", &numA); hestOptAdd(&hopt, "b", "vals", airTypeUInt, 1, -1, &srcB, NULL, "list of values", &numB); hestParseOrDie(hopt, argc-1, argv+1, NULL, me, info, AIR_TRUE, AIR_TRUE, AIR_TRUE); mop = airMopNew(); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); fprintf(stderr, "a ="); for (idx=0; idx<numA; idx++) { fprintf(stderr, " %u", srcA[idx]); } fprintf(stderr, "\n"); fprintf(stderr, "b ="); for (idx=0; idx<numB; idx++) { fprintf(stderr, " %u", srcB[idx]); } fprintf(stderr, "\n"); _srcA = AIR_CAST(unsigned int*, calloc(1+numA, sizeof(unsigned int))); airMopAdd(mop, _srcA, airFree, airMopAlways); _srcB = AIR_CAST(unsigned int*, calloc(1+numB, sizeof(unsigned int))); airMopAdd(mop, _srcB, airFree, airMopAlways); dstC = AIR_CAST(unsigned int*, calloc(1+AIR_MAX(numA,numB), sizeof(unsigned int))); airMopAdd(mop, dstC, airFree, airMopAlways); _srcA[0] = numA; for (idx=0; idx<numA; idx++) { _srcA[1+idx] = srcA[idx]; } _srcB[0] = numB; for (idx=0; idx<numB; idx++) { _srcB[1+idx] = srcB[idx]; } numC = flipListIntx(dstC, _srcA, _srcB); fprintf(stderr, "intx(a,b) ="); for (idx=0; idx<numC; idx++) { fprintf(stderr, " %u", dstC[idx]); } fprintf(stderr, "\n"); airMopOkay(mop); return 0; }
int unrrdu_ccfindMain(int argc, char **argv, char *me, hestParm *hparm) { hestOpt *opt = NULL; char *out, *err, *valS; Nrrd *nin, *nout, *nval=NULL; airArray *mop; int type, pret; unsigned int conny; hestOptAdd(&opt, "v,values", "filename", airTypeString, 1, 1, &valS, "", "Giving a filename here allows you to save out the values " "associated with each connect component. This can be used " "later with \"ccmerge -d\". By default, no record of the " "original CC values is kept."); hestOptAdd(&opt, "t,type", "type", airTypeOther, 1, 1, &type, "default", "type to use for output, to store the CC ID values. By default " "(not using this option), the type used will be the smallest of " "uchar, ushort, or int, that can represent all the CC ID values. " "Using this option allows one to specify the integral type to " "be used.", NULL, NULL, &unrrduHestMaybeTypeCB); hestOptAdd(&opt, "c,connect", "connectivity", airTypeUInt, 1, 1, &conny, NULL, "what kind of connectivity to use: the number of coordinates " "that vary in order to traverse the neighborhood of a given " "sample. In 2D: \"1\": 4-connected, \"2\": 8-connected"); OPT_ADD_NIN(nin, "input nrrd"); OPT_ADD_NOUT(out, "output nrrd"); mop = airMopNew(); airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); USAGE(_unrrdu_ccfindInfoL); PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); if (nrrdCCFind(nout, airStrlen(valS) ? &nval : NULL, nin, type, conny)) { airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: error doing connected components:\n%s", me, err); airMopError(mop); return 1; } if (nval) { airMopAdd(mop, nval, (airMopper)nrrdNuke, airMopAlways); } if (airStrlen(valS)) { SAVE(valS, nval, NULL); } SAVE(out, nout, NULL); airMopOkay(mop); return 0; }
int main(int argc, const char *argv[]) { hestOpt *hopt=NULL; airArray *mop; const char *me; char *outS, *err; Nrrd *nin, *nout; NrrdIoState *nio; float heqamount; me = argv[0]; mop = airMopNew(); hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, NULL, "input nrrd to project. Must be three dimensional.", NULL, NULL, nrrdHestNrrd); hestOptAdd(&hopt, "amt", "heq", airTypeFloat, 1, 1, &heqamount, "0.5", "how much to apply histogram equalization to projection images"); hestOptAdd(&hopt, "o", "img out", airTypeString, 1, 1, &outS, NULL, "output image to save to. Will try to use whatever " "format is implied by extension, but will fall back to PPM."); hestParseOrDie(hopt, argc-1, argv+1, NULL, me, info, AIR_TRUE, AIR_TRUE, AIR_TRUE); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); nio = nrrdIoStateNew(); airMopAdd(mop, nio, (airMopper)nrrdIoStateNix, airMopAlways); nrrdStateDisableContent = AIR_TRUE; if (doit(nout, nin, 1, heqamount)) { err=biffGetDone(NINSPECT); airMopAdd(mop, err, airFree, airMopAlways); fprintf(stderr, "%s: trouble creating output:\n%s", me, err); airMopError(mop); return 1; } if (nrrdFormatPNG->nameLooksLike(outS) && !nrrdFormatPNG->available()) { fprintf(stderr, "(%s: using PPM format for output)\n", me); nio->format = nrrdFormatPNM; } if (nrrdSave(outS, nout, nio)) { err=biffGetDone(NRRD); airMopAdd(mop, err, airFree, airMopAlways); fprintf(stderr, "%s: trouble saving output image \"%s\":\n%s", me, outS, err); airMopError(mop); return 1; } airMopOkay(mop); return 0; }
int unrrdu_spliceMain(int argc, char **argv, char *me, hestParm *hparm) { hestOpt *opt = NULL; char *out, *err; Nrrd *nin, *nout, *nslice; unsigned int axis; int pret; long int _pos[2]; size_t pos; airArray *mop; OPT_ADD_AXIS(axis, "axis to splice along"); hestOptAdd(&opt, "p,position", "pos", airTypeOther, 1, 1, _pos, NULL, "position to splice at:\n " "\b\bo <int> gives 0-based index\n " "\b\bo M-<int> give index relative " "to the last sample on the axis (M == #samples-1).", NULL, NULL, &unrrduHestPosCB); hestOptAdd(&opt, "s,slice", "nslice", airTypeOther, 1, 1, &(nslice), NULL, "slice nrrd. This the slice to be inserted in \"nin\"", NULL, NULL, nrrdHestNrrd); OPT_ADD_NIN(nin, "input nrrd. This the nrrd into which the slice will " "be inserted"); OPT_ADD_NOUT(out, "output nrrd"); mop = airMopNew(); airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); USAGE(_unrrdu_spliceInfoL); PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); if (!( axis < nin->dim )) { fprintf(stderr, "%s: axis %u not in range [0,%u]\n", me, axis, nin->dim-1); return 1; } if (_pos[0] == -1) { fprintf(stderr, "%s: m+<int> specification format meaningless here\n", me); return 1; } pos = _pos[0]*(nin->axis[axis].size-1) + _pos[1]; nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); if (nrrdSplice(nout, nin, nslice, axis, pos)) { airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: error splicing nrrd:\n%s", me, err); airMopError(mop); return 1; } SAVE(out, nout, NULL); airMopOkay(mop); return 0; }
int main(int argc, const char *argv[]) { airArray *mop; hestOpt *hopt=NULL; int i, N, M, P, yes, *year; unsigned int E; const char *me; double crct; me = argv[0]; mop = airMopNew(); hestOptAdd(&hopt, "N", "days", airTypeInt, 1, 1, &N, "365", "# of days in year"); /* E != P */ hestOptAdd(&hopt, "E", "exps", airTypeInt, 1, 1, &P, "100000", "number of experiments after which to print out newly " "computed probability"); hestOptAdd(&hopt, NULL, "people", airTypeInt, 1, 1, &M, NULL, "# of people in room"); hestParseOrDie(hopt, argc-1, argv+1, NULL, me, info, AIR_TRUE, AIR_TRUE, AIR_TRUE); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); if (!( N > 1 && M > 0 && P > 1)) { fprintf(stderr, "%s: need both M, P all > 1, M > 0\n", me); airMopError(mop); exit(1); } if (!(year = (int*)calloc(N, sizeof(int)))) { fprintf(stderr, "%s: couldn't calloc(%d,sizeof(int))\n", me, N); airMopError(mop); exit(1); } airMopMem(mop, year, airMopAlways); crct = 1; for (i=0; i<M; i++) { crct *= (double)(N-i)/N; } crct = 1-crct; yes = 0; E = 1; airSrandMT((int)airTime()); while (E) { yes += runexp(year, N, M); if (!(E % P)) { printf("P = %10d/%10d = %22.20f =?= %22.20f\n", yes, E, (double)yes/E, crct); } E++; } airMopOkay(mop); exit(0); }
int main(int argc, const char *argv[]) { const char *me; char *err, *outS; hestOpt *hopt=NULL; airArray *mop; limnPolyData *pld; FILE *file; Nrrd *nin; double thresh; int bitflag; me = argv[0]; hestOptAdd(&hopt, "vi", "nin", airTypeOther, 1, 1, &nin, NULL, "input values", NULL, NULL, nrrdHestNrrd); hestOptAdd(&hopt, "pi", "lpld", airTypeOther, 1, 1, &pld, NULL, "input polydata", NULL, NULL, limnHestPolyDataLMPD); hestOptAdd(&hopt, "th", "thresh", airTypeDouble, 1, 1, &thresh, NULL, "threshold value"); hestOptAdd(&hopt, "o", "output LMPD", airTypeString, 1, 1, &outS, "out.lmpd", "output file to save LMPD into"); hestParseOrDie(hopt, argc-1, argv+1, NULL, me, info, AIR_TRUE, AIR_TRUE, AIR_TRUE); mop = airMopNew(); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); bitflag = limnPolyDataInfoBitFlag(pld); fprintf(stderr, "!%s: bitflag = %d\n", me, bitflag); fprintf(stderr, "!%s: rgba %d, norm %d, tex2 %d\n", me, (1 << limnPolyDataInfoRGBA) & bitflag, (1 << limnPolyDataInfoNorm) & bitflag, (1 << limnPolyDataInfoTex2) & bitflag); file = airFopen(outS, stdout, "w"); if (!file) { fprintf(stderr, "%s: couldn't open \"%s\" for writing", me, outS); airMopError(mop); return 1; } airMopAdd(mop, file, (airMopper)airFclose, airMopAlways); if (limnPolyDataClip(pld, nin, thresh) || limnPolyDataWriteLMPD(file, pld)) { airMopAdd(mop, err = biffGetDone(LIMN), airFree, airMopAlways); fprintf(stderr, "%s: trouble:\n%s\n", me, err); airMopError(mop); return 1; } airMopOkay(mop); return 0; }
int unrrdu_histaxMain(int argc, char **argv, char *me, hestParm *hparm) { hestOpt *opt = NULL; char *out, *err; Nrrd *nin, *nout; int type, bins, pret, blind8BitRange; unsigned int axis; double min, max; airArray *mop; NrrdRange *range; OPT_ADD_AXIS(axis, "axis to histogram along"); hestOptAdd(&opt, "b,bin", "bins", airTypeInt, 1, 1, &bins, NULL, "# of bins in histogram"); OPT_ADD_TYPE(type, "output type", "uchar"); hestOptAdd(&opt, "min,minimum", "value", airTypeDouble, 1, 1, &min, "nan", "Value at low end of histogram. Defaults to lowest value " "found in input nrrd."); hestOptAdd(&opt, "max,maximum", "value", airTypeDouble, 1, 1, &max, "nan", "Value at high end of histogram. Defaults to highest value " "found in input nrrd."); hestOptAdd(&opt, "blind8", "bool", airTypeBool, 1, 1, &blind8BitRange, nrrdStateBlind8BitRange ? "true" : "false", "Whether to know the range of 8-bit data blindly " "(uchar is always [0,255], signed char is [-128,127])."); OPT_ADD_NIN(nin, "input nrrd"); OPT_ADD_NOUT(out, "output nrrd"); mop = airMopNew(); airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); USAGE(_unrrdu_histaxInfoL); PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); range = nrrdRangeNew(min, max); airMopAdd(mop, range, (airMopper)nrrdRangeNix, airMopAlways); nrrdRangeSafeSet(range, nin, blind8BitRange); if (nrrdHistoAxis(nout, nin, range, axis, bins, type)) { airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: error doing axis histogramming:\n%s", me, err); airMopError(mop); return 1; } SAVE(out, nout, NULL); airMopOkay(mop); return 0; }
int unrrdu_dhistoMain(int argc, const char **argv, const char *me, hestParm *hparm) { hestOpt *opt = NULL; char *out, *err; Nrrd *nin, *nout; int pret, nolog, notick; unsigned int size; airArray *mop; double max; hestOptAdd(&opt, "h,height", "height", airTypeUInt, 1, 1, &size, NULL, "height of output image (horizontal size is determined by " "number of bins in input histogram)."); hestOptAdd(&opt, "nolog", NULL, airTypeInt, 0, 0, &nolog, NULL, "do not show the log-scaled histogram with decade tick-marks"); hestOptAdd(&opt, "notick", NULL, airTypeInt, 0, 0, ¬ick, NULL, "do not draw the log decade tick marks"); hestOptAdd(&opt, "max,maximum", "max # hits", airTypeDouble, 1, 1, &max, "nan", "constrain the top of the drawn histogram to be at this " "number of hits. This will either scale the drawn histogram " "downward or clip its top, depending on whether the given max " "is higher or lower than the actual maximum bin count. By " "not using this option (the default), the actual maximum bin " "count is used"); OPT_ADD_NIN(nin, "input nrrd"); OPT_ADD_NOUT(out, "output nrrd"); mop = airMopNew(); airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); USAGE(_unrrdu_dhistoInfoL); PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); if (nrrdHistoDraw(nout, nin, size, nolog ? AIR_FALSE : (notick ? 2 : AIR_TRUE), max)) { airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: error drawing histogram nrrd:\n%s", me, err); airMopError(mop); return 1; } SAVE(out, nout, NULL); airMopOkay(mop); return 0; }
int tend_evqMain(int argc, char **argv, char *me, hestParm *hparm) { int pret; hestOpt *hopt = NULL; char *perr, *err; airArray *mop; int which, aniso, dontScaleByAniso; Nrrd *nin, *nout; char *outS; hestOptAdd(&hopt, "c", "evec index", airTypeInt, 1, 1, &which, "0", "Which eigenvector should be quantized: \"0\" for the " "direction of fastest diffusion (eigenvector associated " "with largest eigenvalue), \"1\" or \"2\" for other two " "eigenvectors (associated with middle and smallest eigenvalue)"); hestOptAdd(&hopt, "a", "aniso", airTypeEnum, 1, 1, &aniso, NULL, "Which anisotropy metric to scale the eigenvector " "with. " TEN_ANISO_DESC, NULL, tenAniso); hestOptAdd(&hopt, "ns", NULL, airTypeInt, 0, 0, &dontScaleByAniso, NULL, "Don't attenuate the color by anisotropy. By default (not " "using this option), regions with low or no anisotropy are " "very dark colors or black"); hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-", "input diffusion tensor volume", NULL, NULL, nrrdHestNrrd); hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-", "output image (floating point)"); mop = airMopNew(); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); USAGE(_tend_evqInfoL); PARSE(); airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); if (tenEvqVolume(nout, nin, which, aniso, !dontScaleByAniso)) { airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways); fprintf(stderr, "%s: trouble quantizing eigenvectors:\n%s\n", me, err); airMopError(mop); return 1; } if (nrrdSave(outS, nout, NULL)) { airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: trouble writing:\n%s\n", me, err); airMopError(mop); return 1; } airMopOkay(mop); return 0; }
int main(int argc, char *argv[]) { char *me; hestOpt *hopt=NULL; airArray *mop; int *itype, itypeNum, ii; double src[3], last[3], dst[3]; char space[] = " "; me = argv[0]; hestOptAdd(&hopt, NULL, "v1 v2 v3", airTypeDouble, 3, 3, src, NULL, "source triple"); hestOptAdd(&hopt, "t", "type", airTypeEnum, 2, -1, &itype, NULL, "sequence of triple types to convert through", &itypeNum, tenTripleType); hestParseOrDie(hopt, argc-1, argv+1, NULL, me, info, AIR_TRUE, AIR_TRUE, AIR_TRUE); mop = airMopNew(); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); printf("%s", space + strlen(airEnumStr(tenTripleType, itype[0]))); printf("%s", airEnumStr(tenTripleType, itype[0])); ell_3v_print_d(stdout, src); ELL_3V_COPY(last, src); for (ii=1; ii<itypeNum; ii++) { tenTripleConvertSingle_d(dst, itype[ii], src, itype[ii-1]); printf("%s", space + strlen(airEnumStr(tenTripleType, itype[ii]))); printf("%s", airEnumStr(tenTripleType, itype[ii])); ell_3v_print_d(stdout, dst); ELL_3V_COPY(src, dst); } /* tenTripleConvert_d(dst, dstType, src, srcType); tenTripleConvert_d(tst, srcType, dst, dstType); */ /* printf("%s: %s %s --> %s --> %s\n", me, tenTriple->name, airEnumStr(tenTriple, srcType), airEnumStr(tenTriple, dstType), airEnumStr(tenTriple, srcType)); ell_3v_print_d(stdout, src); ell_3v_print_d(stdout, dst); ell_3v_print_d(stdout, tst); */ airMopOkay(mop); return 0; }
int unrrdu_gammaMain(int argc, const char **argv, const char *me, hestParm *hparm) { hestOpt *opt = NULL; char *out, *err; Nrrd *nin, *nout; double min, max, gamma; airArray *mop; int pret, blind8BitRange; NrrdRange *range; hestOptAdd(&opt, "g,gamma", "gamma", airTypeDouble, 1, 1, &gamma, NULL, "gamma > 1.0 brightens; gamma < 1.0 darkens. " "Negative gammas invert values (like in xv). "); hestOptAdd(&opt, "min,minimum", "value", airTypeDouble, 1, 1, &min, "nan", "Value to implicitly map to 0.0 prior to calling pow(). " "Defaults to lowest value found in input nrrd."); hestOptAdd(&opt, "max,maximum", "value", airTypeDouble, 1, 1, &max, "nan", "Value to implicitly map to 1.0 prior to calling pow(). " "Defaults to highest value found in input nrrd."); hestOptAdd(&opt, "blind8", "bool", airTypeBool, 1, 1, &blind8BitRange, nrrdStateBlind8BitRange ? "true" : "false", "Whether to know the range of 8-bit data blindly " "(uchar is always [0,255], signed char is [-128,127])."); OPT_ADD_NIN(nin, "input nrrd"); OPT_ADD_NOUT(out, "output nrrd"); mop = airMopNew(); airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); USAGE(_unrrdu_gammaInfoL); PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); range = nrrdRangeNew(min, max); airMopAdd(mop, range, (airMopper)nrrdRangeNix, airMopAlways); nrrdRangeSafeSet(range, nin, blind8BitRange); if (nrrdArithGamma(nout, nin, range, gamma)) { airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: error doing gamma:\n%s", me, err); airMopError(mop); return 1; } SAVE(out, nout, NULL); airMopOkay(mop); return 0; }
int unrrdu_distMain(int argc, char **argv, char *me, hestParm *hparm) { hestOpt *opt = NULL; char *out, *err; Nrrd *nin, *nout; int pret; int E, typeOut, invert, sign; double thresh; airArray *mop; hestOptAdd(&opt, "th,thresh", "val", airTypeDouble, 1, 1, &thresh, NULL, "threshold value to separate inside from outside"); hestOptAdd(&opt, "t,type", "type", airTypeEnum, 1, 1, &typeOut, "float", "type to save output in", NULL, nrrdType); hestOptAdd(&opt, "sgn", NULL, airTypeInt, 0, 0, &sign, NULL, "also compute signed (negative) distances inside objects, " "instead of leaving them as zero"); hestOptAdd(&opt, "inv", NULL, airTypeInt, 0, 0, &invert, NULL, "values *below* threshold are considered interior to object. " "By default (not using this option), values above threshold " "are considered interior. "); OPT_ADD_NIN(nin, "input nrrd"); OPT_ADD_NOUT(out, "output nrrd"); mop = airMopNew(); airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); USAGE(_unrrdu_distInfoL); PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); if (sign) { E = nrrdDistanceL2Signed(nout, nin, typeOut, NULL, thresh, !invert); } else { E = nrrdDistanceL2(nout, nin, typeOut, NULL, thresh, !invert); } if (E) { airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: error doing distance transform:\n%s", me, err); airMopError(mop); return 1; } SAVE(out, nout, NULL); airMopOkay(mop); return 0; }
int main(int argc, const char *argv[]) { const char *me; char *err; limnCamera *cam; float mat[16]; hestOpt *hopt=NULL; airArray *mop; mop = airMopNew(); cam = limnCameraNew(); airMopAdd(mop, cam, (airMopper)limnCameraNix, airMopAlways); me = argv[0]; hestOptAdd(&hopt, "fr", "eye pos", airTypeDouble, 3, 3, cam->from, NULL, "camera eye point"); hestOptAdd(&hopt, "at", "at pos", airTypeDouble, 3, 3, cam->at, "0 0 0", "camera look-at point"); hestOptAdd(&hopt, "up", "up dir", airTypeDouble, 3, 3, cam->up, "0 0 1", "camera pseudo up vector"); hestOptAdd(&hopt, "rh", NULL, airTypeInt, 0, 0, &(cam->rightHanded), NULL, "use a right-handed UVN frame (V points down)"); hestParseOrDie(hopt, argc-1, argv+1, NULL, me, info, AIR_TRUE, AIR_TRUE, AIR_TRUE); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); cam->neer = -1; cam->dist = 0; cam->faar = 1; cam->atRelative = AIR_TRUE; if (limnCameraUpdate(cam)) { fprintf(stderr, "%s: trouble:\n%s\n", me, err = biffGet(LIMN)); free(err); return 1; } printf("%s: W2V:\n", me); ELL_4M_COPY(mat, cam->W2V); ell_4m_print_f(stdout, mat); printf("\n"); printf("%s: V2W:\n", me); ELL_4M_COPY(mat, cam->V2W); ell_4m_print_f(stdout, mat); airMopOkay(mop); return 0; }
int baneGkms_miteMain(int argc, const char **argv, const char *me, hestParm *hparm) { hestOpt *opt = NULL; char *out, *perr; Nrrd *nin, *nout; airArray *mop; int pret, E; hestOptAdd(&opt, "i", "opacIn", airTypeOther, 1, 1, &nin, NULL, "input opacity function (1 or 2 dimensional), from " "\"gkms opac\"", NULL, NULL, nrrdHestNrrd); hestOptAdd(&opt, "o", "opacOut", airTypeString, 1, 1, &out, NULL, "output opacity function filename"); mop = airMopNew(); airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); USAGE(_baneGkms_miteInfoL); PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); if (1 == nin->axis[0].size && nin->axis[0].label && !strcmp("A", nin->axis[0].label)) { fprintf(stderr, "%s: already\n", me); nout = nin; } else { nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); E = 0; if (!E) E |= nrrdAxesInsert(nout, nin, 0); if (!E) E |= !(nout->axis[0].label = airStrdup("A")); if (!E) E |= !(nout->axis[1].label = airStrdup("gage(v)")); if (3 == nout->dim) { if (!E) E |= !(nout->axis[2].label = airStrdup("gage(gm)")); } if (E) { biffMovef(BANE, NRRD, "%s: trouble modifying opacity function nrrd", me); airMopError(mop); return 1; } } if (nrrdSave(out, nout, NULL)) { biffMovef(BANE, NRRD, "%s: trouble saving opacity function", me); airMopError(mop); return 1; } airMopOkay(mop); return 0; }
int main(int argc, char *argv[]) { char *me, *outS, *err; hestOpt *hopt; hestParm *hparm; airArray *mop; Nrrd *_ninA, *_ninB, *ninA, *ninB, *nmul; me = argv[0]; mop = airMopNew(); hparm = hestParmNew(); hopt = NULL; airMopAdd(mop, hparm, (airMopper)hestParmFree, airMopAlways); hestOptAdd(&hopt, NULL, "matrix", airTypeOther, 1, 1, &_ninA, NULL, "first matrix", NULL, NULL, nrrdHestNrrd); hestOptAdd(&hopt, NULL, "matrix", airTypeOther, 1, 1, &_ninB, NULL, "first matrix", NULL, NULL, nrrdHestNrrd); hestOptAdd(&hopt, "o", "filename", airTypeString, 1, 1, &outS, "-", "file to write output nrrd to"); hestParseOrDie(hopt, argc-1, argv+1, hparm, me, mulInfo, AIR_TRUE, AIR_TRUE, AIR_TRUE); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); ninA = nrrdNew(); airMopAdd(mop, ninA, (airMopper)nrrdNuke, airMopAlways); ninB = nrrdNew(); airMopAdd(mop, ninB, (airMopper)nrrdNuke, airMopAlways); nmul = nrrdNew(); airMopAdd(mop, nmul, (airMopper)nrrdNuke, airMopAlways); nrrdConvert(ninA, _ninA, nrrdTypeDouble); nrrdConvert(ninB, _ninB, nrrdTypeDouble); if (ell_Nm_mul(nmul, ninA, ninB)) { airMopAdd(mop, err = biffGetDone(ELL), airFree, airMopAlways); fprintf(stderr, "%s: problem inverting:\n%s\n", me, err); airMopError(mop); return 1; } if (nrrdSave(outS, nmul, NULL)) { airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: problem saving output:\n%s\n", me, err); airMopError(mop); return 1; } airMopOkay(mop); exit(0); }
int unrrdu_joinMain(int argc, const char **argv, const char *me, hestParm *hparm) { hestOpt *opt = NULL; char *out, *err, *label; Nrrd **nin; Nrrd *nout; int incrDim, pret; unsigned int ninLen, axis; double mm[2], spc; airArray *mop; hparm->respFileEnable = AIR_TRUE; hestOptAdd(&opt, "i,input", "nin0", airTypeOther, 1, -1, &nin, NULL, "everything to be joined together", &ninLen, NULL, nrrdHestNrrd); OPT_ADD_AXIS(axis, "axis to join along"); hestOptAdd(&opt, "incr", NULL, airTypeInt, 0, 0, &incrDim, NULL, "in situations where the join axis is *not* among the existing " "axes of the input nrrds, then this flag signifies that the join " "axis should be *inserted*, and the output dimension should " "be one greater than input dimension. Without this flag, the " "nrrds are joined side-by-side, along an existing axis."); hestOptAdd(&opt, "l,label", "label", airTypeString, 1, 1, &label, "", "label to associate with join axis"); hestOptAdd(&opt, "mm,minmax", "min max", airTypeDouble, 2, 2, mm, "nan nan", "min and max values along join axis"); hestOptAdd(&opt, "sp,spacing", "spc", airTypeDouble, 1, 1, &spc, "nan", "spacing between samples along join axis"); OPT_ADD_NOUT(out, "output nrrd"); mop = airMopNew(); airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); USAGE(_unrrdu_joinInfoL); PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); if (nrrdJoin(nout, AIR_CAST(const Nrrd*const*, nin), ninLen, axis, incrDim)) { airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: error joining nrrds:\n%s", me, err); airMopError(mop); return 1; }
int baneGkms_infoMain(int argc, char **argv, char *me, hestParm *hparm) { hestOpt *opt = NULL; char *outS, *perr, err[BIFF_STRLEN]; Nrrd *hvol, *nout; airArray *mop; int pret, one, measr; hestOptAdd(&opt, "m", "measr", airTypeEnum, 1, 1, &measr, "mean", "How to project along the 2nd derivative axis. Possibilities " "include:\n " "\b\bo \"mean\": average value\n " "\b\bo \"median\": value at 50th percentile\n " "\b\bo \"mode\": most common value\n " "\b\bo \"min\", \"max\": probably not useful", NULL, baneGkmsMeasr); hestOptAdd(&opt, "one", NULL, airTypeInt, 0, 0, &one, NULL, "Create 1-dimensional info file; default is 2-dimensional"); hestOptAdd(&opt, "i", "hvolIn", airTypeOther, 1, 1, &hvol, NULL, "input histogram volume (from \"gkms hvol\")", NULL, NULL, nrrdHestNrrd); hestOptAdd(&opt, "o", "infoOut", airTypeString, 1, 1, &outS, NULL, "output info file, used by \"gkms pvg\" and \"gkms opac\""); mop = airMopNew(); airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); USAGE(_baneGkms_infoInfoL); PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); if (baneOpacInfo(nout, hvol, one ? 1 : 2, measr)) { sprintf(err, "%s: trouble distilling histogram info", me); biffAdd(BANE, err); airMopError(mop); return 1; } if (nrrdSave(outS, nout, NULL)) { sprintf(err, "%s: trouble saving info file", me); biffMove(BANE, err, NRRD); airMopError(mop); return 1; } airMopOkay(mop); return 0; }
int tend_normMain(int argc, char **argv, char *me, hestParm *hparm) { int pret; hestOpt *hopt = NULL; char *perr, *err; airArray *mop; Nrrd *nin, *nout; char *outS; float amount, target; double weight[3]; hestOptAdd(&hopt, "w", "w0 w1 w2", airTypeDouble, 3, 3, weight, NULL, "relative weights to put on major, medium, and minor " "eigenvalue when performing normalization (internally " "rescaled to have a 1.0 L1 norm). These weightings determine " "the tensors's \"size\"."); hestOptAdd(&hopt, "a", "amount", airTypeFloat, 1, 1, &amount, "1.0", "how much of the normalization to perform"); hestOptAdd(&hopt, "t", "target", airTypeFloat, 1, 1, &target, "1.0", "target size, post normalization"); hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-", "input diffusion tensor volume", NULL, NULL, nrrdHestNrrd); hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-", "output image (floating point)"); mop = airMopNew(); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); USAGE(_tend_normInfoL); PARSE(); airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); if (tenSizeNormalize(nout, nin, weight, amount, target)) { airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways); fprintf(stderr, "%s: trouble:\n%s\n", me, err); airMopError(mop); return 1; } if (nrrdSave(outS, nout, NULL)) { airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: trouble writing:\n%s\n", me, err); airMopError(mop); return 1; } airMopOkay(mop); return 0; }
int tend_evecrgbMain(int argc, char **argv, char *me, hestParm *hparm) { int pret; hestOpt *hopt = NULL; char *perr, *err; airArray *mop; tenEvecRGBParm *rgbp; Nrrd *nin, *nout; char *outS; mop = airMopNew(); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); rgbp = tenEvecRGBParmNew(); airMopAdd(mop, rgbp, AIR_CAST(airMopper, tenEvecRGBParmNix), airMopAlways); hestOptAdd(&hopt, "c", "evec index", airTypeUInt, 1, 1, &(rgbp->which), NULL, "which eigenvector will be colored. \"0\" for the " "principal, \"1\" for the middle, \"2\" for the minor"); hestOptAdd(&hopt, "a", "aniso", airTypeEnum, 1, 1, &(rgbp->aniso), NULL, "Which anisotropy to use for modulating the saturation " "of the colors. " TEN_ANISO_DESC, NULL, tenAniso); hestOptAdd(&hopt, "t", "thresh", airTypeDouble, 1, 1, &(rgbp->confThresh), "0.5", "confidence threshold"); hestOptAdd(&hopt, "bg", "background", airTypeDouble, 1, 1, &(rgbp->bgGray), "0", "gray level to use for voxels who's confidence is zero "); hestOptAdd(&hopt, "gr", "gray", airTypeDouble, 1, 1, &(rgbp->isoGray), "0", "the gray level to desaturate towards as anisotropy " "decreases (while confidence remains 1.0)"); hestOptAdd(&hopt, "gam", "gamma", airTypeDouble, 1, 1, &(rgbp->gamma), "1", "gamma to use on color components"); hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-", "input diffusion tensor volume", NULL, NULL, nrrdHestNrrd); hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-", "output image (floating point)"); USAGE(_tend_evecrgbInfoL); PARSE(); airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); if (tenEvecRGB(nout, nin, rgbp)) { airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways); fprintf(stderr, "%s: trouble doing colormapping:\n%s\n", me, err); airMopError(mop); return 1; } if (nrrdSave(outS, nout, NULL)) { airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: trouble writing:\n%s\n", me, err); airMopError(mop); return 1; } airMopOkay(mop); return 0; }
int tend_anscaleMain(int argc, const char **argv, const char *me, hestParm *hparm) { int pret; hestOpt *hopt = NULL; char *perr, *err; airArray *mop; Nrrd *nin, *nout; char *outS; float scale; int fixDet, makePositive; hestOptAdd(&hopt, "s", "scale", airTypeFloat, 1, 1, &scale, NULL, "Amount by which to scale deviatoric component of tensor."); hestOptAdd(&hopt, "fd", NULL, airTypeInt, 0, 0, &fixDet, NULL, "instead of fixing the per-sample trace (the default), fix the " "determinant (ellipsoid volume)"); hestOptAdd(&hopt, "mp", NULL, airTypeInt, 0, 0, &makePositive, NULL, "after changing the eigenvalues of the tensor, enforce their " "non-negative-ness. By default, no such constraint is imposed."); hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-", "input diffusion tensor volume", NULL, NULL, nrrdHestNrrd); hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-", "output image (floating point)"); mop = airMopNew(); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); USAGE(_tend_anscaleInfoL); PARSE(); airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); if (tenAnisoScale(nout, nin, scale, fixDet, makePositive)) { airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways); fprintf(stderr, "%s: trouble:\n%s\n", me, err); airMopError(mop); return 1; } if (nrrdSave(outS, nout, NULL)) { airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: trouble writing:\n%s\n", me, err); airMopError(mop); return 1; } airMopOkay(mop); return 0; }
int main(int argc, char *argv[]) { char *me; hestOpt *hopt; hestParm *hparm; airArray *mop; Nrrd *nin, *_nin; double *in, sym[21], eval[6], evec[36]; unsigned int rr, cc, ii, jj; me = argv[0]; mop = airMopNew(); hparm = hestParmNew(); hopt = NULL; airMopAdd(mop, hparm, (airMopper)hestParmFree, airMopAlways); hestOptAdd(&hopt, NULL, "matrix", airTypeOther, 1, 1, &_nin, NULL, "6x6 matrix", NULL, NULL, nrrdHestNrrd); hestParseOrDie(hopt, argc-1, argv+1, hparm, me, es6Info, AIR_TRUE, AIR_TRUE, AIR_TRUE); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); nin = nrrdNew(); airMopAdd(mop, nin, (airMopper)nrrdNuke, airMopAlways); if (!(2 == _nin->dim && 6 == _nin->axis[0].size && 6 == _nin->axis[1].size)) { fprintf(stderr, "%s: didn't get 2-D 6x6 matrix (got %u-D %ux%u)\n", me, _nin->dim, AIR_CAST(unsigned int, _nin->axis[0].size), AIR_CAST(unsigned int, _nin->axis[1].size)); airMopError(mop); return 1; }
int main(int argc, char *argv[]) { char *me; hestOpt *hopt; hestParm *hparm; airArray *mop; int size[3]; me = argv[0]; mop = airMopNew(); hparm = hestParmNew(); hopt = NULL; airMopAdd(mop, hparm, (airMopper)hestParmFree, airMopAlways); hestOptAdd(&hopt, "s", "sx sy sz", airTypeInt, 3, 3, size, "128 128 128", "dimensions of output volume"); hestParseOrDie(hopt, argc-1, argv+1, hparm, me, tmplInfo, AIR_TRUE, AIR_TRUE, AIR_TRUE); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); airMopOkay(mop); exit(0); }
int unrrdu_axdeleteMain(int argc, char **argv, char *me, hestParm *hparm) { hestOpt *opt = NULL; char *out, *err; Nrrd *nin, *nout, *ntmp; int pret, _axis; unsigned axis; airArray *mop; hestOptAdd(&opt, "a,axis", "axis", airTypeInt, 1, 1, &_axis, NULL, "dimension (axis index) of the axis to remove"); OPT_ADD_NIN(nin, "input nrrd"); OPT_ADD_NOUT(out, "output nrrd"); mop = airMopNew(); airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); USAGE(_unrrdu_axdeleteInfoL); PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); if (-1 == _axis) { ntmp = nrrdNew(); airMopAdd(mop, ntmp, (airMopper)nrrdNuke, airMopAlways); if (nrrdCopy(nout, nin)) { airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: error copying axis:\n%s", me, err); airMopError(mop); return 1; } for (axis=0; axis<nout->dim && nout->axis[axis].size > 1; axis++); while (axis<nout->dim) { if (nrrdAxesDelete(ntmp, nout, axis) || nrrdCopy(nout, ntmp)) { airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: error deleting axis:\n%s", me, err); airMopError(mop); return 1; } for (axis=0; axis<nout->dim && nout->axis[axis].size > 1; axis++); } } else { if (nrrdAxesDelete(nout, nin, _axis)) { airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: error deleting axis:\n%s", me, err); airMopError(mop); return 1; } } SAVE(out, nout, NULL); airMopOkay(mop); return 0; }
int unrrdu_dataMain(int argc, const char **argv, const char *me, hestParm *hparm) { hestOpt *opt = NULL; char *err, *inS=NULL; Nrrd *nin; NrrdIoState *nio; airArray *mop; int car, pret; mop = airMopNew(); hestOptAdd(&opt, NULL, "nin", airTypeString, 1, 1, &inS, NULL, "input nrrd"); airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); USAGE(_unrrdu_dataInfoL); PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); nio = nrrdIoStateNew(); airMopAdd(mop, nio, (airMopper)nrrdIoStateNix, airMopAlways); nio->skipData = AIR_TRUE; nio->keepNrrdDataFileOpen = AIR_TRUE; nin = nrrdNew(); airMopAdd(mop, nin, (airMopper)nrrdNuke, airMopAlways); if (nrrdLoad(nin, inS, nio)) { airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: error reading header:\n%s", me, err); airMopError(mop); return 1; } if (_nrrdDataFNNumber(nio) > 1) { fprintf(stderr, "%s: sorry, currently can't operate with multiple " "detached datafiles\n", me); airMopError(mop); return 1; } if (!( nrrdFormatNRRD == nio->format )) { fprintf(stderr, "%s: can only print data of NRRD format files\n", me); airMopError(mop); return 1; } car = fgetc(nio->dataFile); #ifdef _MSC_VER /* needed because otherwise printing a carraige return will automatically also produce a newline */ _setmode(_fileno(stdout), _O_BINARY); #endif while (EOF != car) { fputc(car, stdout); car = fgetc(nio->dataFile); } airFclose(nio->dataFile); airMopOkay(mop); return 0; }
int unrrdu_projectMain(int argc, const char **argv, const char *me, hestParm *hparm) { hestOpt *opt = NULL; char *out, *err; Nrrd *nin, *nout; unsigned int axis; int measr, pret, type; airArray *mop; OPT_ADD_AXIS(axis, "axis to project along"); hestOptAdd(&opt, "m,measure", "measr", airTypeEnum, 1, 1, &measr, NULL, "How to \"measure\" a scanline, by summarizing all its values " "with a single scalar. " NRRD_MEASURE_DESC, NULL, nrrdMeasure); hestOptAdd(&opt, "t,type", "type", airTypeOther, 1, 1, &type, "default", "type to use for output. By default (not using this option), " "the output type is determined auto-magically", NULL, NULL, &unrrduHestMaybeTypeCB); OPT_ADD_NIN(nin, "input nrrd"); OPT_ADD_NOUT(out, "output nrrd"); mop = airMopNew(); airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); USAGE(_unrrdu_projectInfoL); PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); if (nrrdProject(nout, nin, axis, measr, type)) { airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: error projecting nrrd:\n%s", me, err); airMopError(mop); return 1; } SAVE(out, nout, NULL); airMopOkay(mop); return 0; }
int limnpu_sortMain(int argc, char **argv, char *me, hestParm *hparm) { hestOpt *hopt = NULL; char *err, *perr; airArray *mop; int pret; limnPolyData *pld; Nrrd *nin; char *out; hestOptAdd(&hopt, NULL, "input lpld", airTypeOther, 1, 1, &pld, NULL, "input polydata filename", NULL, NULL, limnHestPolyDataLMPD); hestOptAdd(&hopt, NULL, "input nrrd", airTypeOther, 1, 1, &nin, NULL, "input nrrd filename", NULL, NULL, nrrdHestNrrd); hestOptAdd(&hopt, NULL, "output", airTypeString, 1, 1, &out, NULL, "output lpld filename"); mop = airMopNew(); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); USAGE(myinfo); PARSE(); airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); if (limnPolyDataPrimitiveSort(pld, nin)) { airMopAdd(mop, err = biffGetDone(LIMN), airFree, airMopAlways); fprintf(stderr, "%s: trouble:%s", me, err); airMopError(mop); return 1; } if (limnPolyDataSave(out, pld)) { airMopAdd(mop, err = biffGetDone(LIMN), airFree, airMopAlways); fprintf(stderr, "%s: trouble:%s", me, err); airMopError(mop); return 1; } airMopOkay(mop); return 0; }
int unrrdu_ccsettleMain(int argc, char **argv, char *me, hestParm *hparm) { hestOpt *opt = NULL; char *out, *err, *valS; Nrrd *nin, *nout, *nval=NULL; airArray *mop; int pret; mop = airMopNew(); hestOptAdd(&opt, "i,input", "nin", airTypeOther, 1, 1, &nin, NULL, "input nrrd", NULL, NULL, nrrdHestNrrd); hestOptAdd(&opt, "v,values", "filename", airTypeString, 1, 1, &valS, "", "Giving a filename here allows you to save out the mapping " "from new (settled) values to old values, in the form of a " "1-D lookup table"); OPT_ADD_NOUT(out, "output nrrd"); airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); USAGE(_unrrdu_ccsettleInfoL); PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); nout = nrrdNew(); airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); if (nrrdCCSettle(nout, airStrlen(valS) ? &nval : NULL, nin)) { airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways); fprintf(stderr, "%s: error settling connected components:\n%s", me, err); airMopError(mop); return 1; } if (nval) { airMopAdd(mop, nval, (airMopper)nrrdNuke, airMopAlways); } if (airStrlen(valS)) { SAVE(valS, nval, NULL); } SAVE(out, nout, NULL); airMopOkay(mop); return 0; }