Results 1 to 7 of 7

Thread: Color tolerance

  1. #1
    Join Date
    Feb 2012
    Posts
    170
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default Color tolerance

    how do I tell if a color is in the red spectrum from it's number? (using getcolor function). I'm trying to make a function that returns if there is any red in a certain location, but I don't know how to search the location (a square about 20 by 20 pixels) and then figure out if it's red or not.

  2. #2
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Simba Code:
    Function IsNearRed(Colour, Tolerance: Integer): Boolean;
    begin
      Result := SimilarColors(255, Colour, Tolerance);
    end;

    Function FindRed(Area: TBox): Boolean;
    var
      Points: TPointArray;
    Begin
      Result := FindColorsTolerance(Points, 255, Area.X1, Area.Y1, Area.X2, Area.Y2, Tolerance);
    End;
    Last edited by Brandon; 12-28-2012 at 05:21 PM.
    I am Ggzz..
    Hackintosher

  3. #3
    Join Date
    Feb 2012
    Posts
    170
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    oh, findcolorstolerance is a boolean, that'll work splendidly, but I forget how tolerance is exactly, like how much do you need, and how much is too much. it's a color scale of 0 to 256 right?

  4. #4
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by xdarkshadowx View Post
    oh, findcolorstolerance is a boolean, that'll work splendidly, but I forget how tolerance is exactly, like how much do you need, and how much is too much. it's a color scale of 0 to 256 right?

    Well it doesn't matter. The colour scale can be from 0 to 16777215.

    Aka Black to White. 255 just happens to be true red. I use the 0 to 255 colour scale because I program in OpenGL and DirectX too much.

    Think of it like this:

    RGB(255, 0, 0); That's Red. The Green and Blue channels are 0.

    You can try: writeln(RGBToColor(255, 0, 0)); and see for yourself. It should be the exact same (prints 255).
    I am Ggzz..
    Hackintosher

  5. #5
    Join Date
    Feb 2012
    Posts
    170
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    So a tolerance of like ten would give me most reds? or do I need higher/lower?

  6. #6
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    Quote Originally Posted by xdarkshadowx View Post
    So a tolerance of like ten would give me most reds? or do I need higher/lower?
    Why not just use ACA to find the color, it will find the tolerance and color ect for you. Then you can use those values in FindColorSpiral, or in a function like this
    Simba Code:
    If FindColortolerance(Color Info, box info) then
      begin
        Result:= True;
        Writeln('We found the color');
      end else
      begin
        Result:= False;
        Writeln('We did not find the color');
      end;

  7. #7
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    not finished but covers all RGB stuff already:

    http://villavu.com/forum/showthread.php?t=89308

    e:
    I also wrote another tut, you can find it in my sig.
    Working on: Tithe Farmer

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
  •