Still working on this, but here is a preview of possible tool. It will process png files given as parameters and recolorize according to options.cfg in same folder as image.
http://files.[ simutrans [dot] us (site down, do not visit) ]/files/get/Oxqw_T3Xnu/recolorer.7z
Sounds interesting. Have I understood this tool correctly, i.e. could be used as follows?
1) render image in, say, black and pink
2) use tool to convert pink to player colour, black stays the same?
And does this work for 2 player colours?
This may solve the long-standing request for pak128.Britain vehicles in player colours without too much fuss...
Currently it works like this:
For every pixel,
store current colour as best result but with high metric
for every candidate colour,
find metric
and if metric is bettter than best result,
store this result as best
finally, replace original colour with the best result
metric is Euclidian distance in rgb space
Zeno has worked out a better (more automatic) workflow for Blender, so you might want to give that a test instead. It's based on taking the normal render (w. OSA) and masking with non-osa & shadeless render...
I found that sqrt(r*r*2 + g*g*3 + b*b) often is closer to what human eye sees as "similar" colors than unbiased euclidean distance in rgb space.
Actually I have a small app that is strictly based in my working workflow, thus is only applicable to that way of working and it hasn't any flexibility at the moment.
As VS explains, this way of doing things is based on mask and osa renders. If anyone wants more info on it contact me via PM or the IRC chat (or just post here).