SCAR Code:
program New;
var
b: TBitmap;
w, h, i: Integer;
p: TPointArray;
Procedure RemoveTPointFromArray(Index:Integer; Var Arr:TPointArray);
begin
tSwap(Arr[Index], Arr[High(Arr)]);
SetArrayLength(Arr, High(Arr));
end;
Procedure FilterPoints(var p:TPointArray; Color, II, III:Integer);
var
I, x, y, c:Integer;
//TPA:TPointArray;
begin
//TPA:=P;
For I:=0 to high(P)do
begin
C:=0;
for x:= 0 to II do
for y:= 0 to II do
if getcolor(p[i].x-x, p[i].y-y) <> Color then
Inc(C);
If C > III then
RemoveTPointFromArray(I, {TPA}P);
end;
//P:=TPA;
end;
begin
b := LoadBitmap('C:\tmp.jpeg');
GetBitmapSize(b, w, h);
SetTargetBitmap(b);
FindColorsTolerance(p, clwhite, 0, 0, w, h, 0);
for i := 0 to High(p) do
FastSetPixel(b, p[i].x, p[i].y, clblack);
FindColorsTolerance(p, clwhite, 0, 0, w, h, 441);
for i := 0 to High(p) do
FastSetPixel(b, p[i].x, p[i].y, Clwhite);
FindColorsTolerance(p, clwhite, 0, 0, w, h, 441);
FilterPoints(P, 0, 1, 3);
for i := 0 to High(p) do
FastSetPixel(b, p[i].x, p[i].y, clBlack);
DisplayDebugImgWindow(w, h);
SafeDrawBitmap(b, GetDebugCanvas, 0, 0);
FreeBitmap(b);
end.