|
From: <kin...@us...> - 2003-10-30 21:35:28
|
Update of /cvsroot/teem/teem/src/unrrdu
In directory sc8-pr-cvs1:/tmp/cvs-serv26362/unrrdu
Modified Files:
TODO.txt cmedian.c
Log Message:
API CHANGE: nrrd:
nrrdCheapMedian now takes a new argument, "pad", which tells it to
pad the input by the radius of the filter, prior to filtering, and then
crops the output. Without this, the samples along the boundary are left
unprocessed. Note: this functionality has migrated from "unu cmedian"
down into nrrd.
"unu cmedian", on the other hand, has a new command-line flag, "-c",
which tells it to slice along axis 0, run filtering on all slices, and
then join the results together. I was too chicken to add this the nrrd
API directly, but it may migrate there.
Index: TODO.txt
===================================================================
RCS file: /cvsroot/teem/teem/src/unrrdu/TODO.txt,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** TODO.txt 17 Sep 2003 02:12:06 -0000 1.16
--- TODO.txt 30 Oct 2003 21:35:25 -0000 1.17
***************
*** 1,2 ****
--- 1,4 ----
+ examples of usage with the important unu commands
+
make "unu make" into a nrrd function
Index: cmedian.c
===================================================================
RCS file: /cvsroot/teem/teem/src/unrrdu/cmedian.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** cmedian.c 23 Jul 2003 01:20:30 -0000 1.14
--- cmedian.c 30 Oct 2003 21:35:25 -0000 1.15
***************
*** 38,43 ****
hestOpt *opt = NULL;
char *out, *err;
! Nrrd *nin, *ntmp, *nout;
! int bins, radius, pad, pret, mode;
airArray *mop;
float wght;
--- 38,43 ----
hestOpt *opt = NULL;
char *out, *err;
! Nrrd *nin, *nout, *ntmp, **mnout;
! int bins, radius, pad, pret, mode, chan, ni, nsize;
airArray *mop;
float wght;
***************
*** 64,67 ****
--- 64,71 ----
"overcome our cheapness and correctly "
"handle the border. Obviously, this takes more memory.");
+ hestOptAdd(&opt, "c", NULL, airTypeInt, 0, 0, &chan, NULL,
+ "Slice the input along axis 0, run filtering on all slices, "
+ "and join the results back together. This is the way you'd "
+ "want to process color (multi-channel) images or volumes.");
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
***************
*** 77,118 ****
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
! if (pad) {
! ntmp=nrrdNew();
airMopAdd(mop, ntmp, (airMopper)nrrdNuke, airMopAlways);
! if (nrrdSimplePad(ntmp, nin, radius, nrrdBoundaryBleed)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
! fprintf(stderr, "%s: error padding:\n%s", me, err);
airMopError(mop);
return 1;
}
! /* We want to free up memory now that we have a padded copy of the
! input. We can't nuke the input because that will be a memory
! error with nrrdNuke() called by hestParseFree() called by
! airMopOkay(), but we can empty it without any harm */
! nrrdEmpty(nin);
! }
! else {
! ntmp = nin;
! }
!
! if (nrrdCheapMedian(nout, ntmp, mode, radius, wght, bins)) {
! airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
! fprintf(stderr, "%s: error doing cheap median:\n%s", me, err);
! airMopError(mop);
! return 1;
! }
!
! if (pad) {
! if (nrrdSimpleCrop(ntmp, nout, radius)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
! fprintf(stderr, "%s: error cropping:\n%s", me, err);
airMopError(mop);
return 1;
}
- SAVE(out, ntmp, NULL);
- }
- else {
- SAVE(out, nout, NULL);
}
airMopOkay(mop);
--- 81,122 ----
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
! if (chan) {
! nsize = nin->axis[0].size;
! mnout = (Nrrd **)calloc(nsize, sizeof(Nrrd));
! airMopAdd(mop, mnout, airFree, airMopAlways);
! ntmp = nrrdNew();
airMopAdd(mop, ntmp, (airMopper)nrrdNuke, airMopAlways);
! for (ni=0; ni<nsize; ni++) {
! if (nrrdSlice(ntmp, nin, 0, ni)) {
! airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
! fprintf(stderr, "%s: error slicing input at pos = %d:\n%s",
! me, ni, err);
! airMopError(mop);
! return 1;
! }
! airMopAdd(mop, mnout[ni] = nrrdNew(), (airMopper)nrrdNuke, airMopAlways);
! if (nrrdCheapMedian(mnout[ni], ntmp, pad, mode, radius, wght, bins)) {
! airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
! fprintf(stderr, "%s: error doing cheap median:\n%s", me, err);
! airMopError(mop);
! return 1;
! }
! }
! if (nrrdJoin(nout, (const Nrrd**)mnout, nsize, 0, AIR_TRUE)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
! fprintf(stderr, "%s: error doing final join:\n%s", me, err);
airMopError(mop);
return 1;
}
! } else {
! if (nrrdCheapMedian(nout, nin, pad, mode, radius, wght, bins)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
! fprintf(stderr, "%s: error doing cheap median:\n%s", me, err);
airMopError(mop);
return 1;
}
}
+
+ SAVE(out, nout, NULL);
airMopOkay(mop);
|