MatchColor accepts *any* Color as a parameter and returns an index into the Palette array that points to the closest color to the one passed into the function. (Note: the Palette array is a global constant and visible to MatchColor)
So, in theory, it could be used like this:
NewColor := Palette[MatchColor(OldColor)];
How would such a function be implemented with ImageEn?
3 L A T E S T R E P L I E S (Newest First)
fab
Posted - Oct 19 2012 : 00:15:52 Look at this:
var
palette: array [0..2] of TRGB = ((b: 0; g: 0; r: 0), (b: 12; g: 20; r: 30), (b: 40; g: 60; r: 70));
procedure TForm1.Button22Click(Sender: TObject);
var
RGBToFind: TRGB;
idx: integer;
begin
RGBtoFind := CreateRGB(28, 18, 10); // should match index 1 (b:12, g:20, r:30)
idx := _GetSimilColor(palette, length(palette), RGBtoFind);
ShowMessage(IntToStr(idx));
end;
Rocky
Posted - Oct 18 2012 : 15:18:57 Thanks man. Sorry but as I am relatively novice in imageen could you please give me an example of GetSimilColor?
fab
Posted - Oct 17 2012 : 11:00:43 ImageEn has the undocumented function _GetSimilColor (in imageenproc unit), which takes an array of TRGB (instead of TColor) values and, making a simple comparison, returns the index of the closest color. Anyway you may require to compare colors in a different way (for example comparing color tonality, saturation, luminosity or a combination of them): for this task RGB2HSV could be useful.