|
From: Gordon K. <kin...@us...> - 2004-04-22 07:56:31
|
Update of /cvsroot/teem/teem/src/bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6356 Modified Files: overrgb.c Log Message: added ability to do contrast and contrast fixed point Index: overrgb.c =================================================================== RCS file: /cvsroot/teem/teem/src/bin/overrgb.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** overrgb.c 16 Jan 2004 17:52:37 -0000 1.12 --- overrgb.c 22 Apr 2004 07:01:40 -0000 1.13 *************** *** 36,39 **** --- 36,55 ---- "image; it will be resampled (with linear interpolation) to fit. "); + double + docontrast(double val, double cfp, double cpow) { + double v; + + if (val < cfp) { + v = AIR_AFFINE(0.0, val, cfp, 0.0, 1.0); + v = pow(v, cpow); + val = AIR_AFFINE(0.0, v, 1.0, 0.0, cfp); + } else { + v = AIR_AFFINE(cfp, val, 1.0, 1.0, 0.0); + v = pow(v, cpow); + val = AIR_AFFINE(1.0, v, 0.0, cfp, 1.0); + } + return val; + } + int main(int argc, char *argv[]) { *************** *** 45,49 **** *nrgbaD; /* rgba input as double */ char *me, *outS, *errS; ! double gamma, back[3], *rgbaD, r, g, b, a; airArray *mop; int E, min[3], max[3], i, rI, gI, bI, sx, sy; --- 61,65 ---- *nrgbaD; /* rgba input as double */ char *me, *outS, *errS; ! double gamma, contr, cfp, cpow, back[3], *rgbaD, r, g, b, a; airArray *mop; int E, min[3], max[3], i, rI, gI, bI, sx, sy; *************** *** 55,60 **** hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, NULL, "input nrrd to composite", NULL, NULL, nrrdHestNrrd); hestOptAdd(&hopt, "g", "gamma", airTypeDouble, 1, 1, &gamma, "1.0", ! "gamma to apply to image data"); hestOptAdd(&hopt, "b", "background", airTypeDouble, 3, 3, back, "0 0 0", "background color to composite against; white is " --- 71,82 ---- hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, NULL, "input nrrd to composite", NULL, NULL, nrrdHestNrrd); + hestOptAdd(&hopt, "c", "contrast", airTypeDouble, 1, 1, &contr, "0.0", + "contrast to apply to RGB values, before gamma. \"0.0\" " + "means no change, \"1.0\" means thresholding, \"-1.0\" " + "means a complete washout."); + hestOptAdd(&hopt, "cfp", "fixed point", airTypeDouble, 1, 1, &cfp, "0.5", + "component level that doesn't change with contrast"); hestOptAdd(&hopt, "g", "gamma", airTypeDouble, 1, 1, &gamma, "1.0", ! "gamma to apply to image data, after contrast"); hestOptAdd(&hopt, "b", "background", airTypeDouble, 3, 3, back, "0 0 0", "background color to composite against; white is " *************** *** 146,150 **** free(errS); return 1; } ! outUC = (unsigned char*)nout->data; bgUC = nbg ? nbg->data : NULL; --- 168,174 ---- free(errS); return 1; } ! ! contr = AIR_CLAMP(-1, contr, 1); ! cpow = tan(AIR_AFFINE(-1.000001, contr, 1.000001, 0, AIR_PI/2)); outUC = (unsigned char*)nout->data; bgUC = nbg ? nbg->data : NULL; *************** *** 155,158 **** --- 179,187 ---- b = AIR_CLAMP(0, rgbaD[2], 1); a = AIR_CLAMP(0, rgbaD[3], 1); + if (1 != cpow) { + r = docontrast(r, cfp, cpow); + g = docontrast(g, cfp, cpow); + b = docontrast(b, cfp, cpow); + } r = pow(r, 1.0/gamma); g = pow(g, 1.0/gamma); |