20 квітня 2012 р. 03:12 Graeme Gill <graeme@xxxxxxxxxxxxx> написав: > Ivan Tsyba wrote: > > .cal file contains 256 rows RGB_I RGB_R RGB_G RGB_B table and .ti3 file > contains 48 rows RGB_R > > RGB_G RGB_B XYZ_X XYZ_Y XYZ_Z table. How to append that 256 elements on > 48 elements? > > So it maybe little bit more sophisticated that just replacing RGB values > from cal to ti3 file? > > They are not appended, the values are replaced by their looked up values. > > So: > > for each row of the .ti3 file., ie: > > SAMPLE_ID RGB_R RGB_G RGB_B .... > . > 17 1.4275 34.039 73.682 ... > > for each of R, G & B, ie: > G = 34.039 > > Normalize G = 34.039/100 = 0.34039 > > Locate lookup point in .cal file for a G value of 0.34039 > by locating the RGB_I value it lies between: > > RGB_I RGB_R RGB_G RGB_B > 0.33725 0.36240 0.39923 0.35515 > 0.34118 0.36562 0.40221 0.35843 > > Linearly interpolate the G value > cal_G = (0.34039 - 0.33725)/(0.34118 - 0.33725) * 0.40221 > + (0.34118 - 0.34039)/(0.34118 - 0.33725) * 0.39923 > = 0.40161 > > [Note (0.34039 - 0.33725)/(0.34118 - 0.33725) = > 1.0 - (0.34118 - 0.34039)/(0.34118 - 0.33725)] > > De-normalize the calibrated G value > > cal_G *= 100.0 > > Replace the G value with its calibrated value in the .ti3 file: > > 17 nnnnn 40.161 nnnnn ... > > etc. > > etc. > > Graeme Gill. > > Thanks, this works. Many manual data manipulations, but works.