Jump to content
LordJashin

GetSimilarColors(Color, Tol: Integer): TIntArray; Combs through 16 million colors

Recommended Posts

[scar]

function GetSimilarColors(Color, Tol: Integer): TIntArray;

var

i: Integer;

begin

for i := 0 to 16777215 do

if SimilarColors(Color, i, Tol) then

begin

SetLength(Result, Length(Result) + 1);

Result[Length(Result) - 1] := i;

end;

end;

[/scar]

 

Interesting to see how many colors there is within that Tolerance out of the 16 million.

 

Running: GetSimilarColors(ClRed, 15);

 

The Amount of colors found in each CTS for Running:

 

Original Color (ClRed):

 

wzkKQmx.png

 

CTS0: 4096

 

VgBcZmf.png

 

CTS1: 2046

 

hm3GtXt.png

 

CTS2: 22457

 

uzJuS6R.png

 

CTS3: 163937

 

tOM36EU.png

 

Still working out the pictures. Some weird things happen.

 

At 100 Tolerance...some pink shows up

 

G2YHipa.png

 

And here's a TON of colors debugged Pretty much the entire 16 million. If you use your color picker on it, gets some crazyness.

 

ug39bzv.jpg

 

Switched:

 

ZhEjSI7.png

Edited by LordJashin
Link to comment
Share on other sites

I added pictures. Lol looks like there's a bit of orange in the CTS(2) one.

 

Edit: Weird there must be some sort of error in my code for the bitmaps...get weird things at high tols.

if you are refering to the following sentence:

...And here's a TON of colors debugged Pretty much the entire 16 million. If you use your color picker on it, gets some crazyness.

That might be cause you scale in bitshisted RGB/RGBInt. It could would give a clean(er) result (for RGB) if you do a 3x loops (nested), and use RGB, and convert it to RGBInt, never tested.

 

EG (result might be wierd as well):

base := 0;
for A to 255 do begin
 for B to 255 do begin
   for C to 255 do begin
     color := RGBtoColor(R,G,B);
     if SimilarColors(base, color, tol) then
     begin
       SetLength(Result, Length(Result) + 1);
       Result[High(Result)] := i;
     end; 
   end;
 end;
end;

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...