PDA

View Full Version : AND_TPA and color layers + examples!



bg5
06-03-2012, 04:15 AM
procedure FilterTPADistTPA(var TPA1: TPointArray; const MinDist,MaxDist: Extended;var filterTPA : TPointArray);
procedure FilterTPADistTPAEx(var TPA1: TPointArray; const MaxX,MaxY: integer;var filterTPA : TPointArray);
procedure FilterTPADistTPACmpr(var TPA1: TPointArray; const MinDist,MaxDist: Extended;var filterTPA : TPointArray;CmprTPA1 ,CmprFilter : integer);
procedure FilterTPADistTPAExCmpr(var TPA1: TPointArray; const MaxX,MaxY: integer;var filterTPA : TPointArray;CmprTPA1 ,CmprFilter : integer);

AND_TPA returns all points from TPA1 ,which has in neighbourhood any point from filterTPA. FilterTPADistTPA() uses circle (ring) as neighbourhood , FilterTPADistTPAEx uses rectangle ( w = 2*MaxX ; h = 2*MaxY).

Both functions have version with compression. Compression shorten length of base or filter TPA ,reducing time of operation. It's very usefull when working with big tpas ,but I don't recomend it for precise searching. Compression level = 0 means no compression.

On pictures red color is the match.

Example #1

Finding Burthorpe chest

2 layers

Chest has 2 colors: color of wood (green and red debug color) and it's silver ferrule ( white debug color). But, as you see on the picture, that 2 colors matches also to other objects on screen: silver elements are on NPCs' armors and pillars, and 'wood' color matches palisade and top of a barrel.
So to localise our chest we need to find a place where both colors are close to each other. Therefore we tell this plugin to:


Find the place where wood is surrounded by silver

or more technically:


Find all points from green TPA (wood), which are in proper distance from any white(silver) pixel

and red debug color is a result.

ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.18,0.55);
FindColorsTolerance(TPA2,9737627,msx1,msy1,msx2,ms y2,18); //silver

SetColorspeed2Modifiers(0.06,0.38);
FindColorsTolerance(TPA1,5202030,msx1,msy1,msx2,ms y2,10); //wood

SMART_DRAWDOTSEx(FALSE,TPA1,clgreen);
SMART_DRAWDOTSEx(FALSE,TPA2,clwhite);
FilterTPADistTPA(TPA1,0,20,TPA2);
SMART_DRAWDOTSEx(FALSE,TPA1,clred); // result

http://puu.sh/yjde


Example #2

Finding trapdoor to Rogues' Den
3 layers
http://puu.sh/yjtL
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.02,0.37);
FindColorsTolerance(TPA1,4213331,msx1,msy1,msx2,ms y2,1); //brown1
SetColorspeed2Modifiers(0.3,1.02);
FindColorsTolerance(TPA2,3028800,msx1,msy1,msx2,ms y2,4); //brown2
SetColorspeed2Modifiers(0.15,0.17);
FindColorsTolerance(TPA3,9474457,msx1,msy1,msx2,ms y2,13); //silver handle
SMART_DRAWDOTSEx(FALSE,TPA1,clgreen);
SMART_DRAWDOTSEx(FALSE,TPA2,clwhite);
SMART_DRAWDOTSEx(FALSE,TPA3,clblue);
FilterTPADistTPA(TPA1,0,5,TPA2);
FilterTPADistTPAEx(TPA1,5,10,TPA3);
SMART_DRAWDOTSEx(FALSE,TPA1,clred);
SMART_DrawEllipse(FALSE,point(MSCX,MSCY),20,25,TRU E,1);



Example #3

Finding ivy on wall (varock north)

2 layers + compression

http://puu.sh/yiu5

As you see layers are very big ,that's why I compress filterTPA (white wall). Compression visibly decrease time of operation without difference in result (if proper used).

ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.56,0.59);
FindColorsTolerance(TPA1,3632741,msx1,msy1,msx2,ms y2,11); //green

SetColorspeed2Modifiers(0.28,0.05);
FindColorsTolerance(TPA2,6843501,msx1,msy1,msx2,ms y2,12); // wall

SMART_DRAWDOTSEx(FALSE,TPA1,clgreen);
SMART_DRAWDOTSEx(FALSE,TPA2,clwhite);
FilterTPADistTPAExCmpr(TPA1,10,4,TPA2,0,5);
SMART_DRAWDOTSEx(FALSE,TPA1,clred);

{ // addiotional code for example #4
SMART_Clearcanvas;
FindTPAOutLine(TPA1);
SMART_DRAWDOTSEx(FALSE,TPA1,clyellow); }

Example #4

Using AND_TPA to find outlines of TPA

http://puu.sh/yj6r

function FindTPAOutline (var TPA : TPointArray) : TPointArray;
var
tempTPA : TPointarray;
tempBox : tBox;
begin
tempBox := GetTPABounds(TPA);
TPAFromBoxWrap(tempBox,tempTPA);
ClearTPAFromTPAWrap(tempTPA,TPA,tempTPA);
FilterTPADistTPAEx(TPA,1,1,tempTPA);
end;

S: (http://pastebin.com/pUwvhFyJ)

Brandon
06-03-2012, 04:20 AM
For me, I admire the FindTPAOutline.. Not to picky about the rest but uhh for the TPADistTPA if you created it, do you know if it does AND-ing like this; +Rep+:

http://j1662736.gblearn.com/comp1229/assignments/assignment1/Images/BooleanAlgebra.PNG



If it does I might have uses for it.

Main
06-03-2012, 04:24 AM
hurray!! rep +

Runaway
06-03-2012, 04:33 AM
Awesome! FindTPAOutline is a quite nifty... might have some cool uses for that.

@Brandon, afaik FilterTPADistTPA uses NearbyPointInArray logic; it compares all of the points in TPA1 to the points in TPA2 and it only results the points in TPA1 that are within the max distance of TPA2.

bg5
06-03-2012, 04:39 AM
For me, I admire the FindTPAOutline.. Not to picky about the rest but uhh for the TPADistTPA if you created it, do you know if it does AND-ing like this:

http://j1662736.gblearn.com/comp1229/assignments/assignment1/Images/BooleanAlgebra.PNG

If it does I might have uses for it.

Yes and No ,basically what you drawn there are 2 TPAs with common points. My function search not for common points ,but for points in neighbourhood ,but I think you had that on mind.

You can create all logic statements I think:

AND: AND_TPA(tpa1,tpa2)
OR: CombineTPA(tpa1,tpa2)
XOR: tpa3 := CombineTPA(tpa1,tpa2);
AND_TPA(tpa1,tpa2);
result := ClearTPAFromTPA(tpa3,tpa1);