|
From: <kin...@us...> - 2023-07-11 23:58:21
|
Revision: 7078
http://sourceforge.net/p/teem/code/7078
Author: kindlmann
Date: 2023-07-11 23:58:18 +0000 (Tue, 11 Jul 2023)
Log Message:
-----------
Start of shifting hest usage to non-var-args typed functions
Modified Paths:
--------------
teem/trunk/src/unrrdu/1op.c
teem/trunk/src/unrrdu/2op.c
teem/trunk/src/unrrdu/3op.c
teem/trunk/src/unrrdu/crop.c
teem/trunk/src/unrrdu/make.c
teem/trunk/src/unrrdu/minmax.c
teem/trunk/src/unrrdu/mlut.c
teem/trunk/src/unrrdu/mrmap.c
teem/trunk/src/unrrdu/ninspect.c
teem/trunk/src/unrrdu/pad.c
teem/trunk/src/unrrdu/permute.c
teem/trunk/src/unrrdu/privateUnrrdu.h
teem/trunk/src/unrrdu/project.c
teem/trunk/src/unrrdu/quantize.c
teem/trunk/src/unrrdu/resample.c
teem/trunk/src/unrrdu/reshape.c
teem/trunk/src/unrrdu/rmap.c
teem/trunk/src/unrrdu/save.c
teem/trunk/src/unrrdu/shuffle.c
teem/trunk/src/unrrdu/slice.c
teem/trunk/src/unrrdu/splice.c
teem/trunk/src/unrrdu/sselect.c
teem/trunk/src/unrrdu/subst.c
teem/trunk/src/unrrdu/swap.c
teem/trunk/src/unrrdu/tile.c
teem/trunk/src/unrrdu/unblock.c
teem/trunk/src/unrrdu/uncmt.c
teem/trunk/src/unrrdu/undos.c
teem/trunk/src/unrrdu/unorient.c
teem/trunk/src/unrrdu/unquantize.c
teem/trunk/src/unrrdu/untile.c
teem/trunk/src/unrrdu/vidicon.c
teem/trunk/src/unrrdu/w2i.c
Modified: teem/trunk/src/unrrdu/1op.c
===================================================================
--- teem/trunk/src/unrrdu/1op.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/1op.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -29,47 +29,47 @@
static int
unrrdu_1opMain(int argc, const char **argv, const char *me, hestParm *hparm) {
hestOpt *opt = NULL;
- char *out, *err, *seedS;
+ char *out, *err;
Nrrd *nin, *nout, *ntmp = NULL;
int op, pret, type;
airArray *mop;
- unsigned int seed;
+ unsigned int seed, seedOI;
- hestOptAdd(&opt, NULL, "operator", airTypeEnum, 1, 1, &op, NULL,
- "Unary operator. Possibilities include:\n "
- "\b\bo \"-\": negative (multiply by -1.0)\n "
- "\b\bo \"r\": reciprocal (1.0/value)\n "
- "\b\bo \"sin\", \"cos\", \"tan\", \"asin\", \"acos\", \"atan\": "
- "same as in C\n "
- "\b\bo \"exp\", \"log\", \"log10\": same as in C\n "
- "\b\bo \"log1p\", \"expm1\": accurate log(x+1) and exp(x)-1\n "
- "\b\bo \"log2\": log base 2\n "
- "\b\bo \"sqrt\", \"cbrt\", \"ceil\", \"floor\": same as in C\n "
- "\b\bo \"erf\": error function (integral of Gaussian)\n "
- "\b\bo \"rup\", \"rdn\": round up or down to integral value\n "
- "\b\bo \"abs\": absolute value\n "
- "\b\bo \"sgn\": -1, 0, 1 if value is <0, ==0, or >0\n "
- "\b\bo \"exists\": 1 iff not NaN or +/-Inf, 0 otherwise\n "
- "\b\bo \"rand\": random value in [0.0,1.0), "
- "no relation to input\n "
- "\b\bo \"nrand\": random sample from normal distribution with "
- "mean 0.0 and stdv 1.0, no relation to input\n "
- "\b\bo \"if\": if input is non-zero, 1, else 0\n "
- "\b\bo \"0\": output always 0\n "
- "\b\bo \"1\": output always 1",
- NULL, nrrdUnaryOp);
- hestOptAdd(&opt, "s,seed", "seed", airTypeString, 1, 1, &seedS, "",
- "seed value for RNG for rand and nrand, so that you "
- "can get repeatable results between runs, or, "
- "by not using this option, the RNG seeding will be "
- "based on the current time");
- hestOptAdd(&opt, "t,type", "type", airTypeOther, 1, 1, &type, "default",
- "convert input nrrd to this type prior to "
- "doing operation. Useful when desired output is float "
- "(e.g., with log1p), but input is integral. By default "
- "(not using this option), the types of "
- "the input nrrds are left unchanged.",
- NULL, NULL, &unrrduHestMaybeTypeCB);
+ hestOptAdd_1_Enum(&opt, NULL, "operator", &op, NULL,
+ "Unary operator. Possibilities include:\n "
+ "\b\bo \"-\": negative (multiply by -1.0)\n "
+ "\b\bo \"r\": reciprocal (1.0/value)\n "
+ "\b\bo \"sin\", \"cos\", \"tan\", \"asin\", \"acos\", \"atan\": "
+ "same as in C\n "
+ "\b\bo \"exp\", \"log\", \"log10\": same as in C\n "
+ "\b\bo \"log1p\", \"expm1\": accurate log(x+1) and exp(x)-1\n "
+ "\b\bo \"log2\": log base 2\n "
+ "\b\bo \"sqrt\", \"cbrt\", \"ceil\", \"floor\": same as in C\n "
+ "\b\bo \"erf\": error function (integral of Gaussian)\n "
+ "\b\bo \"rup\", \"rdn\": round up or down to integral value\n "
+ "\b\bo \"abs\": absolute value\n "
+ "\b\bo \"sgn\": -1, 0, 1 if value is <0, ==0, or >0\n "
+ "\b\bo \"exists\": 1 iff not NaN or +/-Inf, 0 otherwise\n "
+ "\b\bo \"rand\": random value in [0.0,1.0), "
+ "no relation to input\n "
+ "\b\bo \"nrand\": random sample from normal distribution with "
+ "mean 0.0 and stdv 1.0, no relation to input\n "
+ "\b\bo \"if\": if input is non-zero, 1, else 0\n "
+ "\b\bo \"0\": output always 0\n "
+ "\b\bo \"1\": output always 1",
+ nrrdUnaryOp);
+ seedOI = hestOptAdd_1_UInt(&opt, "s,seed", "seed", &seed, "0",
+ "seed value for random number generator (RNG), to "
+ "enable repeatable results between runs, or, "
+ "by not using this option, the RNG seeding will be "
+ "based on the current time");
+ hestOptAdd_1_Other(&opt, "t,type", "type", &type, "default",
+ "convert input nrrd to this type prior to "
+ "doing operation. Useful when desired output is float "
+ "(e.g., with log1p), but input is integral. By default "
+ "(not using this option), the types of "
+ "the input nrrds are left unchanged.",
+ &unrrduHestMaybeTypeCB);
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
@@ -99,14 +99,8 @@
** if (nrrdUnaryOpRand == op
** || nrrdUnaryOpNormalRand == op) {
*/
- if (airStrlen(seedS)) {
- if (1 != sscanf(seedS, "%u", &seed)) {
- fprintf(stderr, "%s: couldn't parse seed \"%s\" as uint\n", me, seedS);
- airMopError(mop);
- return 1;
- } else {
- airSrandMT(seed);
- }
+ if (hestSourceDefault != opt[seedOI].source) {
+ airSrandMT(seed);
} else {
/* got no request for specific seed */
airSrandMT(AIR_UINT(airTime()));
Modified: teem/trunk/src/unrrdu/2op.c
===================================================================
--- teem/trunk/src/unrrdu/2op.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/2op.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -33,60 +33,59 @@
static int
unrrdu_2opMain(int argc, const char **argv, const char *me, hestParm *hparm) {
hestOpt *opt = NULL;
- char *out, *err, *seedS;
+ char *out, *err;
NrrdIter *in1, *in2;
Nrrd *nout, *ntmp = NULL;
int op, type, E, pret, which;
airArray *mop;
- unsigned int seed;
+ unsigned int seed, seedOI;
- hestOptAdd(&opt, NULL, "operator", airTypeEnum, 1, 1, &op, NULL,
- "Binary operator. Possibilities include:\n "
- "\b\bo \"+\", \"-\", \"x\", \"/\": "
- "add, subtract, multiply, divide\n "
- "\b\bo \"+c\", \"-c\", \"xc\": add, subtract, multiply, with "
- "clamping to range of output, in case its integral\n "
- "\b\bo \"^\": exponentiation (pow)\n "
- "\b\bo \"spow\": signed exponentiation: sgn(x)pow(abs(x),p)\n "
- "\b\bo \"fpow\": like spow but with curves flipped\n "
- "\b\bo \"%\": integer modulo\n "
- "\b\bo \"fmod\": same as fmod() in C\n "
- "\b\bo \"atan2\": same as atan2() in C\n "
- "\b\bo \"min\", \"max\": minimum, maximum\n "
- "\b\bo \"lt\", \"lte\", \"gt\", \"gte\": same as C's <, <=, >, <=\n "
- "\b\bo \"eq\", \"neq\": same as C's == and !=\n "
- "\b\bo \"comp\": -1, 0, or 1 if 1st value is less than, "
- "equal to, or greater than 2nd value\n "
- "\b\bo \"if\": if 1st value is non-zero, use it, "
- "else use 2nd value\n "
- "\b\bo \"exists\": if 1st value exists, use it, "
- "else use 2nd value\n "
- "\b\bo \"nrand\": scale unit-stdv Gaussian noise by 2nd value "
- "and add to first value\n "
- "\b\bo \"rrand\": sample Rician distribution with 1st value "
- "for \"true\" mean, and 2nd value for sigma",
- NULL, nrrdBinaryOp);
- hestOptAdd(&opt, NULL, "in1", airTypeOther, 1, 1, &in1, NULL,
- "First input. Can be a single value or a nrrd.", NULL, NULL, nrrdHestIter);
- hestOptAdd(&opt, NULL, "in2", airTypeOther, 1, 1, &in2, NULL,
- "Second input. Can be a single value or a nrrd.", NULL, NULL,
- nrrdHestIter);
- hestOptAdd(&opt, "s,seed", "seed", airTypeString, 1, 1, &seedS, "",
- "seed value for RNG for nrand, so that you "
- "can get repeatable results between runs, or, "
- "by not using this option, the RNG seeding will be "
- "based on the current time");
- hestOptAdd(&opt, "t,type", "type", airTypeOther, 1, 1, &type, "default",
- "type to convert all INPUT nrrds to, prior to "
- "doing operation, useful for doing, for instance, the difference "
- "between two unsigned char nrrds. This will also determine "
- "output type. By default (not using this option), the types of "
- "the input nrrds are left unchanged.",
- NULL, NULL, &unrrduHestMaybeTypeCB);
- hestOptAdd(&opt, "w,which", "arg", airTypeInt, 1, 1, &which, "-1",
- "Which argument (0 or 1) should be used to determine the "
- "shape of the output nrrd. By default (not using this option), "
- "the first non-constant argument is used. ");
+ hestOptAdd_1_Enum(&opt, NULL, "operator", &op, NULL,
+ "Binary operator. Possibilities include:\n "
+ "\b\bo \"+\", \"-\", \"x\", \"/\": "
+ "add, subtract, multiply, divide\n "
+ "\b\bo \"+c\", \"-c\", \"xc\": add, subtract, multiply, with "
+ "clamping to range of output, in case its integral\n "
+ "\b\bo \"^\": exponentiation (pow)\n "
+ "\b\bo \"spow\": signed exponentiation: sgn(x)pow(abs(x),p)\n "
+ "\b\bo \"fpow\": like spow but with curves flipped\n "
+ "\b\bo \"%\": integer modulo\n "
+ "\b\bo \"fmod\": same as fmod() in C\n "
+ "\b\bo \"atan2\": same as atan2() in C\n "
+ "\b\bo \"min\", \"max\": minimum, maximum\n "
+ "\b\bo \"lt\", \"lte\", \"gt\", \"gte\": same as C's <, <=, >, <=\n "
+ "\b\bo \"eq\", \"neq\": same as C's == and !=\n "
+ "\b\bo \"comp\": -1, 0, or 1 if 1st value is less than, "
+ "equal to, or greater than 2nd value\n "
+ "\b\bo \"if\": if 1st value is non-zero, use it, "
+ "else use 2nd value\n "
+ "\b\bo \"exists\": if 1st value exists, use it, "
+ "else use 2nd value\n "
+ "\b\bo \"nrand\": scale unit-stdv Gaussian noise by 2nd value "
+ "and add to first value\n "
+ "\b\bo \"rrand\": sample Rician distribution with 1st value "
+ "for \"true\" mean, and 2nd value for sigma",
+ nrrdBinaryOp);
+ hestOptAdd_1_Other(&opt, NULL, "in1", &in1, NULL,
+ "First input. Can be a single value or a nrrd.", nrrdHestIter);
+ hestOptAdd_1_Other(&opt, NULL, "in2", &in2, NULL,
+ "Second input. Can be a single value or a nrrd.", nrrdHestIter);
+ seedOI = hestOptAdd_1_UInt(&opt, "s,seed", "seed", &seed, "0",
+ "seed value for random number generator (RNG), to "
+ "enable repeatable results between runs, or, "
+ "by not using this option, the RNG seeding will be "
+ "based on the current time");
+ hestOptAdd_1_Other(&opt, "t,type", "type", &type, "default",
+ "type to convert all INPUT nrrds to, prior to "
+ "doing operation, useful for doing, for instance, the difference "
+ "between two unsigned char nrrds. This will also determine "
+ "output type. By default (not using this option), the types of "
+ "the input nrrds are left unchanged.",
+ &unrrduHestMaybeTypeCB);
+ hestOptAdd_1_Int(&opt, "w,which", "arg", &which, "-1",
+ "Which argument (0 or 1) should be used to determine the "
+ "shape of the output nrrd. By default (not using this option), "
+ "the first non-constant argument is used. ");
OPT_ADD_NOUT(out, "output nrrd");
mop = airMopNew();
@@ -128,19 +127,13 @@
** if (nrrdBinaryOpNormalRandScaleAdd == op) {
** but then when nrrdBinaryOpRicianRand was added, then the seed wasn't being
** used ==> BUG. To be more future proof, we try to parse and use seed
- ** whenever a non-empty string is given, and end up *ALWAYS* calling
+ ** whenever the user exercies this option, and end up *ALWAYS* calling
** airSrandMT, even for operations that have nothing to do with random
** numbers. Could also have a new array that indicates if an op involves
** the RNG, but this would add rarely-needed complexity
*/
- if (airStrlen(seedS)) {
- if (1 != sscanf(seedS, "%u", &seed)) {
- fprintf(stderr, "%s: couldn't parse seed \"%s\" as uint\n", me, seedS);
- airMopError(mop);
- return 1;
- } else {
- airSrandMT(seed);
- }
+ if (hestSourceDefault != opt[seedOI].source) {
+ airSrandMT(seed);
} else {
/* got no request for specific seed */
airSrandMT(AIR_UINT(airTime()));
Modified: teem/trunk/src/unrrdu/3op.c
===================================================================
--- teem/trunk/src/unrrdu/3op.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/3op.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -39,53 +39,52 @@
int op, type, E, pret, which;
airArray *mop;
- hestOptAdd(&opt, NULL, "operator", airTypeEnum, 1, 1, &op, NULL,
- "Ternary operator. Possibilities include:\n "
- "\b\bo \"+\", \"x\": sum or product of three values\n "
- "\b\bo \"min\", \"max\": minimum, maximum\n "
- "\b\bo \"min_sm\": smoothed minimum function; "
- "min_sm(x, w, M) is like min(x,M) but for x > M-w (with w > 0) "
- "there is a smooth transition from x to asymptotic to M\n "
- "\b\bo \"max_sm\": smoothed maximum function; "
- "max_sm(M, w, x) is like max(M,x) but for x < m+w (with w > m) "
- "there is a smooth transition from x to asymptotic to m\n "
- "\b\bo \"lt_sm\": 1st less than 3rd, smoothed by 2nd\n "
- "\b\bo \"gt_sm\": 1st greater than 3rd, smoothed by 2nd\n "
- "\b\bo \"clamp\": 2nd value is clamped to range between "
- "the 1st and the 3rd\n "
- "\b\bo \"ifelse\": if 1st value non-zero, then 2nd value, else "
- "3rd value\n "
- "\b\bo \"lerp\": linear interpolation between the 2nd and "
- "3rd values, as the 1st value varies between 0.0 and 1.0, "
- "respectively\n "
- "\b\bo \"exists\": if the 1st value exists, use the 2nd "
- "value, otherwise use the 3rd\n "
- "\b\bo \"in_op\": 1 iff 2nd value is > 1st and < 3rd, "
- "0 otherwise\n "
- "\b\bo \"in_cl\": 1 iff 2nd value is >= 1st and <= 3rd, "
- "0 otherwise\n "
- "\b\bo \"gauss\": evaluate (at 1st value) Gaussian with mean=2nd "
- "and stdv=3rd value\n "
- "\b\bo \"rician\": evaluate (at 1st value) Rician with mean=2nd "
- "and stdv=3rd value",
- NULL, nrrdTernaryOp);
- hestOptAdd(&opt, NULL, "in1", airTypeOther, 1, 1, &in1, NULL,
- "First input. Can be a single value or a nrrd.", NULL, NULL, nrrdHestIter);
- hestOptAdd(&opt, NULL, "in2", airTypeOther, 1, 1, &in2, NULL,
- "Second input. Can be a single value or a nrrd.", NULL, NULL,
- nrrdHestIter);
- hestOptAdd(&opt, NULL, "in3", airTypeOther, 1, 1, &in3, NULL,
- "Third input. Can be a single value or a nrrd.", NULL, NULL, nrrdHestIter);
- hestOptAdd(&opt, "t,type", "type", airTypeOther, 1, 1, &type, "default",
- "type to convert all nrrd inputs to, prior to "
- "doing operation. This also determines output type. "
- "By default (not using this option), the types of the input "
- "nrrds are left unchanged.",
- NULL, NULL, &unrrduHestMaybeTypeCB);
- hestOptAdd(&opt, "w,which", "arg", airTypeInt, 1, 1, &which, "-1",
- "Which argument (0, 1, or 2) should be used to determine the "
- "shape of the output nrrd. By default (not using this option), "
- "the first non-constant argument is used. ");
+ hestOptAdd_1_Enum(&opt, NULL, "operator", &op, NULL,
+ "Ternary operator. Possibilities include:\n "
+ "\b\bo \"+\", \"x\": sum or product of three values\n "
+ "\b\bo \"min\", \"max\": minimum, maximum\n "
+ "\b\bo \"min_sm\": smoothed minimum function; "
+ "min_sm(x, w, M) is like min(x,M) but for x > M-w (with w > 0) "
+ "there is a smooth transition from x to asymptotic to M\n "
+ "\b\bo \"max_sm\": smoothed maximum function; "
+ "max_sm(M, w, x) is like max(M,x) but for x < m+w (with w > m) "
+ "there is a smooth transition from x to asymptotic to m\n "
+ "\b\bo \"lt_sm\": 1st less than 3rd, smoothed by 2nd\n "
+ "\b\bo \"gt_sm\": 1st greater than 3rd, smoothed by 2nd\n "
+ "\b\bo \"clamp\": 2nd value is clamped to range between "
+ "the 1st and the 3rd\n "
+ "\b\bo \"ifelse\": if 1st value non-zero, then 2nd value, else "
+ "3rd value\n "
+ "\b\bo \"lerp\": linear interpolation between the 2nd and "
+ "3rd values, as the 1st value varies between 0.0 and 1.0, "
+ "respectively\n "
+ "\b\bo \"exists\": if the 1st value exists, use the 2nd "
+ "value, otherwise use the 3rd\n "
+ "\b\bo \"in_op\": 1 iff 2nd value is > 1st and < 3rd, "
+ "0 otherwise\n "
+ "\b\bo \"in_cl\": 1 iff 2nd value is >= 1st and <= 3rd, "
+ "0 otherwise\n "
+ "\b\bo \"gauss\": evaluate (at 1st value) Gaussian with mean=2nd "
+ "and stdv=3rd value\n "
+ "\b\bo \"rician\": evaluate (at 1st value) Rician with mean=2nd "
+ "and stdv=3rd value",
+ nrrdTernaryOp);
+ hestOptAdd_1_Other(&opt, NULL, "in1", &in1, NULL,
+ "First input. Can be a single value or a nrrd.", nrrdHestIter);
+ hestOptAdd_1_Other(&opt, NULL, "in2", &in2, NULL,
+ "Second input. Can be a single value or a nrrd.", nrrdHestIter);
+ hestOptAdd_1_Other(&opt, NULL, "in3", &in3, NULL,
+ "Third input. Can be a single value or a nrrd.", nrrdHestIter);
+ hestOptAdd_1_Other(&opt, "t,type", "type", &type, "default",
+ "type to convert all nrrd inputs to, prior to "
+ "doing operation. This also determines output type. "
+ "By default (not using this option), the types of the input "
+ "nrrds are left unchanged.",
+ &unrrduHestMaybeTypeCB);
+ hestOptAdd_1_Int(&opt, "w,which", "arg", &which, "-1",
+ "Which argument (0, 1, or 2) should be used to determine the "
+ "shape of the output nrrd. By default (not using this option), "
+ "the first non-constant argument is used. ");
OPT_ADD_NOUT(out, "output nrrd");
mop = airMopNew();
Modified: teem/trunk/src/unrrdu/crop.c
===================================================================
--- teem/trunk/src/unrrdu/crop.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/crop.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -31,8 +31,8 @@
hestOpt *opt = NULL;
char *out, *err;
Nrrd *nin, *nout;
- unsigned int ai;
- int minLen, maxLen, pret;
+ unsigned int ai, minLen, maxLen;
+ int pret;
long int *minOff, *maxOff;
size_t min[NRRD_DIM_MAX], max[NRRD_DIM_MAX];
airArray *mop;
@@ -50,14 +50,14 @@
"there's also:\n "
"\b\bo m+<int> give index relative to minimum.",
maxLen);
- hestOptAdd(&opt, "b,bounds", "filename", airTypeOther, 1, 1, &_nbounds, "",
- "a filename given here overrides the -min and -max "
- "options (they don't need to be used) and provides the "
- "cropping bounds as a 2-D array; first scanline is for "
- "-min, second is for -max. Unfortunately the "
- "\"m\" and \"M\" semantics (above) are currently not "
- "supported in the bounds file.",
- NULL, NULL, nrrdHestNrrd);
+ hestOptAdd_1_Other(&opt, "b,bounds", "filename", &_nbounds, "",
+ "a filename given here overrides the -min and -max "
+ "options (they don't need to be used) and provides the "
+ "cropping bounds as a 2-D array; first scanline is for "
+ "-min, second is for -max. Unfortunately the "
+ "\"m\" and \"M\" semantics (above) are currently not "
+ "supported in the bounds file.",
+ nrrdHestNrrd);
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
@@ -68,8 +68,8 @@
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
if (!_nbounds) {
- if (!(minLen == (int)nin->dim && maxLen == (int)nin->dim)) {
- fprintf(stderr, "%s: # min coords (%d) or max coords (%d) != nrrd dim (%d)\n", me,
+ if (!(minLen == nin->dim && maxLen == nin->dim)) {
+ fprintf(stderr, "%s: # min coords (%u) or max coords (%u) != nrrd dim (%u)\n", me,
minLen, maxLen, nin->dim);
airMopError(mop);
return 1;
@@ -76,7 +76,7 @@
}
for (ai = 0; ai < nin->dim; ai++) {
if (-1 == minOff[0 + 2 * ai]) {
- fprintf(stderr, "%s: can't use m+<int> specification for axis %d min\n", me, ai);
+ fprintf(stderr, "%s: can't use m+<int> specification for axis %u min\n", me, ai);
airMopError(mop);
return 1;
}
Modified: teem/trunk/src/unrrdu/make.c
===================================================================
--- teem/trunk/src/unrrdu/make.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/make.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -69,12 +69,12 @@
encInfo[AIR_STRLEN_LARGE + 1];
Nrrd *nrrd;
size_t *size, bufLen;
- int headerOnly, pret, lineSkip, endian, type, encodingType, gotSpacing, gotThickness,
- gotMin, gotMax, space, spaceSet;
- long int byteSkip;
+ int headerOnly, pret, endian, type, encodingType, gotSpacing, gotThickness, gotMin,
+ gotMax, space, spaceSet;
+ long int byteSkip; /* NOT unsigned: -1 means "from the end" */
unsigned int ii, kindsLen, thicknessLen, spacingLen, sizeLen, nameLen, centeringsLen,
unitsLen, labelLen, kvpLen, spunitsLen, dataFileDim, spaceDim, minLen, maxLen,
- thicknessIdx, spacingIdx, minIdx, maxIdx;
+ thicknessIdx, spacingIdx, minIdx, maxIdx, lineSkip;
double *spacing, *axmin, *axmax, *thickness;
airArray *mop;
NrrdIoState *nio;
@@ -89,81 +89,80 @@
mop = airMopNew();
- hestOptAdd(&opt, "h", NULL, airTypeBool, 0, 0, &headerOnly, NULL,
- "Generate header ONLY: don't write out the whole nrrd, "
- "don't even bother reading the input data, just output the "
- "detached nrrd header file (usually with a \".nhdr\" "
- "extension) determined by the options below. The single "
- "constraint is that detached headers are incompatible with "
- "using stdin as the data source.");
- hestOptAdd(&opt, "i,input", "file", airTypeString, 1, -1, &dataFileNames, "-",
- "Filename(s) of data file(s); use \"-\" for stdin. *OR*, can "
- "use sprintf-style format for identifying a range of numbered "
- "files, see above for details.",
- &nameLen);
- hestOptAdd(&opt, "t,type", "type", airTypeEnum, 1, 1, &type, NULL,
- "type of data (e.g. \"uchar\", \"int\", \"float\", "
- "\"double\", etc.)",
- NULL, nrrdType);
- hestOptAdd(&opt, "s,size", "sz0 sz1", airTypeSize_t, 1, -1, &size, NULL,
- "number of samples along each axis (and implicit indicator "
- "of dimension of nrrd)",
- &sizeLen);
- hestOptAdd(&opt, "fd,filedim", "dim", airTypeUInt, 1, 1, &dataFileDim, "0",
- "When using *multiple* input data files (to \"-i\"), what is "
- "the dimension of the array data in each individual file. By "
- "default (not using this option), this dimension is assumed "
- "to be one less than the whole data dimension. ");
- spacingIdx
- = hestOptAdd(&opt, "sp,spacing", "sp0 sp1", airTypeDouble, 1, -1, &spacing, "nan",
- "spacing between samples on each axis. Use \"nan\" for "
- "any non-spatial axes (e.g. spacing between red, green, and blue "
- "along axis 0 of interleaved RGB image data)",
- &spacingLen);
+ hestOptAdd_Flag(&opt, "h", &headerOnly,
+ "Generate header ONLY: don't write out the whole nrrd, "
+ "don't even bother reading the input data, just output the "
+ "detached nrrd header file (usually with a \".nhdr\" "
+ "extension) determined by the options below. The single "
+ "constraint is that detached headers are incompatible with "
+ "using stdin as the data source.");
+ hestOptAdd_Nv_String(&opt, "i,input", "file", 1, -1, &dataFileNames, "-",
+ "Filename(s) of data file(s); use \"-\" for stdin. *OR*, can "
+ "use sprintf-style format for identifying a range of numbered "
+ "files, see above for details.",
+ &nameLen);
+ hestOptAdd_1_Enum(&opt, "t,type", "type", &type, NULL,
+ "type of data (e.g. \"uchar\", \"int\", \"float\", "
+ "\"double\", etc.)",
+ nrrdType);
+ hestOptAdd_Nv_Size_t(&opt, "s,size", "sz0 sz1", 1, -1, &size, NULL,
+ "number of samples along each axis (and implicit indicator "
+ "of dimension of nrrd)",
+ &sizeLen);
+ hestOptAdd_1_UInt(&opt, "fd,filedim", "dim", &dataFileDim, "0",
+ "When using *multiple* input data files (to \"-i\"), what is "
+ "the dimension of the array data in each individual file. By "
+ "default (not using this option), this dimension is assumed "
+ "to be one less than the whole data dimension. ");
+ spacingIdx = hestOptAdd_Nv_Double(
+ &opt, "sp,spacing", "sp0 sp1", 1, -1, &spacing, "nan",
+ "spacing between samples on each axis. Use \"nan\" for "
+ "any non-spatial axes (e.g. spacing between red, green, and blue "
+ "along axis 0 of interleaved RGB image data)",
+ &spacingLen);
/* NB: these are like unu jhisto's -min -max, not like unu crop's */
- minIdx = hestOptAdd(&opt, "min,axismin", "min0 min1", airTypeDouble, 1, -1, &axmin,
- "nan",
- "When each axis has a distinct meaning (as in a joint "
- "histogram), the per-axis min is the smallest \"position\" "
- "associated with the first sample on the axis. Use \"nan\" for "
- "\"no value to set\" when other axes do have axis min",
- &minLen);
- maxIdx = hestOptAdd(&opt, "max,axismax", "max0 max1", airTypeDouble, 1, -1, &axmax,
- "nan",
- "Goes with -min: the per-axis maximum \"position\". "
- "-max and -min should probably be used together, and having "
- "this information logically supersedes the -sp spacing on those "
- "axes.",
- &maxLen);
- thicknessIdx
- = hestOptAdd(&opt, "th,thickness", "th0 th1", airTypeDouble, 1, -1, &thickness,
- "nan",
- "thickness of region represented by one sample along each axis. "
- " As with -sp spacing, use \"nan\" for "
- "any non-spatial axes.",
- &thicknessLen);
- hestOptAdd(&opt, "k,kind", "k0 k1", airTypeString, 1, -1, &kinds, "",
- "what \"kind\" is each axis, from the nrrdKind airEnum "
- "(e.g. space, time, 3-vector, 3D-masked-symmetric-matrix, "
- "or \"none\" to signify no kind)",
- &kindsLen);
- hestOptAdd(&opt, "cn,centering", "c0 c1", airTypeString, 1, -1, ¢erings, "",
- "kind of centering (node or cell) for each axis, or "
- "\"none\" to signify no centering",
- ¢eringsLen);
- hestOptAdd(&opt, "l,label", "lb0 lb1", airTypeString, 1, -1, &label, "",
- "short string labels for each of the axes", &labelLen);
- hestOptAdd(&opt, "u,unit", "un0 un1", airTypeString, 1, -1, &units, "",
- "short strings giving units for each of the axes", &unitsLen);
- hestOptAdd(&opt, "c,content", "content", airTypeString, 1, 1, &content, "",
- "Specifies the content string of the nrrd, which is built upon "
- "by many nrrd function to record a history of operations");
- hestOptAdd(&opt, "ls,lineskip", "num", airTypeInt, 1, 1, &lineSkip, "0",
- "number of ascii lines to skip before reading data");
- hestOptAdd(&opt, "bs,byteskip", "num", airTypeLongInt, 1, 1, &byteSkip, "0",
- "number of bytes to skip (after skipping ascii lines, if any) "
- "before reading data. Can use \"-bs -1\" to skip a binary "
- "header of unknown length in raw-encoded data");
+ minIdx = hestOptAdd_Nv_Double(
+ &opt, "min,axismin", "min0 min1", 1, -1, &axmin, "nan",
+ "When each axis has a distinct meaning (as in a joint "
+ "histogram), the per-axis min is the smallest \"position\" "
+ "associated with the first sample on the axis. Use \"nan\" for "
+ "\"no value to set\" when other axes do have axis min",
+ &minLen);
+ maxIdx = hestOptAdd_Nv_Double(
+ &opt, "max,axismax", "max0 max1", 1, -1, &axmax, "nan",
+ "Goes with -min: the per-axis maximum \"position\". "
+ "-max and -min should probably be used together, and having "
+ "this information logically supersedes the -sp spacing on those "
+ "axes.",
+ &maxLen);
+ thicknessIdx = hestOptAdd_Nv_Double(
+ &opt, "th,thickness", "th0 th1", 1, -1, &thickness, "nan",
+ "thickness of region represented by one sample along each axis. "
+ " As with -sp spacing, use \"nan\" for "
+ "any non-spatial axes.",
+ &thicknessLen);
+ hestOptAdd_Nv_String(&opt, "k,kind", "k0 k1", 1, -1, &kinds, "",
+ "what \"kind\" is each axis, from the nrrdKind airEnum "
+ "(e.g. space, time, 3-vector, 3D-masked-symmetric-matrix, "
+ "or \"none\" to signify no kind)",
+ &kindsLen);
+ hestOptAdd_Nv_String(&opt, "cn,centering", "c0 c1", 1, -1, ¢erings, "",
+ "kind of centering (node or cell) for each axis, or "
+ "\"none\" to signify no centering",
+ ¢eringsLen);
+ hestOptAdd_Nv_String(&opt, "l,label", "lb0 lb1", 1, -1, &label, "",
+ "short string labels for each of the axes", &labelLen);
+ hestOptAdd_Nv_String(&opt, "u,unit", "un0 un1", 1, -1, &units, "",
+ "short strings giving units for each of the axes", &unitsLen);
+ hestOptAdd_1_String(&opt, "c,content", "content", &content, "",
+ "Specifies the content string of the nrrd, which is built upon "
+ "by many nrrd function to record a history of operations");
+ hestOptAdd_1_UInt(&opt, "ls,lineskip", "num", &lineSkip, "0",
+ "number of ascii lines to skip before reading data");
+ hestOptAdd_1_LongInt(&opt, "bs,byteskip", "num", &byteSkip, "0",
+ "number of bytes to skip (after skipping ascii lines, if any) "
+ "before reading data. Can use \"-bs -1\" to skip a binary "
+ "header of unknown length in raw-encoded data");
strcpy(encInfo,
"encoding of input data. Possibilities include:"
"\n \b\bo \"raw\": raw encoding"
@@ -176,71 +175,70 @@
if (nrrdEncodingBzip2->available()) {
strcat(encInfo, "\n \b\bo \"bzip2\", \"bz2\": bzip2 compressed raw data");
}
- hestOptAdd(&opt, "e,encoding", "enc", airTypeEnum, 1, 1, &encodingType, "raw", encInfo,
- NULL, nrrdEncodingType);
- hestOptAdd(&opt, "en,endian", "end", airTypeEnum, 1, 1, &endian,
- airEnumStr(airEndian, airMyEndian()),
- "Endianness of data; relevent for any data with value "
- "representation bigger than 8 bits, with a non-ascii encoding: "
- "\"little\" for Intel and friends "
- "(least significant byte first, at lower address); "
- "\"big\" for everyone else (most significant byte first). "
- "Defaults to endianness of this machine",
- NULL, airEndian);
- hestOptAdd(&opt, "kv,keyvalue", "key/val", airTypeString, 1, -1, &kvp, "",
- "key/value string pairs to be stored in nrrd. Each key/value "
- "pair must be a single string (put it in \"\"s "
- "if the key or the value contain spaces). The format of each "
- "pair is \"<key>:=<value>\", with no spaces before or after "
- "\":=\".",
- &kvpLen);
- hestOptAdd(&opt, "spc,space", "space", airTypeString, 1, 1, &spcStr, "",
- "identify the space (e.g. \"RAS\", \"LPS\") in which the array "
- "conceptually lives, from the nrrdSpace airEnum, which in turn "
- "determines the dimension of the space. Or, use an integer>0 to"
- "give the dimension of a space that nrrdSpace doesn't know "
- "about. "
- "By default (not using this option), the enclosing space is "
- "set as unknown.");
- hestOptAdd(&opt, "orig,origin", "origin", airTypeString, 1, 1, &_origStr, "",
- "(NOTE: must quote vector) the origin in space of the array: "
- "the location of the center "
- "of the first sample, of the form \"(x,y,z)\" (or however "
- "many coefficients are needed for the chosen space). Quoting the "
- "vector is needed to stop interpretation from the shell");
- hestOptAdd(&opt, "dirs,directions", "v0 v1 ...", airTypeString, 1, 1, &_dirStr, "",
- "(NOTE: must quote whole vector list) The \"space directions\": "
- "the vectors in space spanned by incrementing (by one) each "
- "axis index (the column vectors of the index-to-world "
- "matrix transform), OR, \"none\" for non-spatial axes. Give "
- "one vector per axis. Using a space direction logically "
- "supersedes both per-axis -sp spacing and -min,-max. "
- "(Quoting around whole vector list, not "
- "individually, is needed because of limitations in the parser)");
- hestOptAdd(&opt, "mf,measurementframe", "v0 v1 ...", airTypeString, 1, 1, &_mframeStr,
- "",
- "(NOTE: must quote whole vector list). Each vector is a *column* "
- "vector of the matrix which transforms from coordinates in "
- "measurement frame (in which the coefficients of vectors and "
- "tensors are given) to coordinates of world space (given with "
- "\"-spc\"). This is not a per-axis field: the column vectors "
- "comprise a D-by-D square matrix, where D is the dimension of "
- "world space.");
- hestOptAdd(&opt, "spu,spaceunit", "su0 su1", airTypeString, 1, -1, &spunits, "",
- "short strings giving units with which the coefficients of the "
- "space origin and direction vectors are measured.",
- &spunitsLen);
- hestOptAdd(&opt, "o,output", "nout", airTypeString, 1, 1, &out, "-",
- "output filename. If \"-h\" has been used, the output file is "
- "always a detached header. Otherwise, use extension "
- "\".nrrd\" to signal creation of self-contained nrrd, and "
- "\".nhdr\" to signal creating of a detached header with "
- "(single) data file.");
- hestOptAdd(&opt, "od,outputdata", "name", airTypeString, 1, 1, &outData, "",
- "when *not* using \"-h\" and saving to a \".nhdr\" file, using "
- "this option allows you to explicitly name the data file, "
- "instead of (by default, not using this option) having it be "
- "the same filename base as the header file.");
+ hestOptAdd_1_Enum(&opt, "e,encoding", "enc", &encodingType, "raw", encInfo,
+ nrrdEncodingType);
+ hestOptAdd_1_Enum(&opt, "en,endian", "end", &endian,
+ airEnumStr(airEndian, airMyEndian()),
+ "Endianness of data; relevent for any data with value "
+ "representation bigger than 8 bits, with a non-ascii encoding: "
+ "\"little\" for Intel and friends "
+ "(least significant byte first, at lower address); "
+ "\"big\" for everyone else (most significant byte first). "
+ "Defaults to endianness of this machine",
+ airEndian);
+ hestOptAdd_Nv_String(&opt, "kv,keyvalue", "key/val", 1, -1, &kvp, "",
+ "key/value string pairs to be stored in nrrd. Each key/value "
+ "pair must be a single string (put it in \"\"s "
+ "if the key or the value contain spaces). The format of each "
+ "pair is \"<key>:=<value>\", with no spaces before or after "
+ "\":=\".",
+ &kvpLen);
+ hestOptAdd_1_String(&opt, "spc,space", "space", &spcStr, "",
+ "identify the space (e.g. \"RAS\", \"LPS\") in which the array "
+ "conceptually lives, from the nrrdSpace airEnum, which in turn "
+ "determines the dimension of the space. Or, use an integer>0 to"
+ "give the dimension of a space that nrrdSpace doesn't know "
+ "about. "
+ "By default (not using this option), the enclosing space is "
+ "set as unknown.");
+ hestOptAdd_1_String(&opt, "orig,origin", "origin", &_origStr, "",
+ "(NOTE: must quote vector) the origin in space of the array: "
+ "the location of the center "
+ "of the first sample, of the form \"(x,y,z)\" (or however "
+ "many coefficients are needed for the chosen space). Quoting the "
+ "vector is needed to stop interpretation from the shell");
+ hestOptAdd_1_String(&opt, "dirs,directions", "v0 v1 ...", &_dirStr, "",
+ "(NOTE: must quote whole vector list) The \"space directions\": "
+ "the vectors in space spanned by incrementing (by one) each "
+ "axis index (the column vectors of the index-to-world "
+ "matrix transform), OR, \"none\" for non-spatial axes. Give "
+ "one vector per axis. Using a space direction logically "
+ "supersedes both per-axis -sp spacing and -min,-max. "
+ "(Quoting around whole vector list, not "
+ "individually, prevents the shell from interpreting parentheses)");
+ hestOptAdd_1_String(&opt, "mf,measurementframe", "v0 v1 ...", &_mframeStr, "",
+ "(NOTE: must quote whole vector list). Each vector is a *column* "
+ "vector of the matrix which transforms from coordinates in "
+ "measurement frame (in which the coefficients of vectors and "
+ "tensors are given) to coordinates of world space (given with "
+ "\"-spc\"). This is not a per-axis field: the column vectors "
+ "comprise a D-by-D square matrix, where D is the dimension of "
+ "world space.");
+ hestOptAdd_Nv_String(&opt, "spu,spaceunit", "su0 su1", 1, -1, &spunits, "",
+ "short strings giving units with which the coefficients of the "
+ "space origin and direction vectors are measured.",
+ &spunitsLen);
+ hestOptAdd_1_String(&opt, "o,output", "nout", &out, "-",
+ "output filename. If \"-h\" has been used, the output file is "
+ "always a detached header. Otherwise, use extension "
+ "\".nrrd\" to signal creation of self-contained nrrd, and "
+ "\".nhdr\" to signal creating of a detached header with "
+ "(single) data file.");
+ hestOptAdd_1_String(&opt, "od,outputdata", "name", &outData, "",
+ "when *not* using \"-h\" and saving to a \".nhdr\" file, using "
+ "this option allows you to explicitly name the data file, "
+ "instead of (by default, not using this option) having it be "
+ "the same filename base as the header file.");
airMopAdd(mop, opt, hestOptFree_vp, airMopAlways);
airStrtokQuoting = AIR_TRUE;
Modified: teem/trunk/src/unrrdu/minmax.c
===================================================================
--- teem/trunk/src/unrrdu/minmax.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/minmax.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -85,25 +85,25 @@
#define B8DEF "false"
mop = airMopNew();
- hestOptAdd(&opt, "blind8", "bool", airTypeBool, 1, 1, &blind8BitRange,
- B8DEF, /* NOTE: not using nrrdStateBlind8BitRange here
- for consistency with previous behavior */
- "whether to blindly assert the range of 8-bit data, "
- "without actually going through the data values, i.e. "
- "uchar is always [0,255], signed char is [-128,127]. "
- "Note that even if you do not use this option, the default "
- "(" B8DEF ") is potentialy over-riding the effect of "
- "environment variable NRRD_STATE_BLIND_8_BIT_RANGE; "
- "see \"unu env\"");
- hestOptAdd(&opt, "sl", NULL, airTypeInt, 0, 0, &singleLine, NULL,
- "Without this option, output is on multiple lines (for min, for max, "
- "and then maybe more lines about non-existent values or min, max "
- "conditions). With \"-sl\", output is a single line containing just min "
- "and max, possibly followed by the single word \"non-existent\" if and "
- "only if there were non-existent values. If there are multiple inputs, "
- "the input filename is printed first on the per-input single line.");
- hestOptAdd(&opt, NULL, "nin1", airTypeString, 1, -1, &inS, NULL, "input nrrd(s)",
- &ninLen);
+ hestOptAdd_1_Bool(&opt, "blind8", "bool", &blind8BitRange,
+ B8DEF, /* NOTE: not using nrrdStateBlind8BitRange here
+ for consistency with previous behavior */
+ "whether to blindly assert the range of 8-bit data, "
+ "without actually going through the data values, i.e. "
+ "uchar is always [0,255], signed char is [-128,127]. "
+ "Note that even if you do not use this option, the default "
+ "(" B8DEF ") is potentialy over-riding the effect of "
+ "environment variable NRRD_STATE_BLIND_8_BIT_RANGE; "
+ "see \"unu env\"");
+ hestOptAdd_Flag(
+ &opt, "sl", &singleLine,
+ "Without this option, output is on multiple lines (for min, for max, "
+ "and then maybe more lines about non-existent values or min, max "
+ "conditions). With \"-sl\", output is a single line containing just min "
+ "and max, possibly followed by the single word \"non-existent\" if and "
+ "only if there were non-existent values. If there are multiple inputs, "
+ "the input filename is printed first on the per-input single line.");
+ hestOptAdd_Nv_String(&opt, NULL, "nin1", 1, -1, &inS, NULL, "input nrrd(s)", &ninLen);
airMopAdd(mop, opt, hestOptFree_vp, airMopAlways);
USAGE_OR_PARSE(_unrrdu_minmaxInfoL);
Modified: teem/trunk/src/unrrdu/mlut.c
===================================================================
--- teem/trunk/src/unrrdu/mlut.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/mlut.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -42,36 +42,36 @@
double min, max;
NrrdRange *range = NULL;
- hestOptAdd(&opt, "m,map", "mlut", airTypeOther, 1, -1, &_nmlut, NULL,
- "one nrrd of lookup tables to map input nrrd through, or, "
- "list of nrrds which contain the individual entries of "
- "the lookup table at each voxel, which will be joined together.",
- &_nmlutLen, NULL, nrrdHestNrrd);
- hestOptAdd(&opt, "r,rescale", NULL, airTypeInt, 0, 0, &rescale, NULL,
- "rescale the input values from the input range to the "
- "lut domain. The lut domain is either explicitly "
- "defined by the axis min,max along axis 0 or 1, or, it "
- "is implicitly defined as zero to the length of that axis "
- "minus one.");
- hestOptAdd(&opt, "min,minimum", "value", airTypeDouble, 1, 1, &min, "nan",
- "Low end of input range. Defaults to lowest value "
- "found in input nrrd. Explicitly setting this is useful "
- "only with rescaling (\"-r\")");
- hestOptAdd(&opt, "max,maximum", "value", airTypeDouble, 1, 1, &max, "nan",
- "High end of input range. Defaults to highest value "
- "found in input nrrd. Explicitly setting this is useful "
- "only with rescaling (\"-r\")");
- 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]). "
- "Explicitly setting this is useful only with rescaling (\"-r\")");
- hestOptAdd(&opt, "t,type", "type", airTypeOther, 1, 1, &typeOut, "default",
- "specify the type (\"int\", \"float\", etc.) of the "
- "output nrrd. "
- "By default (not using this option), the output type "
- "is the lut's type.",
- NULL, NULL, &unrrduHestMaybeTypeCB);
+ hestOptAdd_Nv_Other(&opt, "m,map", "mlut", 1, -1, &_nmlut, NULL,
+ "one nrrd of lookup tables to map input nrrd through, or, "
+ "list of nrrds which contain the individual entries of "
+ "the lookup table at each voxel, which will be joined together.",
+ &_nmlutLen, nrrdHestNrrd);
+ hestOptAdd_Flag(&opt, "r,rescale", &rescale,
+ "rescale the input values from the input range to the "
+ "lut domain. The lut domain is either explicitly "
+ "defined by the axis min,max along axis 0 or 1, or, it "
+ "is implicitly defined as zero to the length of that axis "
+ "minus one.");
+ hestOptAdd_1_Double(&opt, "min,minimum", "value", &min, "nan",
+ "Low end of input range. Defaults to lowest value "
+ "found in input nrrd. Explicitly setting this is useful "
+ "only with rescaling (\"-r\")");
+ hestOptAdd_1_Double(&opt, "max,maximum", "value", &max, "nan",
+ "High end of input range. Defaults to highest value "
+ "found in input nrrd. Explicitly setting this is useful "
+ "only with rescaling (\"-r\")");
+ hestOptAdd_1_Bool(&opt, "blind8", "bool", &blind8BitRange,
+ nrrdStateBlind8BitRange ? "true" : "false",
+ "Whether to know the range of 8-bit data blindly "
+ "(uchar is always [0,255], signed char is [-128,127]). "
+ "Explicitly setting this is useful only with rescaling (\"-r\")");
+ hestOptAdd_1_Other(&opt, "t,type", "type", &typeOut, "default",
+ "specify the type (\"int\", \"float\", etc.) of the "
+ "output nrrd. "
+ "By default (not using this option), the output type "
+ "is the lut's type.",
+ &unrrduHestMaybeTypeCB);
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
Modified: teem/trunk/src/unrrdu/mrmap.c
===================================================================
--- teem/trunk/src/unrrdu/mrmap.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/mrmap.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -42,40 +42,40 @@
unsigned int _nmmapLen;
double min, max;
- hestOptAdd(&opt, "m,map", "mmap", airTypeOther, 1, -1, &_nmmap, NULL,
- "one nrrd of regular maps to map input nrrd through, or, "
- "list of nrrds which contain the individual entries of the map "
- "at each voxel, which will be joined together.",
- &_nmmapLen, NULL, nrrdHestNrrd);
- hestOptAdd(&opt, "r,rescale", NULL, airTypeInt, 0, 0, &rescale, NULL,
- "rescale the input values from the input range to the "
- "map domain. The map domain is either explicitly "
- "defined by the axis min,max along axis 0 or 1, or, it "
- "is implicitly defined as zero to one minus the length of "
- "that axis.");
- hestOptAdd(&opt, "min,minimum", "value", airTypeDouble, 1, 1, &min, "nan",
- "Low end of input range. Defaults to lowest value "
- "found in input nrrd. Explicitly setting this is useful "
- "only with rescaling (\"-r\") or if the map domain is only "
- "implicitly defined");
- hestOptAdd(&opt, "max,maximum", "value", airTypeDouble, 1, 1, &max, "nan",
- "High end of input range. Defaults to highest value "
- "found in input nrrd. Explicitly setting this is useful "
- "only with rescaling (\"-r\") or if the map domain is only "
- "implicitly defined");
- 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]). "
- "Explicitly setting this is useful "
- "only with rescaling (\"-r\") or if the map domain is only "
- "implicitly defined");
- hestOptAdd(&opt, "t,type", "type", airTypeOther, 1, 1, &typeOut, "default",
- "specify the type (\"int\", \"float\", etc.) of the "
- "output nrrd. "
- "By default (not using this option), the output type "
- "is the map's type.",
- NULL, NULL, &unrrduHestMaybeTypeCB);
+ hestOptAdd_Nv_Other(&opt, "m,map", "mmap", 1, -1, &_nmmap, NULL,
+ "one nrrd of regular maps to map input nrrd through, or, "
+ "list of nrrds which contain the individual entries of the map "
+ "at each voxel, which will be joined together.",
+ &_nmmapLen, nrrdHestNrrd);
+ hestOptAdd_Flag(&opt, "r,rescale", &rescale,
+ "rescale the input values from the input range to the "
+ "map domain. The map domain is either explicitly "
+ "defined by the axis min,max along axis 0 or 1, or, it "
+ "is implicitly defined as zero to one minus the length of "
+ "that axis.");
+ hestOptAdd_1_Double(&opt, "min,minimum", "value", &min, "nan",
+ "Low end of input range. Defaults to lowest value "
+ "found in input nrrd. Explicitly setting this is useful "
+ "only with rescaling (\"-r\") or if the map domain is only "
+ "implicitly defined");
+ hestOptAdd_1_Double(&opt, "max,maximum", "value", &max, "nan",
+ "High end of input range. Defaults to highest value "
+ "found in input nrrd. Explicitly setting this is useful "
+ "only with rescaling (\"-r\") or if the map domain is only "
+ "implicitly defined");
+ hestOptAdd_1_Bool(&opt, "blind8", "bool", &blind8BitRange,
+ nrrdStateBlind8BitRange ? "true" : "false",
+ "Whether to know the range of 8-bit data blindly "
+ "(uchar is always [0,255], signed char is [-128,127]). "
+ "Explicitly setting this is useful "
+ "only with rescaling (\"-r\") or if the map domain is only "
+ "implicitly defined");
+ hestOptAdd_1_Other(&opt, "t,type", "type", &typeOut, "default",
+ "specify the type (\"int\", \"float\", etc.) of the "
+ "output nrrd. "
+ "By default (not using this option), the output type "
+ "is the map's type.",
+ &unrrduHestMaybeTypeCB);
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
Modified: teem/trunk/src/unrrdu/ninspect.c
===================================================================
--- teem/trunk/src/unrrdu/ninspect.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/ninspect.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -341,18 +341,18 @@
mop = airMopNew();
- hestOptAdd(&opt, "i", "nin", airTypeOther, 1, 1, &nin, NULL,
- "input nrrd to project. Must be three dimensional.", NULL, NULL,
- nrrdHestNrrd);
- hestOptAdd(&opt, "amt", "heq", airTypeFloat, 1, 1, &heqamount, "0.5",
- "how much to apply histogram equalization to projection images");
- hestOptAdd(&opt, "m", "margin", airTypeUInt, 1, 1, &margin, "6",
- "pixel size of margin on boundary, and space between the projections");
- hestOptAdd(&opt, "b", "background", airTypeUInt, 3, 3, back, "0 0 0",
- "background color (8-bit RGB)");
- hestOptAdd(&opt, "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.");
+ hestOptAdd_1_Other(&opt, "i", "nin", &nin, NULL,
+ "input nrrd to project. Must be three dimensional.", nrrdHestNrrd);
+ hestOptAdd_1_Float(&opt, "amt", "heq", &heqamount, "0.5",
+ "how much to apply histogram equalization to projection images");
+ hestOptAdd_1_UInt(
+ &opt, "m", "margin", &margin, "6",
+ "pixel size of margin on boundary, and space between the projections");
+ hestOptAdd_3_UInt(&opt, "b", "background", back, "0 0 0",
+ "background color (8-bit RGB)");
+ hestOptAdd_1_String(&opt, "o", "img out", &outS, NULL,
+ "output image to save to. Will try to use whatever "
+ "format is implied by extension, but will fall back to PPM.");
USAGE_OR_PARSE(_unrrdu_infoL);
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
Modified: teem/trunk/src/unrrdu/pad.c
===================================================================
--- teem/trunk/src/unrrdu/pad.c 2023-07-11 22:15:46 UTC (rev 7077)
+++ teem/trunk/src/unrrdu/pad.c 2023-07-11 23:58:18 UTC (rev 7078)
@@ -31,8 +31,8 @@
hestOpt *opt = NULL;
char *out, *err;
Nrrd *nin, *nout;
- unsigned int ai;
- int minLen, maxLen, bb, pret;
+ unsigned int minLen, maxLen, ai;
+ int bb, pret;
long int *minOff, *maxOff;
ptrdiff_t min[NRRD_DIM_MAX], max[NRRD_DIM_MAX];
double padVal;
@@ -50,15 +50,15 @@
"there's also:\n "
"\b\bo m+<int> give index relative to minimum.",
maxLen);
- hestOptAdd(&opt, "b,boundary", "behavior", airTypeEnum, 1, 1, &bb, "bleed",
- "How to handle samples beyond the input bounds:\n "
- "\b\bo \"pad\": use some specified value\n "
- "\b\bo \"bleed\": extend border values outward\n "
- "\b\bo \"mirror\": repeated reflections\n "
- "\b\bo \"wrap\": wrap-around to other side",
- NULL, nrrdBoundary);
- hestOptAdd(&opt, "v,value", "val", airTypeDouble, 1, 1, &padVal, "0.0",
- "for \"pad\" boundary behavior, pad with this value");
+ hestOptAdd_1_Enum(&opt, "b,boundary", "behavior", &bb, "bleed",
+ "How to handle samples beyond the input bounds:\n "
+ "\b\bo \"pad\": use some specified value\n "
+ "\b\bo \"bleed\": extend border values outward\n "
+ "\b\bo \"mirror\": repeated reflections\n "
+ "\b\bo \"wrap\": wrap-around to other side",
+ nrrdBoundary);
+ hestOptAdd_1_Double(&opt, "v,value", "val", &padVal, "0.0",
+ "for \"pad\" boundary behavior, pad with this value");
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
@@ -68,8 +68,8 @@
USAGE_OR_PARSE(_unrrdu_padInfoL);
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
- if (!(minLen == (int)nin->dim && maxLen == (int)nin->dim)) {
- fprintf(stderr, "%s: # min coords (%d) or max coords (%d) != nrrd dim (%d)\n", me,
+ if (!(minLen == nin->dim && maxLen == nin->dim)) {
+ fprintf(stderr, "%s: # min coords (%u) or max coords (%u) != nrrd dim (%u)\n", me,
minLen, maxLen, nin->dim);
airMopError(mop);
return 1;
@@ -76,7 +76,7 @@
}
for (ai = 0; ai < nin->dim; ai++) {
if (-1 == minOff[0 + 2 * ai]) {
- fprintf(stderr, "%s: can't use m+<int> specification for axis %d min\n", me, ai);
+ fprintf(stderr, "%s: can't use m+<int> specification for axis %u min\n", me, ai);
airMopError(mop);
return 1;
}
Modified: teem/trunk/src/unrrdu/permute.c
===================================================================
-...
[truncated message content] |