SRL Archive - OSR Help

Someone Teach Me How To Do Density Checks?


YoHoJo

2010-03-20 14:45:22

Someone Teach Me How To Do Density Checks?

I want to learn the technique and use it so I can distinguish between ore in rocks vs ore on ground.

<3 Thank Youuuu!

Markus

2010-03-20 14:49:49

gettpabounds(tpa);

length(tpa) / (x2-x1)*(y2-y1)

How about that?

Naum

2010-03-20 14:51:35

From: Markus
gettpabounds(tpa);

length(tpa) / (x2-x1)*(y2-y1)

How about that?


Yeah, zeph used it in the old autocolor:

        TB := GetTPABounds(CPts);
Count := Length(CPts);
try
ColourDensity := Length(CPts) / ((TB.x2 - TB.x1) * (TB.y2 - TB.y1) * 1.0);
except end;
if (Count > 350) and (ColourDensity > 0.08) then
Break;

Markus is right! As always :)

YoHoJo

2010-03-20 14:51:37

How would I know what to make the x1 x2 y2 y1.
How would I find density of a rock, and then ore?
Thanks.

Naum

2010-03-20 15:01:46

From: YoHoJo
How would I know what to make the x1 x2 y2 y1.
How would I find density of a rock, and then ore?
Thanks.


1.

FindColors(TPA, rockcolor, ...);
ATPA := SplitTPA(TPA, 5);
For I := 0 To High(ATPA) Do
Begin
TB := GetTPABounds(ATPA[I]);
Density := (Length(ATPA[I]) / ((TB.x2 - TB.x1) * (TB.y2 - TB.y1) * 1.0));
If Not InRange(Density, RockDensityMin, RockDensityMax) Then
Exit;
End;


2. Answered in first question, you need to loop it. Come on MSN and I can help you better.

EDIT: I'm a :ninja:

Heysus

2010-03-20 15:02:44

I've never even heard of density before but here is what I would do…


FindColorsTolerance(TPA, color, MSX1, MSY1, MSX2, MSY2, tol);
TPAToATPA(TPA, 25);
for i:=0 to High(ATPA) do
begin
B := GetTPABounds(ATPA[i]);
D := GetArrayLength(ATPA[i]) / (B.x2 - B.x1)*(B.y2 - B.y1);
// other stuff...mabye record the point with the best density??
end;

Killerdou

2010-03-20 18:41:58

http://villavu.com/forum/showthread.php?t=13764 <— you guys are 2.5 years late(obviously the suggested methods above are better… they weren't there yet, but you can see how you can use it in object finding :D)

Oh, and I think using a convex hull rather then a square around your points would be way more usefull :D