I don't know whether this is coincidence, or a quirk of number theory. If it's the latter it's well beyond me, and I'd be interested in any comments.
I've got a test program which is sending binary messages to a graphical output device, the configuration messages can include a palette.
When I was defining palettes in the test program I decided that rather than entering in lots of numbers I'd allow the user to specify either a linear, logarithmic or antilogarithmic (exponential) transfer function.
The palette can be of various sizes: 2^1, 2^2 ... 2^6. The smallest value in the palette should be 0 and the largest 255, so in the case of 2^1 it's (0, 255) and so on.
Of these, the most demanding palette is the exponential palette of size 2^2, since the ideal is to have the smallest value zero and the next non-zero... getting this right took some experimentation. Assuming that entries indexed i = 0..3 are i^z, I get this for various values of z:
(* 1.0001 249 251 253 255 *) (* 1.001 198 215 234 255 *) (* 1.01 20 47 109 255 *) (* 1.1 0 0 0 255 *) (* 1.05 0 0 4 255 *) (* 1.025 0 4 31 255 *) (* 1.024 1 5 34 255 *) (* 1.026 0 3 29 255 *)
I'm assuming that the best z for a palette sized 2^2 is also best for larger palettes, and I'm slightly spooked that the digit sequence radix 10 is so familiar.
Is there any rational reason why the best z = (2^10+1)/10^3 or is it a dumb coincidence? :-)
MarkMLl
I think I can follow the above up to, but not including, the list. Can you pls show how you calculate the linear, logarithmic & eponential transfer.
Also, looking at the list above, I would have choosen z = 1.025 or z = 1.026 as "best fit" by your explanation. As you have obviously choosen 1.001 I must have misunderstood something - care to explain in more detail?
QuoteAlso, looking at the list above, I would have choosen z = 1.025 or z = 1.026 as "best fit" by your explanation. As you have obviously choosen 1.001 I must have misunderstood something - care to explain in more detail?
No, that list was purely in the order I worked through to get the results: the value I chose- and am puzzled over- is 1.025 which gives the sequence (0, 4, 31, 255).
MarkMLl
Now that I saw your calculation I am convinced it is a coincidence that you found z= 1.025 / 1.026 as best fit. The way you are calculating requires a z for which holds z^255 >= 2*255 (to get the lower rounding to 0 correct). If you solve that for z you get 1.0247499.... (for equality). If you had i.e. a LUT maximum of 1,023 (instead of 255) the equivalent calculation would spit out z = 1.007473... As described above (in my edited post) I would have done the exponential fit slightly different.