0

i have a question, is there some library, or piece of code that can detect if color is most similar to greeen, blue, yellow or so?

i can decompose the pixel color of TImage with this function:

procedure RGB(Col: TColor; var R, G, B: Byte);
var
  Color: $0..$FFFFFFFF;
begin
  Color := ColorToRGB(Col);
  R := ($000000FF and Color);
  G := ($0000FF00 and Color) Shr 8;
  B := ($00FF0000 and Color) Shr 16;
end;

but with simply comparation of r>g>b i cannot determine, if the color is more similar to yellow, brown or so. I need only few basic colors (working on little kids education stuff)

I will be very thankfull for every hint, or help.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Fero
  • 35
  • 1
  • 1
  • 8
  • The definition of 'similar' is a bit tricky. You could do something that finds the difference for each of red, green and blue and chooses the lowest difference. Here is a suggestion for javascript, which you could adapt: https://stackoverflow.com/questions/1725505/finding-similar-colors-programatically – E Rullmann Jun 23 '17 at 20:57
  • I tried to define "collor difference" ranges, but without success.. i just need to detrmine basic colors (red green blue yellow black white brown) for kids in the kindergarden - they will touch the screen and the app will tell the color via speakers.. – Fero Jun 23 '17 at 21:03

0 Answers0