bg5
2012-05-03 14:03:25
(* Returns all points from TPA1 ,which are in given distance from any point of TPA2*)
procedure FilterTPADistTPA(var TPA1: TPointArray; const MinDist,
MaxDist: Extended; TPA2 : TPointArray);I call this method color plaiting ,because it can filter one object ,which contains two or more different colors, from bunch of similar colored pixels. It's very simple ,but efficient. I wish this function to be added into Simba's core ,of course main reason is speed. :stirthepot:
Example:
You want to find upper-right object
FindColorstolerance(TPA1,2366701,1,1,w-1,h-1,0); //red
FindColorstolerance(TPA2,969215,1,1,w-1,h-1,0); // orange
FilterTPADistTPA(TPA1,0,3,TPA2);
DrawTPABitmap(bmp,TPA1,clwhite);procedure FilterTPADistTPA(var TPA1: TPointArray; const MinDist,
MaxDist: Extended; TPA2 : TPointArray);
var
c,i,j,h,hh : integer;
d : extended;
mind ,maxd :extended;
begin
h := high(TPA1);
hh := high(TPA2);
c := 0;
mind := sqr(MinDist);
maxd := sqr(MaxDist);
for i := 0 to h do
begin
for j := 0 to hh do
begin
d := sqr(TPA1[i].x - TPA2[j].x) + sqr(TPA1[i].y - TPA2[j].y);
if (d >= mind) and (d <= maxd) then
begin
TPA1[c] := TPA1[i];
inc(c);
break;
end;
end;
end;
setlength(TPA1,c);
end; Example of ingame use - Lumbridge ducks:
I will combine colors of duck's head and duck's rump. As you see both colors are very popular in this place ( I use CTS 0).
But when I join them together…
FindColorsTolerance(TPA1,3559229,MSX1,MSY1,MSX2,MSY2,14);
FindColorsTolerance(TPA2,8556950,MSX1,MSY1,MSX2,MSY2,20);
FilterTPADistTPA(TPA1,0,20,TPA2);
SplitTPAWrap(TPA1,30,ATPA);
SMART_ClearCanvas;
for a:= 0 to high(ATPA) do
SMART_DrawCircle(FALSE,MiddleTPA(ATPA[a]),20,FALSE,clred);…I have 100% accuracy :)–beginner5
This thread is outdated,because I've made plugin with those functions which is 1001x faster : http://villavu.com/forum/showthread.php?t=83795
