Results 1 to 11 of 11

Thread: ColorSpeedModifiers

  1. #1
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default ColorSpeedModifiers

    Well, I came accross all the ColorSpeedModifier functions in the "help" section of Scar, but I didn't quite grasp it, and would really appreciate it if anyone could explain this to me, because looking through scripts hasn't really helped a lot either... Here is the quote of of the "Help" section:

    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.

    function GetColorToleranceSpeed: Integer;
    Returns the current tolerancespeed.

    procedure SetColorspeed2Modifiers(huemodifier, saturationmodifier: Extended);
    These work when ColorToleranceSpeed(2) has been set. Normally Tolerance parameter in this mode applies to Luminance directly. For an example, SimilarColors(c1, c2, 10) would work if both colors differ by 10 max luminance. After calling SetColorspeed2Modifiers(0.2, 2) it would mean that SimilarColors(c1, c2, 10) would check for Hue in range of 2 and Saturation in range of 20. Default huemodifier and saturationmodifier is 0.2.

    procedure GetColorspeed2Modifiers(var huemodifier, saturationmodifier: Extended);
    Gets the current Colorspeed2 modifiers.

    procedure SetColorspeed3Modifiers(Sensitivity: Integer);
    This works when ColorToleranceSpeed(3) has been set. This sets the Sensitivity of the 3th color comparison mode. The default Sensitivity is 4. (Note that this is carefully chosen and will be sufficient in most cases.)

    procedure GetColorspeed3Modifiers(var Sensitivity: Integer);
    Gets the current Colorspeed2 modifiers.
    So, what exactly is the difference between them, and what happens when I use/change them? I know it's a lot to ask for a simple post in the scripting help section, but I need them for my Willow cutter. (I have seen some convincing results in my search for an explanation)

    Thanks a bunch,
    Pure1993
    There is nothing right in my left brain and there is nothing left in my right brain.

  2. #2
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    from what I've seen.. CTS(0) is the fastest but least accurate.. and as you go up, they get slower and more accurate, so CTS(3) is extremely accurate, but relatively slow.. It seems unnoticeable to me.. but I'd use CTS(2)

    especially for willow cutting.. and if you get problems, try CTS(3)

    I hope that helped

  3. #3
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    So, I would simply call ColorToleranceSpeed(3) {Or 2, depending on what works} and then use any color finding function? Does it simply change the kind of tolerance with which it finds the colors? I think I read something about HSL being CTS(2), and xyz CTS(3), is that somewhat correct?
    Sorry for all the questions, this is completely new ground for me...

    Thanks a lot for that answer though ^^
    There is nothing right in my left brain and there is nothing left in my right brain.

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

    Default

    Its very usefull, and there is a whole tut by Cazax on it, which is very sexy.
    SCAR Code:
    Function FindTree(var Tree: TPoint): Boolean;
    var
      CTSS, i, TestColor: Integer;
      Tree1: TPointArray;
      Tree2: Array of TPointArray;
    begin
      if not loggedin then exit;
      CTSS := GetColorToleranceSpeed;
      ColorToleranceSpeed(3);
      SetColorSpeed3Modifiers(9);
      FindColorsSpiralTolerance(mscx, mscy, Tree1, 4819069, msx1, msy1, msx2, msy2, 5);
      DebugTPA(Tree1, '');
      If length(Tree1) < 1 then
      begin
        Writeln('No Tree on MS!');
        Result := False;
        exit;
      end;
      ColorToleranceSpeed(CTSS);

      Tree2 := TPAToATPAEx(Tree1, 20, 15);
     
      For i := 0 to High(Tree2) do
      begin
        MiddleTPAEx(Tree2[i], Tree.x, Tree.y);
        TestColor := GetColor(Tree.x, Tree.y);
        mmouse(Tree.x, Tree.y, 6, 6);
        TextWait;
        If isuptext('Tree') then
        begin
          GetMousePos(Tree.x, tree.y);
          Result := True;
          Exit;
        end;
      end;
    end;

    Right there, thats a FLAWLESS Normal/(Oak) Tree finder.
    The higher the MODIFIER the less tolerance you have to use. Its a great colour aglo
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  5. #5
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ah, that makes it alot easier to understand, thanks.

    I think I got it now, thanks to both of you.
    There is nothing right in my left brain and there is nothing left in my right brain.

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

  7. #7
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hehe, I read through yours before posting, don't worry.
    It just wasn't very detailed on the explanations... Or at least not detailed enough for me...

    Well, if you are already on this thread: What do you have to do, so that it colors every found color red on the picture, like you did on your tutorial?
    There is nothing right in my left brain and there is nothing left in my right brain.

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

    Default

    Debug TPA by Wizzup:
    scar Code:
    Function DebugTPA(Points: TPointArray; BmpName: String): Boolean;

    Var
       Width, Height, ClientBMP, I: Integer;
       xs, ys, xe, ye: Integer;

    Begin
      Try
      Begin
        xe := xs xor xs;
        ye := ys xor ys;
        xs := 1 shl 20;
        ys := 1 shl 20;

        For I := 0 To High(Points) Do
        Begin
          xs := Min(xs, Points[i].X);
          ys := Min(ys, Points[i].Y);

          xe := Max(xe, Points[i].X);
          ye := Max(ye, Points[i].Y);
        End;

        Width := xe - xs;
        Height := ye - ys;

        DisplayDebugImgWindow(0, 0);
        DisplayDebugImgWindow(Width, Height);
        ClientBMP := BitmapFromString(Width, Height, '');

        CopyClientToBitmap(ClientBMP, xs, ys, xe, ye);
        For I := 0 To High(Points) Do
          FastSetPixel(ClientBMP, Points[i].X - xs, Points[i].Y - ys, 255);
        If BmpName <> '' Then
          SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');
        SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
        DisplayDebugImgWindow(Width, Height);

        FreeBitmap(ClientBMP);
      End
      Except
        FreeBitmap(ClientBMP);
      End;
      Result := True;
    End;
    If you have any other TPA question, look here http://www.villavu.com/forum/showthread.php?t=42428


  9. #9
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Haha, alright, I think before posting future questions, I'll check you list of created threads... it seems that there isn't a single question that isn't answered in one of your tutorials... that tutorial cup is well deserved
    There is nothing right in my left brain and there is nothing left in my right brain.

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

    Default

    Check out the Debug.scar as well in the Misc Folder.

    Also, the Hue and Sat. modifiers in CTS 2 are part of that speed. Try reading google on HSL colors, as well as XYZ and RGB. The articles are informative on the topic.
    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

  11. #11
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    My RGB/HSL/Autocolor tut, I think I got the basic idea
    but thanks for the hint of checking out the debug.scar, wasn't aware of it until now.
    There is nothing right in my left brain and there is nothing left in my right brain.

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
  •