Mercurial > hg > minc-tools
changeset 980:ba65debc47cf
Added -exp and -log options.
author | neelin <neelin> |
---|---|
date | Wed, 17 Jan 1996 21:24:06 +0000 |
parents | 5b22ea40ff27 |
children | 7c7801b48f7a |
files | progs/mincmath/mincmath.c progs/mincmath/mincmath.man1 |
diffstat | 2 files changed, 37 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/progs/mincmath/mincmath.c +++ b/progs/mincmath/mincmath.c @@ -9,9 +9,12 @@ @CALLS : @CREATED : April 28, 1995 (Peter Neelin) @MODIFIED : $Log: mincmath.c,v $ -@MODIFIED : Revision 3.2 1996-01-16 13:29:31 neelin -@MODIFIED : Added -invert option. +@MODIFIED : Revision 3.3 1996-01-17 21:24:06 neelin +@MODIFIED : Added -exp and -log options. @MODIFIED : + * Revision 3.2 1996/01/16 13:29:31 neelin + * Added -invert option. + * * Revision 3.1 1995/12/13 16:22:24 neelin * Added -check_dimensions and -nocheck_dimensions options. * @@ -27,7 +30,7 @@ ---------------------------------------------------------------------------- */ #ifndef lint -static char rcsid[]="$Header: /private-cvsroot/minc/progs/mincmath/mincmath.c,v 3.2 1996-01-16 13:29:31 neelin Exp $"; +static char rcsid[]="$Header: /private-cvsroot/minc/progs/mincmath/mincmath.c,v 3.3 1996-01-17 21:24:06 neelin Exp $"; #endif #include <stdlib.h> @@ -61,7 +64,7 @@ UNSPECIFIED_OP = 0, ADD_OP, SUB_OP, MULT_OP, DIV_OP, SQRT_OP, SQUARE_OP, SCALE_OP, CLAMP_OP, SEGMENT_OP, NSEGMENT_OP, PERCENTDIFF_OP, EQ_OP, NE_OP, GT_OP, GE_OP, LT_OP, LE_OP, AND_OP, OR_OP, NOT_OP, -ISNAN_OP, NISNAN_OP, INVERT_OP +ISNAN_OP, NISNAN_OP, INVERT_OP, EXP_OP, LOG_OP } Operation; typedef enum { @@ -95,6 +98,8 @@ UNARY_NUMOP, ILLEGAL_NUMOP, ILLEGAL_NUMOP, /* ISNAN_OP */ UNARY_NUMOP, ILLEGAL_NUMOP, ILLEGAL_NUMOP, /* NISNAN_OP */ UNARY_NUMOP, UNARY_NUMOP, ILLEGAL_NUMOP, /* INVERT_OP */ + UNARY_NUMOP, UNARY_NUMOP, UNARY_NUMOP, /* EXP_OP */ + UNARY_NUMOP, UNARY_NUMOP, UNARY_NUMOP, /* LOG_OP */ ILLEGAL_NUMOP, ILLEGAL_NUMOP, ILLEGAL_NUMOP /* nothing */ }; @@ -227,6 +232,10 @@ "Take square root of a volume."}, {"-square", ARGV_CONSTANT, (char *) SQUARE_OP, (char *) &operation, "Take square of a volume."}, + {"-exp", ARGV_CONSTANT, (char *) EXP_OP, (char *) &operation, + "Calculate c2*exp(c1*x). The constants c1 and c2 default to 1."}, + {"-log", ARGV_CONSTANT, (char *) LOG_OP, (char *) &operation, + "Calculate log(x/c2)/c1. The constants c1 and c2 default to 1."}, {"-scale", ARGV_CONSTANT, (char *) SCALE_OP, (char *) &operation, "Scale a volume: volume * c1 + c2."}, {"-clamp", ARGV_CONSTANT, (char *) CLAMP_OP, (char *) &operation, @@ -426,7 +435,9 @@ for (iconst=0; iconst < sizeof(constants)/sizeof(constants[0]); iconst++) { if (iconst < num_constants) constants[iconst] = math_data->constants[iconst]; - else if (operation == INVERT_OP) + else if ((operation == INVERT_OP) || + (operation == EXP_OP) || + (operation == LOG_OP)) constants[iconst] = 1.0; else constants[iconst] = 0.0; @@ -482,6 +493,16 @@ break; case SQUARE_OP: output_data[0][ivox] = value1 * value1; break; + case EXP_OP: + output_data[0][ivox] = constants[1] * exp(value1 * constants[0]); + break; + case LOG_OP: + if ((value1 <= 0.0) || (constants[1] <= 0.0) || + (constants[0] == 0.0)) + output_data[0][ivox] = illegal_value; + else + output_data[0][ivox] = log(value1/constants[1])/constants[0]; + break; case SCALE_OP: output_data[0][ivox] = value1 * constants[0] + constants[1]; break; case CLAMP_OP:
--- a/progs/mincmath/mincmath.man1 +++ b/progs/mincmath/mincmath.man1 @@ -8,7 +8,7 @@ .\" software for any purpose. It is provided "as is" without .\" express or implied warranty. .\" -.\" $Header: /private-cvsroot/minc/progs/mincmath/mincmath.man1,v 3.2 1996-01-16 13:29:31 neelin Exp $ +.\" $Header: /private-cvsroot/minc/progs/mincmath/mincmath.man1,v 3.3 1996-01-17 21:24:06 neelin Exp $ .\" .TH MINCMATH 1 @@ -167,6 +167,16 @@ .I -square: Calculate the square of a volume. .P +.I -exp: +Calculate c2*exp(c1*x) at each voxel of a volume, where x is the +voxel value and c1 and c2 are constants specified by -constant c1 or +-const2 c1 c2. The default value for these constants is 1.0. +.P +.I -log: +Calculate log(x/c2)/c1 for each voxel of a volume, where x is the +voxel value and c1 and c2 are constants specified by -constant c1 or +-const2 c1 c2. The default value for these constants is 1.0. +.P .I -scale: Scale a volume either by multiplying by a single constant (use -constant) or by multiplying by the first constant and adding the