Results 1 to 11 of 11

Thread: Range of "tolerance"?

  1. #1
    Join Date
    Nov 2009
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Range of "tolerance"?

    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.

  2. #2
    Join Date
    Feb 2009
    Posts
    1,447
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

  3. #3
    Join Date
    Oct 2006
    Posts
    500
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  4. #4
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    422 for cts1
    255 for cts2

  5. #5
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by noidea View Post
    422 for cts1
    255 for cts2
    Are you sure?
    SCAR Code:
    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

  6. #6
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    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).
    Last edited by nielsie95; 11-13-2009 at 06:29 PM.

  7. #7
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

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

  8. #8
    Join Date
    Nov 2009
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by nielsie95 View Post
    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

    Code:
    (Abs(R1 - R2) + Abs(G1 - G2) + Abs(B1 - B2)) / 3
    Where the max would then be 255, not 442?

    I don't understand how
    Code:
    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:

    Code:
    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?)

    Code:
    (Sqrt(Sqr(R1 - R2)) + Sqrt(Sqr(G1 - G2)) + Sqrt(Sqr(B1 - B2))) / 3
    [Further edit]

    I was wrong, don't listen to me.
    Last edited by moose_are_fun; 11-15-2009 at 12:11 AM.

  9. #9
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    My bad, I've chosen the wrong words
    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))

  10. #10
    Join Date
    Feb 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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.

  11. #11
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by maxcreigs View Post
    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!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •