SRL Archive - General

Range of "tolerance"?


moose_are_fun

2009-11-12 21:09:30

In functions requiring "tolerance", what is the maximum range? It appears that 0 is the minimum (that is, specifying comparison of the exact color). All the documentation says is this:


function SimilarColors(col1, col2, tolerance: Integer): Boolean;
Function to test weather two colors are within tolerance range. If they are within range, it returns true, if not false.


And:


function FindColorTolerance(var x, y: Integer; color, xs, ys, xe, ye: Integer; Tolerance: Integer): Boolean;
Works like the regular FindColor function but with a tolerance parameter for finding any similar color. Tolerance is used to find a color in range of the color you are looking for. The greater color range you want, the higher the tolerance parameter should be.


Is it limitless? Doesn't it end at some point? Or, is it relying on the values of the color?

Thanks.

TRiLeZ

2009-11-12 21:29:56

I believe the maximum tolerance is 255.

Rick

2009-11-12 21:43:29

Yeah, 0 to 255.

noidea

2009-11-12 22:23:33

422 for cts1
255 for cts2

Gu3st...

2009-11-13 02:54:02

From: noidea
422 for cts1
255 for cts2

Are you sure?
var I : Integer;
begin
ColorToleranceSpeed(1); //Replace the number with the CTS you want to test.
for I := 0 to 9999 do
if SimilarColors(0, 16777215, I) then
begin
WriteLn(IntToStr(I));
Break;
end;
end.
My results:
CTS 1 = 442 max
CTS 2 = 100 max
CTS 3 = 227 max

nielsie95

2009-11-13 13:22:37

cts 0 uses the maximum difference of RGB to calculate the tolerance -> Max(Abs(R1 - R2), Abs(G1 - G2), Abs(B1 - B2))
RGB is a value between 0 and 255, so in the worst case you have a tolerance of 255.

cts 1 uses the average difference of RGB -> Sqrt(Sqr(R1 - R2) + Sqr(G1 - G2) + Sqr(B1 - B2))
At worst case the tolerance is Sqrt(Sqr(255) * 3) = 442.

cts 2 uses modifiers, so it's harder to calculate the max tolerance there.

I don't know what formula cts 3 uses, so I can't say anything about that.

In all cases a tolerance > 100 is pretty high, > 50 is rather high and ~20 is a nice value (in general).

noidea

2009-11-13 15:40:01

Thanks for clearing that up :)
It's been awhile since I've worked with that.

moose_are_fun

2009-11-14 18:56:21

From: nielsie95
cts 1 uses the average difference of RGB -> Sqrt(Sqr(R1 - R2) + Sqr(G1 - G2) + Sqr(B1 - B2))
At worst case the tolerance is Sqrt(Sqr(255) * 3) = 442.


Maybe I'm misunderstanding you, but wouldn't the "average difference" be


(Abs(R1 - R2) + Abs(G1 - G2) + Abs(B1 - B2)) / 3

Where the max would then be 255, not 442?

I don't understand how
Sqrt(Sqr(R1 - R2) + Sqr(G1 - G2) + Sqr(B1 - B2))
is an "average difference" (and, moreover, it's going to fail if (R|G|B)1 > (R|G|B)2)

Thanks for the explanation though, that did clear some things up.

[Edit]

Okay, it appears that I misread Sqr() as Sqrt(). The two functions I stated are nearly equivalent (sqrt(x^2) == |x|), but I think you misplaced some parentheses.

Was this what you intended:


Sqrt(Sqr(R1 - R2)) + Sqrt(Sqr(G1 - G2)) + Sqrt(Sqr(B1 - B2))
?

If this is the case, I still don't understand how it's the "average" (don't you have to divide by three?)


(Sqrt(Sqr(R1 - R2)) + Sqrt(Sqr(G1 - G2)) + Sqrt(Sqr(B1 - B2))) / 3

[Further edit]

I was wrong, don't listen to me.

nielsie95

2009-11-15 12:51:06

My bad, I've chosen the wrong words :p
It's more like the distance between the two colours.

Same as that you can calculate the distance between two points:

d(a, b) = Sqrt(Sqr(a.x - b.x) + Sqr(a.y - c.y))

you can also calculate the distance between two colors (as if it's a 3 dimensional point):

Sqrt(Sqr(R1 - R2) + Sqr(G1 - G2) + Sqr(B1 - B2))

maxcreigs

2010-02-25 01:27:42

First you have to check if there is a defined tolerance group for the company code using T-code OBA4. Then, check if the username has been assigned a tolerance group using T-Code OB57.

Thanks.

Gu3st...

2010-02-25 03:30:38

From: maxcreigs
First you have to check if there is a defined tolerance group for the company code using T-code OBA4. Then, check if the username has been assigned a tolerance group using T-Code OB57.

Thanks.
What the hell are you talking about? Stop gravedigging old topics!