Richard
2012-01-13 16:32:51
Been doing a little bit of research into finding what the best tolerance is for colour finding techniques is. I had this idea of logging in and out many times and grabbing colours of the same pixel. I then thought of making this function that takes all the colours, and then calculates a tolerance that would be able to find all of the given colours with any of the colours used in the function.
Note: This only works using CTS 1 (RGB):
I did a couple of tests, using the colours below:
The colour pairs here are 36095/42495 and 16711680/14772545.
The results given are 25 and 105. Even though the blue pairs are quite similar, either the green or red values must change a lot.
If I am to make this more effective, I need to work with CTS2 and CTS3, the problem is that I don't know how the tolerances for HSL and XYZ work, if someone could tell me how their tolerances work, then I'd be able to adapt this function (so it has CTS in the parameters) to work with more accurate CTSs.
Thanks.
Note: This only works using CTS 1 (RGB):
function GetBestTolerance(Colors: TIntegerArray): Integer;
var
vals: Array [0..2] of Array of Integer;
low,high: Array [0..2] of Byte;
differences: array [0..2] of Integer;
i: Integer;
begin
for i := 0 to 2 do
SetArrayLength(vals[i],Length(Colors));
for i := 0 to Length(Colors) - 1 do
ColorToRGB(Colors[i], vals[0][i], vals[1][i], vals[2][i]);
for i := 0 to 2 do
begin
low[i] := MinA(vals[i]);
high[i] := MaxA(vals[i]);
differences[i] := high[i] - low[i];
end;
Result := MaxA(differences);
end; I did a couple of tests, using the colours below:
The colour pairs here are 36095/42495 and 16711680/14772545.The results given are 25 and 105. Even though the blue pairs are quite similar, either the green or red values must change a lot.
If I am to make this more effective, I need to work with CTS2 and CTS3, the problem is that I don't know how the tolerances for HSL and XYZ work, if someone could tell me how their tolerances work, then I'd be able to adapt this function (so it has CTS in the parameters) to work with more accurate CTSs.
Thanks.