Jump to content
troller

tolerance range?

Recommended Posts

Color similarity is "a bit" more advanced than that, I can go through the default method in SCAR (known as CTS1) for you.

- This is what's by default used in find color and find bitmap methods.

 

The value you have there is a (numeric) representation of a RGB color.

var
 R,G,B:Integer;
begin
 ColorToRGB(100000, R,G,B);  
 WriteLn(TIAToStr([R,G,B]));
end.      

So your example value of 100000 = R: 160, G: 134, B: 1

 

From the beginning now knowing that:

SCAR convert the representation of the color to R, G and B values by doing some bitshifting (separating the 3 first bytes from the 4 byte long number), as so:

procedure ColorToRGB(Color:Integer; out R,G,B:Integer);
begin
 R := color and $FF;
 G := color shr 8 and $FF;
 B := color shr 16 and $FF;
end;

 

Then it compares the color using a function which computes the euclidean distance between the two colors:

RGB_Diff.png

function ColorSimilarity(Color1, Color2:Integer): Extended;
var 
 R1,B1,G1, R2,G2,B2: Integer;
begin
 ColorToRGB(Color1, R1,G1,B1);
 ColorToRGB(Color2, R2,G2,B2); 
 Result := Sqrt( Sqr(R1-R2) + Sqr(G1-G2) + Sqr(B1-B2) );
end;

 

That means the max tolerance used between two colors when using CTS1 (the formula shown above) is 442 (441,673)

 

 

`Tolerance` measured this way yields an "exponential-ish growth" in the number of similar colors (up to values):

1 tolerance: ~7 colors
2 tolerance: ~33 colors
3 tolerance: ~123 colors
4 tolerance: ~257 colors
...
8 tolerance: ~2109 colors
...
16 tolerance: ~17077 colors

Side note: The number of colors in RGB-color space is (256^3) = 16777216 (0 to 16777215)

 

--------------------

 

Based on your example color of 100000, using that with this formula and 1 tolerance that would give you the following values:

`(99999, 99744, 34464, 100000, 165536, 100256, 100001)`

 

Which is equal to the RGB colors:

--------(159,134,1) (160,133,1)

(160,134,0) (160,134,1) (160,134,2)

--------(160,135,1) (161,134,1)

 

--------------------------------------------------

 

Read: http://wiki.scar-divi.com/Tolerance

I hope this helps, tho if you have any more questions, just ask! :-)

Edited by slacky
Link to comment
Share on other sites

wow, that explains a lot of things.

i have another question too, not the same as above, but related to colors.

is there something in scar 3.22 that can change the search pattern of colors/bitmaps?

i want to find a color(pixel2) around a colored pixel(pixel1). there are many moving pixels(pixel2) there and i want to click the closest one(pixel2). is this possible?

Link to comment
Share on other sites

wow, that explains a lot of things.

i have another question too, not the same as above, but related to colors.

is there something in scar 3.22 that can change the search pattern of colors/bitmaps?

i want to find a color(pixel2) around a colored pixel(pixel1). there are many moving pixels(pixel2) there and i want to click the closest one(pixel2). is this possible?

I don't use, nor do I have experience with older scar-versions.

 

There is generally no support to get here for prehistoric SCAR-versions. Update you SCAR to the latest and people here can actually help.. rather then using a version of SCAR which belongs in a museum.

Edited by slacky
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...