7 const float REF_PT = (7120.0 - 1520.0) / 8000.0 * (100.0 / 55.0) - log10(0.18);
9 const float LUT_1D[11][2] = {
10 {-0.190000000000000, -6.000000000000000},
11 { 0.010000000000000, -2.721718645000000},
12 { 0.028000000000000, -2.521718645000000},
13 { 0.054000000000000, -2.321718645000000},
14 { 0.095000000000000, -2.121718645000000},
15 { 0.145000000000000, -1.921718645000000},
16 { 0.220000000000000, -1.721718645000000},
17 { 0.300000000000000, -1.521718645000000},
18 { 0.400000000000000, -1.321718645000000},
19 { 0.500000000000000, -1.121718645000000},
20 { 0.600000000000000, -0.926545676714876}
23 // Convert Channel Independent Density values to Relative Log Exposure values
25 if ( cid[0] <= 0.6) logE[0] = interpolate1D( LUT_1D, cid[0]);
26 if ( cid[1] <= 0.6) logE[1] = interpolate1D( LUT_1D, cid[1]);
27 if ( cid[2] <= 0.6) logE[2] = interpolate1D( LUT_1D, cid[2]);
29 if ( cid[0] > 0.6) logE[0] = ( 100.0 / 55.0) * cid[0] - REF_PT;
30 if ( cid[1] > 0.6) logE[1] = ( 100.0 / 55.0) * cid[1] - REF_PT;
31 if ( cid[2] > 0.6) logE[2] = ( 100.0 / 55.0) * cid[2] - REF_PT;
35 def interpolate1D(x, xp, fp):
36 return numpy.interp(x, xp, fp)
38 LUT_1D_xp = [-0.190000000000000,
50 LUT_1D_fp = [-6.000000000000000,
62 REF_PT = (7120.0 - 1520.0) / 8000.0 * (100.0 / 55.0) - math.log(0.18, 10.0)
66 return interpolate1D(x, LUT_1D_xp, LUT_1D_fp)
67 return (100.0 / 55.0) * x - REF_PT
69 def WriteSPI1D(filename, fromMin, fromMax, data):
70 f = file(filename,'w')
71 f.write("Version 1\n")
72 f.write("From %s %s\n" % (fromMin, fromMax))
73 f.write("Length %d\n" % len(data))
74 f.write("Components 1\n")
77 f.write(" %s\n" % value)
81 def Fit(value, fromMin, fromMax, toMin, toMax):
82 if fromMin == fromMax:
83 raise ValueError("fromMin == fromMax")
84 return (value - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin
89 for i in xrange(NUM_SAMPLES):
90 x = i/(NUM_SAMPLES-1.0)
91 x = Fit(x, 0.0, 1.0, RANGE[0], RANGE[1])
92 data.append(cid_to_rle(x))
94 WriteSPI1D('adx_cid_to_rle.spi1d', RANGE[0], RANGE[1], data)