SRL Archive - OSR Help

Color tolerance


xdarkshadowx

2012-12-28 12:11:51

how do I tell if a color is in the red spectrum from it's number? (using getcolor function). I'm trying to make a function that returns if there is any red in a certain location, but I don't know how to search the location (a square about 20 by 20 pixels) and then figure out if it's red or not.

Brandon

2012-12-28 12:17:32


Function IsNearRed(Colour, Tolerance: Integer): Boolean;
begin
Result := SimilarColors(255, Colour, Tolerance);
end;

Function FindRed(Area: TBox): Boolean;
var
Points: TPointArray;
Begin
Result := FindColorsTolerance(Points, 255, Area.X1, Area.Y1, Area.X2, Area.Y2, Tolerance);
End;

xdarkshadowx

2012-12-28 12:23:59

oh, findcolorstolerance is a boolean, that'll work splendidly, but I forget how tolerance is exactly, like how much do you need, and how much is too much. it's a color scale of 0 to 256 right?

Brandon

2012-12-28 12:35:45

From: xdarkshadowx
oh, findcolorstolerance is a boolean, that'll work splendidly, but I forget how tolerance is exactly, like how much do you need, and how much is too much. it's a color scale of 0 to 256 right?



Well it doesn't matter. The colour scale can be from 0 to 16777215.

Aka Black to White. 255 just happens to be true red. I use the 0 to 255 colour scale because I program in OpenGL and DirectX too much.

Think of it like this:

RGB(255, 0, 0); That's Red. The Green and Blue channels are 0.

You can try: writeln(RGBToColor(255, 0, 0)); and see for yourself. It should be the exact same (prints 255).

xdarkshadowx

2012-12-28 12:47:05

So a tolerance of like ten would give me most reds? or do I need higher/lower?

King

2012-12-28 12:55:12

From: xdarkshadowx
So a tolerance of like ten would give me most reds? or do I need higher/lower?


Why not just use ACA to find the color, it will find the tolerance and color ect for you. Then you can use those values in FindColorSpiral, or in a function like this
If FindColortolerance(Color Info, box info) then
begin
Result:= True;
Writeln('We found the color');
end else
begin
Result:= False;
Writeln('We did not find the color');
end;

masterBB

2012-12-28 13:02:23

not finished but covers all RGB stuff already:

http://villavu.com/forum/showthread.php?t=89308

e:
I also wrote another tut, you can find it in my sig.