New to image processing, in FMX I'm trying to convert from color to mono. I can't seem to get the code below to work. Am I doing something obviously wrong?

New to image processing, in FMX I'm trying to convert from color to mono. I can't seem to get the code below to work. Am I doing something obviously wrong?

procedure ConvertAlphaColorToMono( var aColor: TAlphaColor);
var
Mono: Cardinal;
begin
Mono := Min(255,Trunc( (TAlphaColorRec(aColor).R * 0.21) +
(TAlphaColorRec(aColor).G * 0.72) +
(TAlphaColorRec(aColor).B * 0.07)));
TAlphaColorRec(aColor).R := Mono;
TAlphaColorRec(aColor).G := Mono;
TAlphaColorRec(aColor).B := Mono;
end;

Note there are other numeric factors than the ones I'm using above. Good quick discussion here: https://www.johndcook.com/blog/2009/08/24/algorithms-convert-color-grayscale/

Comments

  1. It seems you don't scale the resulting value to span the 0..255 range.

    ReplyDelete
  2. For completeness, below is the now working version of the code in my original post:

    https://plus.google.com/photos/...

    ReplyDelete

Post a Comment