Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- var bmp: TMufasaBitmap;
- function LoadExample(): TPointArray;
- var
- p: TPoint;
- ex: TMufasaBitmap;
- begin
- bmp.Init(client.GetMBitmaps);
- bmp.LoadFromFile('images/example.bmp');
- bmp.ThresholdAdaptive(0,255, False, TM_Mean, 0);
- bmp.FindColors(Result, 0);
- bmp.DrawClear($FFFFFF);
- for p in Result do
- begin
- bmp.SetPixel(p.x,p.y, 0);
- end;
- end;
- procedure TMufasaBitmap.MarkArea(P: TPoint; Sz: Int32; color: Int32);
- var
- i,test: Int32;
- TPA: TPointArray;
- begin
- TPA := TPAFromCircle(p.x,p.y, Sz);
- FillEllipse(TPA);
- for i:=0 to High(TPA) do
- begin
- if (not InRange(TPA[i].x, 0,Self.GetWidth()-1)) or (not InRange(TPA[i].y, 0,Self.GetHeight()-1)) then
- continue;
- test := bmp.GetPixel(TPA[i].x, TPA[i].y);
- if (test = $FFFFFF) then
- bmp.SetPixel(TPA[i].x, TPA[i].y, color);
- end;
- end;
- var
- i,j,wid,hei: Int32;
- color: Int32;
- H,S,L: Extended;
- TPA,PTS: TPointArray;
- colors: TIntegerArray;
- ATPA: T2DPointArray;
- xxx: Int32;
- begin
- PTS := LoadExample();
- ShowBitmap(bmp);
- //TerminateScript;
- for TPA in ClusterTPA(PTS, 12) do
- begin
- color := Random($FFFFFF);
- ColorToHSL(color, H,S,L);
- for j:=0 to High(TPA) do
- begin
- pts := TPAFromCircle(TPA[j].x,TPA[j].y, 3);
- FillEllipse(pts);
- FilterPointsBox(pts, 0,0, bmp.getWidth-1, bmp.getHeight-1);
- colors := bmp.GetPixels(pts);
- bmp.DrawTPA(pts, $FFFFFF);
- if xxx mod 2 = 0 then
- DrawBitmapDebugImg(bmp);
- bmp.SetPixels(pts, colors);
- bmp.MarkArea(TPA[j], 12, HSLtoColor(H,70,90));
- bmp.SetPixel(TPA[j].x, TPA[j].y, HSLtoColor(H,90,15));
- Inc(xxx);
- end;
- end;
- ShowBitmap(bmp);
- bmp.Free();
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement