My original idea didn't work too well, but I came up with this:
SCAR Code:
procedure FixCaptcha(BMP: Integer);
var
x, y, W, H: Integer;
Hue, S, L: Extended;
begin
GetBitmapSize(BMP, W, H);
for y:= 0 to H - 1 do
begin
for x:= 0 to W - 1 do
begin
ColortoHSL(FastGetPixel(BMP, x, y), Hue, S, L); //convert the current pixel to HSL
if(L < 60)then //if the luminance of that pixel is less than 60, then...
FastSetPixel(BMP, x, y, 0) //make it black
else //otherwise..
FastSetPixel(BMP, x, y, clWhite); //make it white
end;
end;
end;
It's very simple, but it works pretty well to retrieve just the letters. It's definitely not perfect, so play around with the "L < 60" and maybe add saturation checking too to get it just how you want it.