SRL Archive - OSR Help

Density


bbri06

2010-05-23 20:46:24

So I have a function that is supposed to check density of colors and the problem is I get results such as

0.0000000000000000E+0000

I don't really have the slightest clue what that means or what to do with it. Is E supposed to be Euler's number?


Function CheckDensity(TPA: TPointArray; Min, Max: Extended): boolean;
var
PB, Bounds: TBox;
RTPA: TPointArray;
Density : Extended;
begin
DebugTPA(TPA, '');
PB := GetTPABounds(TPA);
FindColorsTolerance(RTPA, URockAC, PB.x1 - 5, PB.y1 - 5, PB.x2 + 5, PB.y2 + 5, 20);
if(Length(RTPA) > 0)then
begin
Bounds := GetTPABounds(RTPA);
Density := (Length(TPA))/((Bounds.x2 - Bounds.x1) * (Bounds.y2 - Bounds.y1));
Writeln(Density);
if(Density > Min)and(Density < Max)then
Result := True
else
Result := False;
end;
end;

i luffs yeww

2010-05-23 20:59:19

I brought this up. >_< They said it was fine.

Use FloatToStr rather than ToStr.

3Garrett3

2010-05-23 23:02:57

From: bbri06
So I have a function that is supposed to check density of colors and the problem is I get results such as

0.0000000000000000E+0000

I don't really have the slightest clue what that means or what to do with it. Is E supposed to be Euler's number?


If math class serves me right, the E means *10^0000

Which means that the density of that number is 0. So its the result of no density. I didn't look through the code because luffs already said what should solve it, so I thought I'd just clarify that part.

bbri06

2010-05-23 23:28:30

Ah, alright. Thanks to both of you. No idea how it could possibly be 0 after seeing the debug images, but I figured out another way to do it anyways.

i luffs yeww

2010-05-24 19:57:46

^ How'd you do it instead of FloatToStr?

bbri06

2010-05-24 20:03:48

No, I meant I just didn't use a density check since it wasn't really doing anything for me. I just checked pixels around the color instead.