Results 1 to 4 of 4

Thread: Help Finding Two Colors Near Each Other

  1. #1
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default Help Finding Two Colors Near Each Other

    Let's say I have a tree, green on top, brown on bottom, and there is NO OVERLAP of the colors, one ends, the other begins.
    Or another example, a reg blob on top of a green blob, they do not overlap at all.

    How would I go about finding this object in general, or the section at which the two colors meet.

    Ex:


    I just want to find the object in general, or where the blue rectangle is.


    ACTUAL code along with comments is greatly appreciated!


    Guess?
    Make a TPA of both, then ATPA of both, then compare distances between ATPAColor1 and ATPAColor2?
    Last edited by YoHoJo; 03-22-2013 at 11:27 AM.

  2. #2
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    Simba Code:
    procedure FindObject;
    var
      TPA1, TPA2, TPA3: TPointArray;
      i, L: Integer;

    begin
      //NearbyPointInArray(Point, Dist, TPA);
      for i:=0 to high(TPA1) do
        if NearbyPointInArray(TPA1[i], 10, TPA2) then
        begin
          L := Length(TPA3);
          SetLength(TPA3, L+1);
          TPA3[L] := TPA1[i];
        end;

    end;

    TPA1: Red color of your drawing found by using FindColorsTolerance blablabla
    TPA2: Green color found the same way

    TPA3 is the area where they overlap at any points. You can then split TPA3 to find the largest match.
    So all in all something like this

    Code:
    procedure FindObject;
    var
      TPA1, TPA2, TPA3: TPointArray;
      i, L: Integer;
      ATPA: T2DPointArray;
      P: TPoint;
    
    begin
      //NearbyPointInArray(Point, Dist, TPA);
      for i:=0 to high(TPA1) do
        if NearbyPointInArray(TPA1[i], 10, TPA2) then
        begin
          L := Length(TPA3);
          SetLength(TPA3, L+1);
          TPA3[L] := TPA1[i];
        end;
    
      if L > 0 then
      begin
        SplitTPAWrap(TPA3, 5, ATPA);
        SortATPASize(ATPA, True);
        P := MiddleTPA(ATPA[0]);
      end;
    
    end;

    Script source code available here: Github

  3. #3
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Ahh I sort of see what you are doing there, very neat!
    It takes me a few reads/sample scripts/debug screens to understand ATPAs sometimes, but I can see what is going on here!
    I'll give that some sample runs tomorrow and report back with results!

    Everyone else feel free to add onto/tweak what JJ said or post your own ideas too!

    @JJ brilliant! Working perfectly!
    Last edited by YoHoJo; 03-22-2013 at 12:09 PM.

  4. #4
    Join Date
    Jul 2011
    Location
    /home/litoris
    Posts
    2,226
    Mentioned
    0 Post(s)
    Quoted
    159 Post(s)

    Default

    Simba Code:
    function AND_TPA (tpa1 , tpa2 :TpointArray ; MinDist ,MaxDist : extended) : TPointArray;
    var
      a : integer;                    
      temp_tpa1 :TPointarray;        
    begin
     Setlength(Result,0);
     for a:=0 to High(tpa2) do
     begin
       temp_tpa1 := tpa1;

       FilterPointsDist(temp_tpa1,MinDist,MaxDist,tpa2[a].x,tpa2[a].y);

       CombineTPAWrap(Result,temp_tpa1,Result);
     end;
    ClearDoubleTPA(Result);
    end;
    I just copied this off from my miner, This is a version of something beginner5 posted a while ago in the snippets section.
    I use this on mining rocks, trees etc. and it works well when there are similar colored objects around. Picking colors is a pain in the ass tough.
    Miner & Urn Crafter & 07 Chicken Killer
    SPS BlindWalk Tutorial

    Working on: Nothing

    teacher in every art, brought the fire that hath proved to mortals a means to mighty ends

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
  •