Page 1 of 4 123 ... LastLast
Results 1 to 25 of 89

Thread: ACA - AutoColorAid by Nielsie95

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

    Default ACA - AutoColorAid by Nielsie95

    ACA a.k.a. AutoColorAid

    by Nielsie95



    This is a snippet which helps you to autocolor something. You enter as much colors as you can get and the script will create an autocolor procedure using RGB, HSL or XYZ.
    The script itself will decide which is the best to use
    It also sets the best ColorToleranceSpeed and Tolerance.
    I also integrated the snippet from Boreas which helps you to get the best color from a bitmap .






    Please comment, suggest and test.



    Credits to RkRoxPunk for helping me with the name
    Credits to Wizzup for the ColorToleranceSpeed compare.
    Credits to Sumilion for the updated AutoColor Function
    Credits to Tarajunky for getting the best color + tol from the array!
    Credits to Boreas for the Color from Bitmap

    older version downloads: 155.

    Nielsie95
    Hup Holland Hup!

  2. #2
    Join Date
    Jan 2007
    Location
    Not here
    Posts
    1,604
    Mentioned
    2 Post(s)
    Quoted
    19 Post(s)

    Default

    niel's wheels colour shmuller

    anywayz...yay first post...worked great for me on the grey MM rocks with 10 colours. well done
    Sleeping...

  3. #3
    Join Date
    Jun 2006
    Location
    USA
    Posts
    1,828
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Cant check it out now, but I may test it later.
    But it looks just great!

  4. #4
    Join Date
    Mar 2006
    Posts
    3,051
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    It looks like it automatically picked the first number in the series as the generic search color. It would be better if you found the median number and used that, since it should reduce the tolerance needed.

  5. #5
    Join Date
    Jun 2007
    Location
    Kentucky, United States of America
    Posts
    409
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Works well. . .I'm using it for my Chicken Obliterator script. . .Until I can figure out how to do it myself or something

  6. #6
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Looks real cool; gonna try it out
    Interested in C# and Electrical Engineering? This might interest you.

  7. #7
    Join Date
    Mar 2007
    Posts
    3,681
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    this looks cool needed this thanks!

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

    Default

    Thanks for the great comments

    Tara:

    Maybe you could help me with that one? I've tried getting the best color, but the Results in Tolerance are staying the same. I think it doesn't matter which color is first, or I'm doing something wrong here.

    I tried it like this:

    SCAR Code:
    ColorToleranceSpeed(Cts);
      SetArrayLength(ColCount, Length(Colors));
      for i := 0 to Length(Colors) -1 do
        for c := 0 to Length(Colors) -1 do
        if c <> i then
          ColCount[i] := ColCount[i] + SimC(Colors[i], Colors[c]);

      c := 0;
      for i := 0 to Length(Colors) -1 do
        if Min(ColCount[c], ColCount[i]) <> ColCount[c] then c := i;

      WriteLn('Best Color: '+IntToStr(Colors[c]));

    In the example above I got 1190948 as best color.
    But I'm getting the same results with Tolerance..
    Hup Holland Hup!

  9. #9
    Join Date
    Mar 2006
    Posts
    3,051
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    ColorToleranceSpeed(Cts);
      SetArrayLength(ColCount, Length(Colors));
      for i := 0 to Length(Colors) -1 do
        for c := 0 to Length(Colors) -1 do
          if SimC(Colors[i], Colors[c]) > ColCount[i] then
            ColCount[i] := SimC(Colors[i], Colors[c]);
     
      c := 0;
      for i := 0 to Length(Colors) -1 do
        if Min(ColCount[c], ColCount[i]) <> ColCount[c] then c := i;
     
      WriteLn('Best Color: '+IntToStr(Colors[c]));

    That should work. The way you had it before you added up the total tolerance difference between all the numbers, which is the same for every number in the series. (Like an extreme number might be 5, 10, 90 while a middle number might be 30,35,40, they add up to the same amount but one is much worse than the other) You only want to know the maximum tolerance for each color to each other color. Then you pick the color with the lowest value.

  10. #10
    Join Date
    May 2007
    Location
    NSW, Australia
    Posts
    2,823
    Mentioned
    3 Post(s)
    Quoted
    25 Post(s)

  11. #11
    Join Date
    Jun 2006
    Location
    Tennessee, USA
    Posts
    2,603
    Mentioned
    1 Post(s)
    Quoted
    46 Post(s)

    Default

    Wow very nice nielsie. It amazes me how you just came to these forums and started owning everyone

    BTW you remind me of Boreas, he always codes unique things like this.

  12. #12
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    He reminds me of Fawki. Can you believe Nielsie actually asked someone how to do something?!!
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  13. #13
    Join Date
    Feb 2006
    Location
    Helsinki, Finland
    Posts
    1,395
    Mentioned
    30 Post(s)
    Quoted
    107 Post(s)

    Default

    Quote Originally Posted by Mjordan View Post
    BTW you remind me of Boreas, he always codes unique things like this.
    Haha, same here.. He also reminds me of Ron/SKy Scripter/The_Rs_Monkey..

    That's a nice 'utility' you have there, Nielsie - definitely useful one! Thanks.

    By the way Nielsie, can you hear people yelling... "Make form! Make form! Make form!"? I can..

  14. #14
    Join Date
    Jun 2006
    Location
    Canada
    Posts
    1,610
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    oh thats cool.

    Nice work

    Accept that the waters around you have grown.

  15. #15
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Nice work! Just tested it. Perfect! Although I think the CountColor > 50 should be reduced to around 10 or so... and some people want to search in the main screen, not the minimap. So maybe you could make an option for that?

    Form pl0cks?

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

    Default

    Although I think the CountColor > 50 should be reduced to around 10 or so... and some people want to search in the main screen, not the minimap. So maybe you could make an option for that?
    It's easier to just edit the code after you paste it...

  17. #17
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Yeah, I know. But I didn't realize that it was searching the minimap for about ten minutes. I was getting pretty mad

  18. #18
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    nice BTW

    Lol Should Have really Made the RGB in order not the color XD

    SCAR Code:
    program New;

    procedure DeleteColorItem(var ColorData : TIntegerArray; Index : Integer);
    var
       i : integer;
    begin
     if (InRange(Index, 0, GetArrayLength(ColorData)-1)) then
     begin
        for i := index to GetArrayLength(ColorData)-2 do
           ColorData[i] := ColorData[i + 1];
        SetArrayLength(ColorData, GetArrayLength(ColorData)-1);
     end;
    end;

    procedure DeleteColorValue(var ColorData : TIntegerArray; Value : Integer);
    var
       i, Length : integer;
    begin
    Length := GetArrayLength(ColorData);
      for i := 0 to Length-1 do
      begin
          if (ColorData[i] = Value) then
          begin
             DeleteColorItem(ColorData, i);
             Exit;
          end;
      end;
    end;



    function OrganizeColors(DataColor : TIntegerArray) : TIntegerArray;
    var
      i : integer;
    begin
        for i := 0 to GetArrayLength(DataColor)-1 do
        begin
           SetArrayLength(Result, GetArrayLength(Result)+1);
           Result[GetArrayLength(Result)-1] := AMax(DataColor);
           DeleteColorValue(DataColor,  Result[GetArrayLength(Result)-1]);
        end;
    end;
                    // Finds The Middle 1, 2, 3*, 4, 5
    function AMid(Data: TIntegerArray) : Integer;
    var
       n : TIntegerArray;
    begin
      n := OrganizeColors(Data);
      Result := n[GetArrayLength(n)-1];
    end;

    function AMin(Data : TIntegerArray) : Integer;
    var
      Min, i : integer;
    begin
      if (GetArrayLength(Data) = 0) then Exit;
      Min := Data[0];
       for i := 0 to GetArrayLength(Data)-1 do
         if (Data[i] < Min) then
            Min := Data[i];
       Result := Min;
    end;



    var
       T : TIntegerArray;
       Min, Mid, Max : Integer;
       R, G, B : array [1..3] of Integer;
    begin

       SetArrayLength(T, 5);

       T[0] := 10;  // Colors
       T[1] := 20;
       T[2] := 30;
       T[3] := 40;
       T[4] := 50;

       Min := AMin(T);
       Mid := AMid(T);
       Max := AMax(T);

       ColortoRGB(Min, R[1], G[1], B[1]);
       ColortoRGB(Mid, R[2], G[2], B[2]);
       ColortoRGB(Max, R[3], G[3], B[3]);

       writeln('Min Color : R:' + Inttostr(R[1]) +  ' B:' + Inttostr(B[1]) + ' G:' + Inttostr(G[1]));
       writeln('Mid Color : R:' + Inttostr(R[2]) +  ' B:' + Inttostr(B[2]) + ' G:' + Inttostr(G[2]));
       writeln('Max Color : R:' + Inttostr(R[3]) +  ' B:' + Inttostr(B[3]) + ' G:' + Inttostr(G[3]));


      // Writeln('Middle Color = ' + IntToStr(GetMiddle(T)));


    end.

  19. #19
    Join Date
    Jun 2006
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Awesome tool, Nielsie! Ill be sure to use it Ill let you know how it works out.

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

    Default

    Thanks, updated it a bit to use the best color out the array (thanks Tara )!
    Next: Forms!
    Hup Holland Hup!

  21. #21
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    2,984
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    I took the liberty of changing your function a little ... you see, lets say there are 50 pixels with the to be autocolored color .. then it will check all those 50pixels while they are the same color ... so i added a little unique color function to it, see if you want to add it or not. (ps. i havent tested it, but i know the unique color thing works ...)

    SCAR Code:
    WriteLn(' ');
      WriteLn('function AutoColorIt: Integer;');
      WriteLn('var');
      WriteLn('  '+RangeNames[0]+', '+RangeNames[1]+', '+RangeNames[2]+': '+RangeNames[4]+';');
      WriteLn('  Points: TPointArray;');
      WriteLn('  Colors, UniqueColors: TIntegerArray;');
      WriteLn('  i, a: Integer;');
      WriteLn('  NewColor: Boolean;');
      WriteLn('begin');
      WriteLn('  if not LoggedIn then Exit;');
      WriteLn('  ColorToleranceSpeed('+IntTostr(CTS)+');');
      WriteLn('  FindColorsSpiralTolerance(MMCX, MMCY, Points, '+IntToStr(BColor)+', MMX1, MMY1, MMX2, MMY2, '+IntToStr(Tol[CTS][1] + 2)+');');
      WriteLn('  if Length(Points) < 1 then Exit;');
      WriteLn('  Colors := GetColors(Points);');
      WriteLn(' ');
      WriteLn('  for i := 0 to Length(Colors) -1 do');
      WriteLn('  begin');
      WriteLn('    NewColor := True;');
      WriteLn('    for a := 0 to GetArrayLength(UniqueColors) - 1 do');
      WriteLn('    begin');
      WriteLn('      if(UniqueColors[a] = Colors[i])then');
      WriteLn('       NewColor := False;');
      WriteLn('    end;');
      WriteLn('    if(NewColor)then');
      WriteLn('    begin');
      WriteLn('      SetArrayLength(UniqueColors, GetArrayLength(UniqueColors) + 1);');
      WriteLn('      UniqueColors[GetArrayLength(UniqueColors) - 1] := Colors[i];');
      WriteLn('    end;');
      WriteLn('  end;');
      WriteLn('  for i := 0 to Length(UniqueColors) -1 do');
      WriteLn('  if UniqueColors[i] <> 0 then ');
      WriteLn('  begin');
      WriteLn('    '+RangeNames[3]+'(UniqueColors[i], '+RangeNames[0]+', '+RangeNames[1]+', '+RangeNames[2]+');');
      WriteLn('    if ('+RangeNames[0]+ ' < ' + FloatToStr(Round(Ranges[0][1]) + 2) + ') and ('+RangeNames[0]+ ' > ' + FloatToStr(Round(Ranges[0][0]) - 2) + ') then ');
      WriteLn('      if ('+RangeNames[1]+ ' < ' + FloatToStr(Round(Ranges[1][1]) + 2) + ') and ('+RangeNames[1]+ ' > ' + FloatToStr(Round(Ranges[1][0]) - 2) + ') then ');
      WriteLn('        if ('+RangeNames[2]+ ' < ' + FloatToStr(Round(Ranges[2][1]) + 2) + ') and ('+RangeNames[2]+ ' > ' + FloatToStr(Round(Ranges[2][0]) - 2) + ') then ');
      WriteLn('          if CountColor(UniqueColors[i], MMX1, MMY1, MMX2, MMY2) > 50 then ');
      WriteLn('          begin');
      WriteLn('            WriteLn(''AutColor: ''+IntTostr(UniqueColors[i]))');
      WriteLn('            Result := UniqueColors[i];');
      WriteLn('            Break;');
      WriteLn('          end;');
      WriteLn('  end; ');
      WriteLn(' ');
      WriteLn('  ColorToleranceSpeed(1);');
      WriteLn('end;');
    Administrator's Warning:


  22. #22
    Join Date
    Mar 2006
    Posts
    3,051
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    It would also be helpful to know what the maximum tolerance is for the best color.

    So after the Best Color line you should add this...

    Writeln('Max Tol = '+IntToStr(ColCount[c]));
    Then if you want to use that color as a point in a DTM or something, you just use that color and that tolerance + 5 or 10 and it should find the color pretty much every time. The more points you have in the array, the more accurate your color range should be, and the less you need to add to the tolerance. So, if you only have 5 data points you might want to add 15. If you have 60 data points maybe only add 3 or 5.

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

    Default

    Thanks!

    Updated it a little again. Now uses the updated AutoColorTemplate from Sumilion!

    @Tara: It already showed the max tolerance, I made it a bit more clear now
    Hup Holland Hup!

  24. #24
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    2,984
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    No problem

    Too bad ACA didnt do the trick for me ... my color is too complicated
    Administrator's Warning:


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

    Default

    It's more supposed to give you hints on colors, tolerance, tolerancespeed etc..
    The AutoColorFunction is a nice addition, but is too global too really autocolor

    btw: Mind telling me what those colors are?
    Hup Holland Hup!

Page 1 of 4 123 ... LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [ACA]AutoColorAid v2 - by Nielsie95 and Sumilion
    By Sumilion in forum Unofficial Development
    Replies: 168
    Last Post: 01-19-2018, 12:41 AM

Posting Permissions

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