hola,
Código Delphi
[-]
function TForm1.Lluminositat(c : TColor): integer;
var
r,g,b : integer;
act : integer;
begin
r := Red(c);
g := Green(c);
b := Blue(c);
act := r+g+b;
Lluminositat := act div 3;
end;
function TForm1.Red(c : TColor) : integer;
begin
Red := c and $FF;
end;
function TForm1.Green(c : TColor) : integer;
begin
Green := (c and $FF00) div $100;
end;
function TForm1.Blue(c : TColor) : integer;
begin
Blue := (c and $FF0000) div $10000;
end;
si haces algo como
Código Delphi
[-]
procedure filtro_de_contraste(cn : TCanvas);
var
i,j : integer;
begin
for i := 0 to cn.Width do
for j := 0 to cn.Height do
begin
if Lluminositat(cn.Pixels[i,j]) > 128 then cn.Pixels[i,j] := clWhite
else cn.Pixels[i,j] := clBlack;
end;
end;
tendras un filtro de contraste bastante aproximado. Solo hara falta aplicarlo antes. Si lo que quieres son deducir la direccion de degradado del color, puedes hacerlo tambien buscando el punto de maximo brillo (mediante lluminositat), restar con la luminosidad de los adyacentes, y aquel donde la diferencia (el gradiente) sea maximo, es el mas proximo al borde, aunque no creo que lo necesites.