troller Posted September 4, 2014 Share Posted September 4, 2014 hey guys. i have a question. how exactly tolerance works? for example i have color 100000 and the tolerance is set to 1. will it search for color 99999, 100000 and 100001 or what? same question for bitmaps Quote Link to comment Share on other sites More sharing options...
slacky Posted September 7, 2014 Share Posted September 7, 2014 (edited) 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: 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 September 10, 2014 by slacky Quote Link to comment Share on other sites More sharing options...
troller Posted September 9, 2014 Author Share Posted September 9, 2014 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? Quote Link to comment Share on other sites More sharing options...
slacky Posted September 10, 2014 Share Posted September 10, 2014 (edited) 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 September 10, 2014 by slacky Quote Link to comment Share on other sites More sharing options...