Доброго денечка, уважаемые, сразу оговорюсь, что в Питоне я не силен, так что прощу вашей помощи в переводе на паскаль данного скриптика:
Код:
1 2 3 4 | def get_skin_ratio(im):
im = im.crop((int(im.size[0]*0.2), int(im.size[1]*0.2), im.size[0]-int(im.size[0]*0.2), im.size[1]-int(im.size[1]*0.2)))
skin = sum([count for count, rgb in im.getcolors(im.size[0]*im.size[1]) if rgb[0]>60 and rgb[1]<(rgb[0]*0.85) and rgb[2]<(rgb[0]*0.7) and rgb[1]>(rgb[0]*0.4) and rgb[2]>(rgb[0]*0.2)])
return float(skin)/float(im.size[0]*im.size[1])
|
Думаю, что должно выглядеть как то так:
Код:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | procedure TForm1.Button24Click(Sender: TObject);
type
PCardArray = ^TCardArray;
TCardArray = array [0 .. 8191] of Cardinal;
var
x, y: Cardinal;
Line: PCardArray;
R, G, B: Byte;
begin
Nude := 0;
with Image1.Picture.BitMap do
begin
PixelFormat := pf32bit;
for y := 0 to Height - 1 do
begin
Line := ScanLine[y];
for x := 0 to Width - 1 do
begin
R := GetRValue(Line[x]);
G := GetGValue(Line[x]);
B := GetBValue(Line[x]);
if (R > 60) and (G < (R * 0.85)) and (B < (R * 0.7)) and (G > (R * 0.4)) and (B > (R * 0.2)) then Line[x] := $FFFFFF;
end;
end;
end;
end;
|