Пример #1
0
int
miteRayBegin(miteThread *mtt, miteRender *mrr, miteUser *muu,
             int uIndex, int vIndex,
             double rayLen,
             double rayStartWorld[3], double rayStartIndex[3],
             double rayDirWorld[3], double rayDirIndex[3]) {
  airPtrPtrUnion appu;
  AIR_UNUSED(mrr);
  AIR_UNUSED(rayStartWorld);
  AIR_UNUSED(rayStartIndex);
  AIR_UNUSED(rayDirIndex);

  mtt->ui = uIndex;
  mtt->vi = vIndex;
  mtt->rayStep = (muu->rayStep*rayLen /
                  (muu->hctx->cam->vspFaar - muu->hctx->cam->vspNeer));
  if (!uIndex) {
    fprintf(stderr, "%d/%d ", vIndex, muu->hctx->imgSize[1]);
    fflush(stderr);
  }
  mtt->verbose = (uIndex == muu->verbUi && vIndex == muu->verbVi);
  mtt->skip = (muu->verbUi >= 0 && muu->verbVi >= 0
               && !mtt->verbose);
  if (mtt->verbose) {
    /* create muu->ndebug */
    muu->ndebug = nrrdNew();
    /* we want to store the value and index for each txf domain variable,
       plus the RGBAZ computed for that sample */
    muu->ndebug->axis[0].size = 2*mtt->stageNum + 5;
    /* we really do want to associate ndebug with the miteUser's mop,
       because the information stored in it has to persist for as long as
       the user wants: mite itself doesn't call miteUserNix */
    airMopAdd(muu->umop, muu->ndebug, (airMopper)nrrdNuke, airMopAlways);
    /* but the scope of the debug array allocation is within this ray */
    muu->debugArr = airArrayNew((appu.d = &(muu->debug), appu.v),
                                NULL, sizeof(double), 128);
  }
  mtt->raySample = 0;
  mtt->RR = mtt->GG = mtt->BB = 0.0;
  mtt->TT = 1.0;
  mtt->ZZ = AIR_NAN;
  ELL_3V_SCALE(mtt->V, -1, rayDirWorld);

  return 0;
}
Пример #2
0
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;
}
Пример #3
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;
}
Пример #4
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;
}
Пример #5
0
int
limnpu_measMain(int argc, char **argv, char *me, hestParm *hparm) {
  hestOpt *hopt = NULL;
  char *err, *perr;
  airArray *mop;
  int pret;

  limnPolyData *pld;
  Nrrd *nout;
  char *out;

  hestOptAdd(&hopt, NULL, "input", airTypeOther, 1, 1, &pld, NULL,
             "input polydata filename",
             NULL, NULL, limnHestPolyDataLMPD);
  hestOptAdd(&hopt, NULL, "output", airTypeString, 1, 1, &out, NULL,
             "output nrrd filename");
  
  mop = airMopNew();
  airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);

  USAGE(myinfo);
  PARSE();
  airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (limnPolyDataPrimitiveArea(nout, pld)) {
    airMopAdd(mop, err = biffGetDone(LIMN), airFree, airMopAlways);
    fprintf(stderr, "%s: trouble:%s", me, err);
    airMopError(mop);
    return 1;
  }

  if (nrrdSave(out, nout, NULL)) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: trouble:%s", me, err);
    airMopError(mop);
    return 1;
  }
  
  airMopOkay(mop);
  return 0;
}
Пример #6
0
int
unrrdu_permuteMain(int argc, char **argv, char *me, hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  Nrrd *nin, *nout;
  unsigned int *perm, permLen;
  int pret;
  airArray *mop;

  hestOptAdd(&opt, "p,permute", "ax0 ax1", airTypeUInt, 1, -1, &perm, NULL,
             "new axis ordering", &permLen);
  OPT_ADD_NIN(nin, "input nrrd");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_permuteInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
  
  if (!( permLen == nin->dim )) {
    fprintf(stderr,"%s: # axes in permutation (%u) != nrrd dim (%d)\n",
            me, permLen, nin->dim);
    airMopError(mop);
    return 1;
  }

  if (nrrdAxesPermute(nout, nin, perm)) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: error permuting nrrd:\n%s", me, err);
    airMopError(mop);
    return 1;
  }

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}
Пример #7
0
int
unrrdu_untileMain(int argc, const char **argv, const char *me,
                  hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  Nrrd *nin, *nout;
  unsigned int axes[3];
  int pret;
  size_t size[2];
  airArray *mop;

  hestOptAdd(&opt, "a,axis", "axMerge ax0 ax1", airTypeUInt, 3, 3, axes, NULL,
             "the slow parts of axes ax0 and ax1 are merged into a (new) "
             "axis axMerge, with the axis ax0 part being faster than ax1.");
  hestOptAdd(&opt, "s,size", "size0 size1", airTypeSize_t, 2, 2, size, NULL,
             "the slow parts of axes ax0 and ax1 are taken to have size "
             "size0 and size1, respectively, and axis axMerge will have "
             "size size0*size1.");
  OPT_ADD_NIN(nin, "input nrrd");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_untileInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (nrrdUntile2D(nout, nin, axes[1], axes[2], axes[0], size[0], size[1])) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: error tiling nrrd:\n%s", me, err);
    airMopError(mop);
    return 1;
  }

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}
int
tend_sliceMain(int argc, char **argv, char *me, hestParm *hparm) {
  int pret;
  hestOpt *hopt = NULL;
  char *perr, *err;
  airArray *mop;

  char *outS;
  int axis, pos, dim;
  Nrrd *nin, *nout;

  hestOptAdd(&hopt, "a", "axis", airTypeInt, 1, 1, &axis, NULL,
             "axis along which to slice");
  hestOptAdd(&hopt, "p", "pos", airTypeInt, 1, 1, &pos, NULL,
             "position to slice at");
  hestOptAdd(&hopt, "d", "dim", airTypeInt, 1, 1, &dim, "3",
             "dimension of desired tensor output, can be either 2 or 3");
  hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-",
             "input diffusion tensor volume", NULL, NULL, nrrdHestNrrd);
  hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-",
             "output tensor slice");

  mop = airMopNew();
  airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
  USAGE(_tend_sliceInfoL);
  PARSE();
  airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);
  airMopAdd(mop, nout=nrrdNew(), (airMopper)nrrdNuke, airMopAlways);

  if (tenSlice(nout, nin, axis, pos, dim)) {
    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;
}
Пример #9
0
Nrrd* LBLReader::Convert(int t, int c, bool get_max)
{
   int64_t pos = m_path_name.find_last_of('.');
   if (pos == -1)
      return 0;
   wstring str_name = m_path_name.substr(0, pos);
   wostringstream strs;
   strs << str_name /*<< "_t" << t << "_c" << c*/ << ".lbl";
   str_name = strs.str();

   Nrrd *output = nrrdNew();
   NrrdIoState *nio = nrrdIoStateNew();
   nrrdIoStateSet(nio, nrrdIoStateSkipData, AIR_TRUE);
   string str;
   str.assign(str_name.length(), 0);
   for (int i=0; i<(int)str_name.length(); i++)
      str[i] = (char)str_name[i];
   if (nrrdLoad(output, str.c_str(), nio))
      return 0;
   nio = nrrdIoStateNix(nio);
   if (output->dim != 3 ||
         (output->type != nrrdTypeInt &&
          output->type != nrrdTypeUInt))
   {
      delete []output->data;
      nrrdNix(output);
      return 0;
   }
   int slice_num = int(output->axis[2].size);
   int x_size = int(output->axis[0].size);
   int y_size = int(output->axis[1].size);
   int data_size = slice_num * x_size * y_size;
   output->data = new unsigned int[data_size];

   if (nrrdLoad(output, str.c_str(), NULL))
   {
      delete []output->data;
      nrrdNix(output);
      return 0;
   }

   return output;
}
Пример #10
0
int
tend_tconvMain(int argc, const char **argv, const char *me,
               hestParm *hparm) {
  int pret;
  hestOpt *hopt = NULL;
  char *perr, *err;
  airArray *mop;

  int ttype[2];
  Nrrd *nin, *nout;
  char *outS;

  hestOptAdd(&hopt, "t", "inType outType", airTypeEnum, 2, 2, ttype, NULL,
             "given input and desired output type of triples",
             NULL, tenTripleType);
  hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-",
             "input array of triples", NULL, NULL, nrrdHestNrrd);
  hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-",
             "output array");

  mop = airMopNew();
  airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
  USAGE(_tend_tconvInfoL);
  PARSE();
  airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
  if (tenTripleConvert(nout, ttype[1], nin, ttype[0])) {
    airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways);
    fprintf(stderr, "%s: trouble converting:\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;
}
Пример #11
0
int
tend_unmfMain(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;

  hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, NULL,
             "input diffusion tensor volume "
             "(sorry, can't use usual default of \"-\" for stdin "
             "because of hest quirk)",
             NULL, NULL, nrrdHestNrrd);
  hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-",
             "output tensor volume");

  mop = airMopNew();
  airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
  USAGE(_tend_unmfInfoL);
  PARSE();
  airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
  if (tenMeasurementFrameReduce(nout, nin)) {
    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;
}
Пример #12
0
int
unrrdu_convertMain(int argc, char **argv, char *me, hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  Nrrd *nin, *nout;
  int type, pret, E, doClamp;
  airArray *mop;

  OPT_ADD_TYPE(type, "type to convert to", NULL);
  OPT_ADD_NIN(nin, "input nrrd");
  hestOptAdd(&opt, "clamp", NULL, airTypeInt, 0, 0, &doClamp, NULL,
             "clamp input values to representable range of values of "
             "output type, to avoid wrap-around problems");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_convertInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (doClamp) {
    E = nrrdClampConvert(nout, nin, type);
  } else {
    E = nrrdConvert(nout, nin, type);
  }
  if (E) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: error converting nrrd:\n%s", me, err);
    airMopError(mop);
    return 1;
  }

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}
Пример #13
0
int
rva_gridMain(int argc, const char **argv, const char *me,
             hestParm *hparm) {
  hestOpt *hopt = NULL;
  char *err;
  airArray *mop;

  rvaLattSpec *lsp;
  double radius;
  char *outStr;
  Nrrd *nout;

  mop = airMopNew();
  hopt = NULL;
  hestOptAdd(&hopt, NULL, "latt", airTypeOther, 1, 1, &lsp, NULL,
             "lattice definition", NULL, NULL, rvaHestLattSpec);
  hestOptAdd(&hopt, "r", "radius", airTypeDouble, 1, 1, &radius, "1",
             "radius limit");
  hestOptAdd(&hopt, "o", "fname", airTypeString, 1, 1, &outStr, "-",
             "output filename");
  hestParseOrDie(hopt, argc, argv, hparm,
                 me, longInfo, 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);
  if (rvaGrid(nout, lsp, radius)) {
    airMopAdd(mop, err=biffGetDone(RVA), airFree, airMopAlways);
    fprintf(stderr, "%s: problem:\n%s", me, err);
    airMopError(mop); return 1;
  }

  if (nrrdSave(outStr, nout, NULL)) {
    airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: problem saving:\n%s", me, err);
    airMopError(mop); return 1;
  }

  airMopOkay(mop);
  return 0;
}
Пример #14
0
int
_baneClipAnswer_TopN(int *countP, Nrrd *hvol, double *clipParm) {
  static const char me[]="_baneClipAnwer_TopN";
  Nrrd *copy;
  int *hits, tmp;
  size_t num;

  if (nrrdCopy(copy=nrrdNew(), hvol)) {
    biffMovef(BANE, NRRD, "%s: couldn't create copy of histovol", me);
    return 1;
  }
  hits = (int *)copy->data;
  num = nrrdElementNumber(copy);
  qsort(hits, num, sizeof(int), nrrdValCompare[nrrdTypeInt]);
  tmp = AIR_CLAMP(0, (int)clipParm[0], (int)num-1);
  *countP = hits[num-tmp-1];
  nrrdNuke(copy);

  return 0;
}
Пример #15
0
int
unrrdu_tileMain(int argc, const char **argv, const char *me,
                hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  Nrrd *nin, *nout;
  int pret;
  size_t size[2];
  unsigned int axes[3];
  airArray *mop;

  hestOptAdd(&opt, "a,axis", "axSplit ax0 ax1", airTypeUInt, 3, 3, axes, NULL,
             "axSplit is divided and merged with ax0 and ax1");
  hestOptAdd(&opt, "s,size", "fast slow", airTypeSize_t, 2, 2, size, NULL,
             "fast and slow axis sizes to produce as result of splitting "
             "the axSplit axis.");
  OPT_ADD_NIN(nin, "input nrrd");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_tileInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (nrrdTile2D(nout, nin, axes[1], axes[2], axes[0], size[0], size[1])) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: error tiling nrrd:\n%s", me, err);
    airMopError(mop);
    return 1;
  }

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}
Пример #16
0
int
unrrdu_axsplitMain(int argc, const char **argv, const char *me,
                   hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  Nrrd *nin, *nout;
  int pret;
  size_t size[2];
  unsigned int axis;
  airArray *mop;

  OPT_ADD_AXIS(axis, "dimension (axis index) to split at");
  hestOptAdd(&opt, "s,size", "fast, slow sizes", airTypeSize_t, 2, 2,
             size, NULL,
             "fast and slow axis sizes to produce as result of splitting "
             "given axis.");
  OPT_ADD_NIN(nin, "input nrrd");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_axsplitInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (nrrdAxesSplit(nout, nin, axis, size[0], size[1])) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: error splitting axis:\n%s", me, err);
    airMopError(mop);
    return 1;
  }

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}
Пример #17
0
void
makeSceneAntialias(limnCamera *cam, echoRTParm *parm,
                   echoObject **sceneP, airArray **lightArrP) {
  echoObject *scene, *rect;
  Nrrd *ntext;

  *sceneP = scene = echoObjectNew(echoList);
  *lightArrP = echoLightArrayNew();

  ELL_3V_SET(cam->from, 0, 0, 10);
  ELL_3V_SET(cam->at,   0, 0, 0);
  ELL_3V_SET(cam->up,   0, 1, 0);
  cam->uRange[0] = -3.7;
  cam->uRange[1] = 3.7;
  cam->vRange[0] = -3.7;
  cam->vRange[1] = 3.7;

  parm->jitterType = echoJitterGrid;
  parm->numSamples = 1;
  parm->imgResU = 300;
  parm->imgResV = 300;
  parm->aperture = 0.0;
  parm->renderLights = AIR_FALSE;
  parm->renderBoxes = AIR_FALSE;
  parm->seedRand = AIR_FALSE;
  parm->maxRecDepth = 10;
  parm->shadow = 1.0;

  nrrdLoad(ntext = nrrdNew(), "chirp.nrrd", NULL);
  rect = echoObjectNew(echoRectangle);
  echoRectangleSet(rect,
                         -3, -3, 0,
                         6, 0, 0,
                         0, 6, 0);
  echoMatterPhongSet(rect, 1, 1, 1, 1.0,
                     1.0, 0.0, 0.0, 1);
  echoMatterTextureSet(rect, ntext);
  echoObjectAdd(scene, rect);

  return;
}
Пример #18
0
int
unrrdu_axinsertMain(int argc, char **argv, char *me, hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err, *label;
  Nrrd *nin, *nout;
  int pret;
  unsigned int axis;
  airArray *mop;

  OPT_ADD_AXIS(axis, "dimension (axis index) at which to insert the new axis");
  hestOptAdd(&opt, "l,label", "label", airTypeString, 1, 1, &label, "",
             "label to associate with new axis");
  OPT_ADD_NIN(nin, "input nrrd");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_axinsertInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (nrrdAxesInsert(nout, nin, axis)) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: error inserting axis:\n%s", me, err);
    airMopError(mop);
    return 1;
  }
  if (strlen(label)) {
    nout->axis[axis].label = (char *)airFree(nout->axis[axis].label);
    nout->axis[axis].label = airStrdup(label);
  }

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}
Пример #19
0
int
tend_evalpowMain(int argc, char **argv, char *me, hestParm *hparm) {
  int pret;
  hestOpt *hopt = NULL;
  char *perr, *err;
  airArray *mop;

  Nrrd *nin, *nout;
  char *outS;
  float expo;
  
  hestOptAdd(&hopt, "p", "power", airTypeFloat, 1, 1, &expo, NULL,
             "Power to which to raise all the eigenvalues.");
  hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-",
             "input diffusion tensor volume", NULL, NULL, nrrdHestNrrd);
  hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-",
             "output tensor volume");

  mop = airMopNew();
  airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
  USAGE(_tend_evalpowInfoL);
  PARSE();
  airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
  if (tenEigenvaluePower(nout, nin, expo)) {
    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;
}
Пример #20
0
int
unrrdu_unblockMain(int argc, const char **argv, const char *me,
                   hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  Nrrd *nin, *nout;
  int type, pret;
  size_t blockSize;
  airArray *mop;

  OPT_ADD_TYPE(type, "type to unblock to", NULL);
  hestOptAdd(&opt, "bs", "blocksize", airTypeSize_t, 1, 1, &blockSize, "0",
             "Useful only if *output* type is also block: the size of "
             "blocks in output nrrd");
  OPT_ADD_NIN(nin, "input nrrd");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_unblockInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  nout->blockSize = blockSize;
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (nrrdUnblock(nout, nin, type)) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: error unblocking nrrd:\n%s", me, err);
    airMopError(mop);
    return 1;
  }

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}
Пример #21
0
int
unrrdu_ccadjMain(int argc, const char **argv, const char *me,
                 hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  Nrrd *nin, *nout;
  airArray *mop;
  int pret;
  unsigned int conny;

  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_ccadjInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (nrrdCCAdjacency(nout, nin, conny)) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: error finding adjacencies:\n%s", me, err);
    airMopError(mop);
    return 1;
  }

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}
Пример #22
0
int
tend_shrinkMain(int argc, char **argv, char *me, hestParm *hparm) {
  int pret;
  hestOpt *hopt = NULL;
  char *perr, *err;
  airArray *mop;

  Nrrd *nin, *nout;
  char *outS;

  hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-",
             "input diffusion tensor volume, with 9 matrix components "
             "per sample",
             NULL, NULL, nrrdHestNrrd);
  hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, NULL,
             "output tensor volume, with the 7 values per sample");

  mop = airMopNew();
  airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
  USAGE(_tend_shrinkInfoL);
  PARSE();
  airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
  if (tenShrink(nout, NULL, nin)) {
    airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways);
    fprintf(stderr, "%s: trouble shrinking tensors:\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;
}
Пример #23
0
int
tkwbExpandImageInfo(tkwbSlide **slide) {
    char me[]="tkwbExpandImageInfo", err[BIFF_STRLEN], *image;
    Nrrd *nimg;
    int si, sx, sy, len;
    airArray *mop;

    mop = airMopNew();
    nimg = nrrdNew();
    airMopAdd(mop, nimg, (airMopper)nrrdNuke, airMopAlways);
    for (si=0; slide[si]; si++) {
        if (nrrdLoad(nimg, slide[si]->image, NULL)) {
            sprintf(err, "%s: trouble reading slide image \"%s\"",
                    me, slide[si]->image);
            biffMove(TKWB, err, NRRD);
            airMopError(mop);
            return 1;
        }
        if (!nrrdFormatPNG->fitsInto(nimg, nrrdEncodingGzip, AIR_TRUE)) {
            sprintf(err, "%s: slide image \"%s\" doesn't seem to be an image",
                    me, slide[si]->image);
            biffMove(TKWB, err, NRRD);
            airMopError(mop);
            return 1;
        }
        sx = nimg->axis[nimg->dim-2].size;
        sy = nimg->axis[nimg->dim-1].size;
        len = (strlen("<img width=xxxx height=xxxx src=\"\">")
               + strlen(slide[si]->image) + 1);
        image = (char *)calloc(len, sizeof(char));
        sprintf(image, "<img width=%d height=%d src=\"%s\">",
                sx, sy, slide[si]->image);
        free(slide[si]->image);
        slide[si]->image = image;
    }

    airMopOkay(mop);
    return 0;
}
Пример #24
0
float *
_baneTRexRead(char *fname) {
  char me[]="_baneTRexRead";

  if (nrrdLoad(baneNpos=nrrdNew(), fname, NULL)) {
    fprintf(stderr, "%s: !!! trouble reading \"%s\":\n%s\n", me, 
            fname, biffGet(NRRD));
    return NULL;
  }
  if (banePosCheck(baneNpos, 1)) {
    fprintf(stderr, "%s: !!! didn't get a valid p(x) file:\n%s\n", me, 
            biffGet(BANE));
    return NULL;
  }
  if (TREX_LUTLEN != baneNpos->axis[0].size) {
    fprintf(stderr, "%s: !!! need a length %d p(x) (not " _AIR_SIZE_T_CNV
            ")\n", me, TREX_LUTLEN, baneNpos->axis[0].size); 
    return NULL;
  }

  return (float *)baneNpos->data;
}
Пример #25
0
//struct Function;
void callDiderot(char *Outfile, int type, void *valM, int imgResU,int imgResV,  float stepSize){
  
    basic_d2s_sample_World_t *wrld = basic_d2s_sample_New ();
    
    if (wrld == 0) {
	//fprintf (stderr, "Unable to create Diderot world\n");
	exit (1);
    }
    
    basic_d2s_sample_Init (wrld);//initialize it.
    //initialize input vars
    basic_d2s_sample_InVarSet_m (wrld, valM);
    basic_d2s_sample_InVarSet_stepSize(wrld,stepSize);
    basic_d2s_sample_InVarSet_imgResU(wrld,imgResU);
    basic_d2s_sample_InVarSet_imgResV(wrld,imgResV);
    
    // nrrd for getting computational state
    Nrrd *nData = nrrdNew();
    
    if (basic_d2s_sample_Initially (wrld)) {//intialize set of strands
        // error
	fprintf(stderr, "Error initializing world: %s", basic_d2s_sample_GetErrors(wrld));
	exit(1);
    }
    int nSteps = basic_d2s_sample_Run (wrld, 0);
    //second paramter is the limit to # of steps.
    //0-to termination
    
    // change here for output var
    if (basic_d2s_sample_OutputGet_out(wrld, nData)) {
        // error
	fprintf(stderr, "Error getting nrrd data: %s", basic_d2s_sample_GetErrors(wrld));
	exit(1);
    }

    WriteFile(nData, type, Outfile);
    basic_d2s_sample_Shutdown (wrld);

}
Пример #26
0
int
tend_makeMain(int argc, char **argv, char *me, hestParm *hparm) {
  int pret;
  hestOpt *hopt = NULL;
  char *perr, *err;
  airArray *mop;

  Nrrd *nin[3], *nout;
  char *outS;

  hestOptAdd(&hopt, "i", "conf evals evecs", airTypeOther, 3, 3, nin, NULL,
             "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_makeInfoL);
  JUSTPARSE();
  airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
  if (tenMake(nout, nin[0], nin[1], nin[2])) {
    airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways);
    fprintf(stderr, "%s: trouble making tensor volume:\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;
}
Пример #27
0
int
unrrdu_swapMain(int argc, const char **argv, const char *me,
                hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  Nrrd *nin, *nout;
  int pret;
  unsigned int ax[2];
  airArray *mop;

  hestOptAdd(&opt, "a,axis", "axisA axisB", airTypeUInt, 2, 2, ax, NULL,
             "the two axes to switch (0-based numbering)");
  OPT_ADD_NIN(nin, "input nrrd");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_swapInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (nrrdAxesSwap(nout, nin, ax[0], ax[1])) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: error swapping nrrd:\n%s", me, err);
    airMopError(mop);
    return 1;
  }

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}
Пример #28
0
int
unrrdu_reshapeMain(int argc, char **argv, char *me, hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  Nrrd *nin, *nout;
  int pret;
  size_t *size;
  unsigned int sizeLen;
  airArray *mop;

  hestOptAdd(&opt, "s,size", "sz0 sz1 ", airTypeSize_t, 1, -1, &size, NULL,
             "new axes sizes", &sizeLen);
  OPT_ADD_NIN(nin, "input nrrd");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_reshapeInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (nrrdReshape_nva(nout, nin, sizeLen, size)) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: error reshaping nrrd:\n%s", me, err);
    airMopError(mop);
    return 1;
  }

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}
Пример #29
0
/*
** DOES use biff
*/
meetPullVol *
meetPullVolCopy(const meetPullVol *mpv) {
  static const char me[]="meetPullVolCopy";
  meetPullVol *ret;
  unsigned int si;
  airArray *mop;

  mop = airMopNew();
  ret = meetPullVolNew();
  airMopAdd(mop, ret, (airMopper)meetPullVolNix, airMopOnError);
  /* HEY: hope this is okay for dynamic kinds */
  ret->kind = mpv->kind;
  ret->fileName = airStrdup(mpv->fileName);
  ret->volName = airStrdup(mpv->volName);
  if (mpv->sbp) {
    ret->sbp = gageStackBlurParmNew();
    if (gageStackBlurParmCopy(ret->sbp, mpv->sbp)) {
      biffMovef(MEET, GAGE, "%s: problem", me);
      airMopError(mop); return NULL;
    }
  }
  ret->leeching = AIR_FALSE;
  ret->derivNormSS = mpv->derivNormSS;
  ret->recomputedSS = AIR_FALSE;
  ret->derivNormBiasSS = mpv->derivNormBiasSS;
  if (mpv->sbp) {
    ret->nin = NULL;
    ret->ninSS = AIR_CALLOC(ret->sbp->num, Nrrd *);
    for (si=0; si<mpv->sbp->num; si++) {
      ret->ninSS[si] = nrrdNew();
      if (nrrdCopy(ret->ninSS[si], mpv->ninSS[si])) {
        biffMovef(MEET, NRRD, "%s: problem with ninSS[%u]", me, si);
        airMopError(mop); return NULL;
      }
    }
  } else {
Пример #30
0
int
unrrdu_substMain(int argc, char **argv, char *me, hestParm *hparm) {
  hestOpt *opt = NULL;
  char *out, *err;
  int pret;
  Nrrd *nin, *nsubst, *nout;
  airArray *mop;

  hestOptAdd(&opt, "s,subst", "subst", airTypeOther, 1, 1, &nsubst, NULL,
             "substition table to map input nrrd through",
             NULL, NULL, nrrdHestNrrd);
  OPT_ADD_NIN(nin, "input nrrd");
  OPT_ADD_NOUT(out, "output nrrd");

  mop = airMopNew();
  airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);

  USAGE(_unrrdu_substInfoL);
  PARSE();
  airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);

  nout = nrrdNew();
  airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);

  if (nrrdApply1DSubstitution(nout, nin, nsubst)) {
    airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
    fprintf(stderr, "%s: trouble applying SUBST:\n%s", me, err);
    airMopError(mop);
    return 1;
  }

  SAVE(out, nout, NULL);

  airMopOkay(mop);
  return 0;
}