Results 1 to 14 of 14

Thread: Color tolerance

  1. #1
    Join Date
    Aug 2010
    Posts
    6
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Color tolerance

    I don't quite understand color tolerance, and what it should be at generally.

    Also, how does color finding not mistake something for other things on the screen???

  2. #2
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by pjwaffle View Post
    I don't quite understand color tolerance, and what it should be at generally.

    Also, how does color finding not mistake something for other things on the screen???
    Tolerance is like accuracy. If you're trying to find a color with a tolerance of 0, it will only find that color, but if you have a tolerance of 10, then it will find the original color plus colors that are close to that color.

    And color finding can mistake one thing for another on the screen, that's why there are failsafes like uptext. If the mouse was to hover the wrong object, it wouldn't click if the uptext was wrong.

    It also helps if you're using CTS 2/3 which makes it more accurate than CTS 1. See some guides on ColoerToleranceSpeeds in the tutorial section.

  3. #3
    Join Date
    May 2007
    Location
    Everywhere
    Posts
    1,428
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    I'd like to know how tolerance works as a mechanism one day. For example, can anyone predict the range of colors it will search when attempting to find Color 1000000 with a tolerance of 5?

  4. #4
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    it searches withing 5 of the RGB values.

    So if you had (213,100,134) and searched with tol of 3, (210->216, 97->103,131->137) would be valid.

    E: thats only with CTS zero and one.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  5. #5
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by pjwaffle View Post
    I don't quite understand color tolerance, and what it should be at generally.

    Also, how does color finding not mistake something for other things on the screen???
    Quote Originally Posted by cstrike View Post
    I'd like to know how tolerance works as a mechanism one day. For example, can anyone predict the range of colors it will search when attempting to find Color 1000000 with a tolerance of 5?
    Colors in their decimal form are like 16777215, 255, 0 (white, red, black) and all colors are composed generally of three or four elements.

    Like for example 255 (clRed) is 255 red 0 green 0 blue

    16777215 (clWhite) is 255 red 255 green 255 blue

    You get the picture, now of course there is more than RGB (red green blue) there is HSL (hue saturation luminance) XYZ, LAB... the list goes on.

    Now colors (in runescape particularly) are designed to fluctuate. When you call a simple FindColor or GetColor() = 000000 in SCAR it's only going to return true if that exact same color was found. So in order to compensate for this we add in a thing called tolerance. What it does it determines the range of say a Max Red, Min Red, Max Green, Min Green, Max Blue, Min Blue of a color.... now depending on which CTS (color tolerance speed) you use the tolerance level will be different and target different types of color fluctuations.

    Straight out of SCAR manual

    procedure ColorToleranceSpeed(x: Integer);
    Sets the speed of tolerance comparisons. ColorToleranceSpeed(1) is a little slower then 0 but more accurate. ColorToleranceSpeed(0) is faster but not as accurate as 1. ColorToleranceSpeed(2) uses Hue, Saturation and Lightness to determine color similarity. ColorToleranceSpeed(3) uses the CIE colorspace to compare colors (XYZ), it's usually fairly slower than the other modes but it's extremely accurate.
    To get a better understanding and to know how much tolerance you should use for a certain thing, there is a thing called ACA (auto color aid) it can be found in tools -> explorer folder -> includes -> SRL -> scripting tools.

    There's also various tutorials on this in the scripting tutorial sections.

  6. #6
    Join Date
    May 2007
    Location
    Everywhere
    Posts
    1,428
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    I use ACA aid a lot, it's great for making FindObj stuff.

    What I don't understand from the above would be:
    - What is decimal form of a color?
    - How is 255/255/255 rgb = 16777215? Does that apply to the 16777215,255,0?
    - How can there be a 16777215, 255, 0 (white, red, black), I thought they went up to 255 only
    - If we have color x as something like 600000, if we subtract one, will it look sort of like the same color? Or could it vary wildly by just increasing the longint by 1?

    I've actually been looking for tutorials on color. I feel lost without understanding *exactly* how color works. I know I can just use ACA for pretty much everything, but it leaves a huge gap in my knowledge of how and why it works. Pretty much, I'm like a physicist who can make a rocket go into space without knowing d/t=v.
    I've looked through probably most guides as I attempted [and succeeded] at getting into SRL members. Now it's time to fill in all these gaps. I'd like to be more proficient with color too, and I'm sure this will aid me a lot
    If you have any links that explain everything in the most minute of detail I will read [or re-read!] again with precision.


    EDIT: Another reason tolerance can be confusing for me is because according to This tutorial, color tolerance is basically RANGE = COLOR - TOLERANCE, yet when I set a tolerance of 50 or 100... or even 300... it will cover the whole screen pretty much in red; thus confusing me on how tolerance works since I know all of the pixels are not 300 units away from the color chosen.
    Last edited by Cstrike; 09-13-2010 at 04:40 AM.

  7. #7
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by cstrike View Post
    - What is decimal form of a color?
    - How is 255/255/255 rgb = 16777215? Does that apply to the 16777215,255,0?
    - How can there be a 16777215, 255, 0 (white, red, black), I thought they went up to 255 only
    - If we have color x as something like 600000, if we subtract one, will it look sort of like the same color? Or could it vary wildly by just increasing the longint by 1?
    white red black? It's Red Green Blue. The color 60000 is potentially very much different from 60001 such as green -> red (open the DTM editer up and manually edit the color value to change the preview, you'll see what I mean).

    Colors in decimal form are this way because of bitwise operations http://villavu.com/forum/showthread.php?t=18514
    http://villavu.com/forum/showthread.php?t=55234 (simpler)

  8. #8
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Tolerance is just a formula that we use to define how similar colours are. If they are very similar, the tolerance will be low, if they are not at all similar, the tolerance will have to be high to match them. This makes it easy for example to find colour that look ``red''.

    Quote Originally Posted by IceFire908 View Post
    Straight out of SCAR manual
    I never found the SCAR manual to give a pleasing description of each tolerance, so here's my try at quickly describing the tolerances in Simba: http://wizzup.org/simbadoc/scriptref...lour-tolerance
    (The entire article may be of use for the OP)

    For an even better understanding of the algorithms, we take a look at the Simba source:

    Simba Code:
    function TMFinder.SimilarColors(Color1, Color2,Tolerance: Integer) : boolean;
    var
      R1,G1,B1,R2,G2,B2 : Byte;
      H1,S1,L1,H2,S2,L2 : extended;
    begin
      Result := False;
      ColorToRGB(Color1,R1,G1,B1);
      ColorToRGB(Color2,R2,G2,B2);
      if Color1 = Color2 then
        Result := true
      else
      case CTS of
      0: Result := ((Abs(R1-R2) <= Tolerance) and (Abs(G1-G2) <= Tolerance) and (Abs(B1-B2) <= Tolerance));
      1: Result := (Sqrt(sqr(R1-R2) + sqr(G1-G2) + sqr(B1-B2)) <= Tolerance);
      2: begin
           RGBToHSL(R1,g1,b1,H1,S1,L1);
           RGBToHSL(R2,g2,b2,H2,S2,L2);
           Result := ((abs(H1 - H2) <= (hueMod * Tolerance)) and (abs(S2-S1) <= (satMod * Tolerance)) and (abs(L1-L2) <= Tolerance));
         end;
      end;
    end;
    Last edited by Wizzup?; 09-13-2010 at 07:13 AM.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  9. #9
    Join Date
    Mar 2008
    Location
    In a cave
    Posts
    345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice! This one got me interested as well. Any tips where could I find the sources for ColorToRGB and RGBToHSL ?
    A Chinese wiseman once said: "Shu ciu!", it was considered very smart, but now people know it means: "Something stinks here!"
    FalBuggySmelter v.1.31
    [Updated on the 1st of March 2010]
    RimmBugger BETA V1.8

  10. #10
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  11. #11
    Join Date
    Mar 2008
    Location
    In a cave
    Posts
    345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    If you use CTS2 then you define those as globals, i suppose...
    A Chinese wiseman once said: "Shu ciu!", it was considered very smart, but now people know it means: "Something stinks here!"
    FalBuggySmelter v.1.31
    [Updated on the 1st of March 2010]
    RimmBugger BETA V1.8

  12. #12
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by bugger0001 View Post
    Nice! This one got me interested as well. Any tips where could I find the sources for ColorToRGB and RGBToHSL ?
    Here. https://git.villavu.com/?p=simba.git...lour_conv.pas;

    hueMod and satMod default to 0.2, Shuttleu.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  13. #13
    Join Date
    Mar 2008
    Location
    In a cave
    Posts
    345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks! That cleared out couple of issues I had with colours
    A Chinese wiseman once said: "Shu ciu!", it was considered very smart, but now people know it means: "Something stinks here!"
    FalBuggySmelter v.1.31
    [Updated on the 1st of March 2010]
    RimmBugger BETA V1.8

  14. #14
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Shuttleu View Post
    sorry, but where does hueMod and satMod come from?

    ~shut
    It's a predefined variable IIRC. So when you change hueMod and satMod in your script(SetToleranceSpeed2Modifiers) it's also modified inside Simba.


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
  •