function TImageFunc.binaryzation2(souBMP:TBitmap):TBitmap;
var
p:PByteArray;
Gray,x,y:Integer;
Bmp:TBitmap;
begin
try
Bmp:=TBitmap.Create;
Bmp.Assign(souBMP);
Bmp.PixelFormat:=pf24Bit;
randomize;
for y:=0 to Bmp.Height-1 do
begin
Bmp.Canvas.Lock;
p:=Bmp.ScanLine[y];
for x:=0 to Bmp.Width-1 do
begin
Gray:=Round(p[x*3+2]*0.3+p[x*3+1]*0.59+p[x*3]*0.11);
if gray > 128 then
begin
p[x*3]:=255;
p[x*3+1]:=255;
p[x*3+2]:=255;
end
else
begin
p[x*3]:=0;
p[x*3+1]:=0;
p[x*3+2]:=0;
end;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载