mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-27 11:32:18 -05:00
Merge new CTS/Finder system.
Touches pretty much all the functions in finder.pas, so I expect a lot of functions to break. Tests will have to be written and results will have to be compared with Simba 0.97. Still, I think it's ready for merging to simba-next. Squashed commit of the following: commitd1e3645ee5
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 19:08:23 2011 +0200 MML/Finder: Fix all compiler hints + bug. commitf159f20bc2
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 19:05:03 2011 +0200 MML/Finder: Fix FindDTMsRotated. commit1fc33752e4
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 19:04:16 2011 +0200 MML/Finder: FindDTMsRotated rework. commita621a6e8da
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 18:13:36 2011 +0200 MML/Finder: FindDTMs rework done. commit0b592eef86
Merge:56e01c6
aaafd6b
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 16:48:09 2011 +0200 Merge branch 'master' into cts-rework Conflicts: Units/MMLCore/finder.pas commit56e01c67fa
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 16:16:19 2011 +0200 MML/Finder: CTS: Bitmap+Color functions done. Only DTM to go. commit464b90d42b
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 13:58:49 2011 +0200 MMLCore/finder: Small cleanup. commit2414f60c08
Merge:55b0435
a20a31a
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 31 18:12:41 2011 +0200 Merge branch 'master' into cts-rework commit55b0435a4e
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 20:27:54 2011 +0200 Tests: Update BmpBench. commit013daccf07
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 20:09:31 2011 +0200 MML/Core: Cleanup. commit6f32e21291
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 20:08:17 2011 +0200 MML/Core: FindBitmapToleranceIn seems to work. commit3b939443e8
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 19:10:10 2011 +0200 MML/Core: FindBitmapToleranceIn is nearly finished. Speed is nice, results are not accurate yet. I probably missed something when pre-loading the data. commit0422f0eb5a
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 15:53:48 2011 +0200 MML/Core: Fixes for FindBitmapToleranceIn. commit65f4ae16ed
Merge:daff307
353d1f3
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 14:32:46 2011 +0200 Merge branch 'master' into cts-rework commitdaff307f3d
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 13:46:10 2011 +0200 Tests: Add BmpBench. commitcdb89a1802
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 13:12:21 2011 +0200 MMLCore: FindBitmapToleranceIn cts rewrite. commitd0bd81c2e9
Merge:3282636
da0de6e
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 00:15:50 2011 +0200 Merge branch 'master' into cts-rework commit3282636178
Merge:7c86003
a8cdf77
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jul 25 16:50:43 2011 +0200 Merge branch 'master' into cts-rework commit7c8600311c
Merge:153025f
e0767cb
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 24 00:14:53 2011 +0200 Merge branch 'master' into cts-rework Conflicts: Doc/sphinx/conf.py Doc/sphinx/libmml/intro.rst commit153025f080
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 17 19:51:16 2011 +0200 libMML: Changed the indentation. commit8abd502580
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 17 19:37:33 2011 +0200 Documentation: Bump version to 820. commit031654b3d1
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 17 19:36:21 2011 +0200 Documentation: Initial libMML documentation. commitf91c9ffb0e
Merge:f5c9690
989d077
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jul 7 12:00:58 2011 +0200 Merge branch 'master' into cts-rework commitf5c9690bee
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jul 7 11:59:15 2011 +0200 Finder: More rework and cleanups. commit79021409d0
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 21:34:03 2011 +0200 Finder: CTS 2 fix. commitcda571dcb0
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 21:06:17 2011 +0200 Finder: Remote tolerance param. Cleanups. commit733a8cbf32
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 20:39:44 2011 +0200 Finder: More fixes. :-) commite6b005b61f
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 18:34:49 2011 +0200 Finder: CTS-rework fixes. commit6f896b56a2
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 18:15:33 2011 +0200 Finder: Start CTS rework. commita630399148
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 13:01:22 2011 +0200 Small TODO update. commit0e6bf83a5c
Merge:f19fd6b
f2873b1
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 12:59:09 2011 +0200 Merge branch 'master' into cts-rework commitf19fd6bf8d
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 3 20:42:14 2011 +0200 Simba/Doc: Add Raymond to doc. commit451ab89db3
Merge:37183f5
35026bc
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 2 14:48:43 2011 +0200 Merge branch 'master' into cts-rework commit37183f5fd0
Merge:cca7b05
6873e72
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Tue Jun 28 22:10:02 2011 +0200 Merge branch 'master' into cts-rework commitcca7b05213
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 17:03:14 2011 +0200 Add CTS 3 to FindColorsTolerance. Conflicts: Units/MMLCore/finder.pas commitc837d9b960
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 16:33:25 2011 +0200 CTS 3: Fix typo. commit52db461f84
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 6 16:06:17 2011 +0200 CTS 3: Now implement the formula properly. commit7a0db25416
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jun 5 19:44:52 2011 +0200 Add L*a*b CTS (3). commit2e1e786d0e
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 15:11:17 2011 +0200 FindBitmapToleranceIn now works. commit58ea6021cd
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 14:26:20 2011 +0200 CTS work. CTS 2 is still broken for bitmaps. commit91d952d33a
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 12:52:10 2011 +0200 CTS cleanups. commitd9836a251c
Merge:5bf7d8b
bfc3f86
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 20:44:08 2011 +0200 Merge branch 'master' into cts-rework commit5bf7d8beea
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 20:38:00 2011 +0200 Completed first CTS rework. commit7a412d1670
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 20:21:23 2011 +0200 CTS: Cleanups. commit14474a84ab
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 18:16:59 2011 +0200 CTS rework for FindColorsTolerance. commitb87a123701
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 17:44:04 2011 +0200 More cleanups to CTS. commit9415d08100
Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 17:41:06 2011 +0200 Finder: Trying a different CTS approach.
This commit is contained in:
parent
f0fca408fd
commit
5b3e2a864b
@ -59,6 +59,8 @@ write - again - their own wrapper around libMML. This is what is being done with
|
||||
*pyMML*, the python libMML wrapper. It is still as much in development as libMML
|
||||
is, but the functionality exposed by libMML is succesfully used.
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
As of writing the pyMML usage looks like this, the passing around of a client
|
||||
may be removed in a later stage, or at least have it's behaviour changed.
|
||||
|
||||
@ -98,3 +100,4 @@ may be removed in a later stage, or at least have it's behaviour changed.
|
||||
print m.getPos()
|
||||
|
||||
del DLL
|
||||
>>>>>>> master
|
||||
|
5
TODO
5
TODO
@ -7,13 +7,16 @@ Simple stuff, not required, may not be possible/useful:
|
||||
|
||||
|
||||
- CTS/finder speedups and changes [ ]
|
||||
General ideas:
|
||||
- Table displaying all the different performance gains and
|
||||
penalties. [ ]
|
||||
- General ideas:
|
||||
- everything subprocedure (lots of code)
|
||||
|
||||
- jit + comparison function (per cts) generated, call in loop
|
||||
|
||||
- comparison function (per cts), not generated, call in loop
|
||||
|
||||
- Investigate SIMD probable speedups [ ]
|
||||
- JIT (Generate comparison functions) [ ]
|
||||
- Comparison functions for HSL/XYZ/L*a*b should check for
|
||||
match on each component before calculating the next.
|
||||
|
25
Tests/PS/BmpBenchmark.simba
Normal file
25
Tests/PS/BmpBenchmark.simba
Normal file
@ -0,0 +1,25 @@
|
||||
program new;
|
||||
//http://farm4.static.flickr.com/3067/2612399892_7df428d482.jpg
|
||||
{Make the above bitmap your target}
|
||||
var
|
||||
Bmp : integer;
|
||||
x,y : integer;
|
||||
w,h : integer;
|
||||
t, i: integer;
|
||||
begin
|
||||
Bmp := createBitmap(15, 10);
|
||||
FastDrawClear(bmp, clwhite);
|
||||
GetClientDimensions(w,h);
|
||||
|
||||
setcolortolerancespeed(2);
|
||||
t:=getsystemtime;
|
||||
for i := 0 to 10 do
|
||||
FindBitmapToleranceIn(bmp,x,y,0,0,w-1,h-1,500);
|
||||
writeln((getsystemtime-t) / 10.0);
|
||||
|
||||
if FindBitmapToleranceIn(bmp,x,y,0,0,w-1,h-1,500) then
|
||||
begin
|
||||
writeln('found');
|
||||
MoveMouse(x,y);
|
||||
end;
|
||||
end.
|
@ -1,6 +1,5 @@
|
||||
program new;
|
||||
//http://farm4.static.flickr.com/3067/2612399892_7df428d482.jpg
|
||||
{Make the above bitmap your target}
|
||||
|
||||
var
|
||||
Bmp : integer;
|
||||
x,y : integer;
|
||||
@ -19,11 +18,14 @@ begin
|
||||
setcolortolerancespeed(c);
|
||||
|
||||
t:=getsystemtime;
|
||||
for i := 0 to 100 do
|
||||
for i := 0 to 10 do
|
||||
findBitmapToleranceIn(bmp,x,y,0,0,w-1,h-1,10);
|
||||
writeln((getsystemtime-t) / 100.0);
|
||||
if findBitmapToleranceIn(bmp,x,y,0,0,w-1,h-1,200) then
|
||||
writeln((getsystemtime-t) / 10.0);
|
||||
if findBitmapToleranceIn(bmp,x,y,0,0,w-1,h-1,10) then
|
||||
begin
|
||||
writeln('found');
|
||||
movemouse(x,y);
|
||||
end;
|
||||
end;
|
||||
|
||||
{if FindBitmapToleranceIn(bmp,x,y,0,0,w-1,h-1,300) then
|
||||
|
@ -64,6 +64,7 @@ type
|
||||
function FastGetPixel(x,y : integer) : TColor;
|
||||
function FastGetPixels(Points : TPointArray) : TIntegerArray;
|
||||
function GetAreaColors(xs,ys,xe,ye : integer) : T2DIntArray;
|
||||
function GetHSLValues(xs, ys, xe, ye: integer): T2DHSLArray;
|
||||
procedure FastDrawClear(Color : TColor);
|
||||
procedure FastDrawTransparent(x, y: Integer; TargetBitmap: TMufasaBitmap);
|
||||
procedure FastReplaceColor(OldColor, NewColor: TColor);
|
||||
@ -876,6 +877,23 @@ begin
|
||||
result[x-xs][y-ys] := BGRToRGB(FData[y*w+x]);
|
||||
end;
|
||||
|
||||
function TMufasaBitmap.GetHSLValues(xs, ys, xe, ye: integer): T2DHSLArray;
|
||||
var
|
||||
x, y: integer;
|
||||
R, G, B, C: integer;
|
||||
begin
|
||||
ValidatePoint(xs,ys);
|
||||
ValidatePoint(xe,ye);
|
||||
setlength(result,ye-ys+1,xe-xs+1);
|
||||
for y := ys to ye do
|
||||
for x := xs to xe do
|
||||
begin { REWRITE THIS }
|
||||
RGBToHSL(FData[y*w+x].R, FData[y*w+x].G, FData[y*w+x].B,
|
||||
Result[y-ys][x-xs].H, Result[y-ys][x-xs].S,
|
||||
Result[y-ys][x-xs].L);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMufasaBitmap.SetTransparentColor(Col: TColor);
|
||||
begin
|
||||
self.FTransparentSet:= True;
|
||||
@ -1406,7 +1424,7 @@ var
|
||||
i,minw,minh : integer;
|
||||
begin
|
||||
if (AWidth <> w) or (AHeight <> h) then
|
||||
begin;
|
||||
begin
|
||||
if AWidth*AHeight <> 0 then
|
||||
begin;
|
||||
NewData := GetMem(AWidth * AHeight * SizeOf(TRGB32));
|
||||
|
@ -48,7 +48,8 @@ procedure ColorToXYZ(color: Integer; out X, Y, Z: Extended); inline;
|
||||
function XYZToColor(X, Y, Z: Extended): TColor; inline;
|
||||
function HSLToColor(H, S, L: Extended): TColor; inline;
|
||||
function BGRToRGB(BGR : TRGB32) : TColor;inline;
|
||||
|
||||
procedure XYZtoCIELab(X, Y, Z: Extended; out L, a, b: Extended);
|
||||
procedure CIELabtoXYZ(L, a, b: Extended; out X, Y, Z: Extended);
|
||||
|
||||
|
||||
implementation
|
||||
@ -336,4 +337,53 @@ begin
|
||||
Result := RGBToColor(r, g, b);
|
||||
end;
|
||||
|
||||
procedure XYZtoCIELab(X, Y, Z: Extended; out L, a, b: Extended);
|
||||
begin
|
||||
X := X / 95.047;
|
||||
Y := Y / 100.000;
|
||||
Z := Z / 108.883;
|
||||
|
||||
if ( X > 0.008856 ) then
|
||||
X := Power(X, 1.0/3.0)
|
||||
else
|
||||
X := ( 7.787 * X ) + ( 16.0 / 116.0 );
|
||||
if ( Y > 0.008856 ) then
|
||||
Y := Power(Y, 1.0/3.0)
|
||||
else
|
||||
Y := ( 7.787 * Y ) + ( 16.0 / 116.0 );
|
||||
if ( Z > 0.008856 ) then
|
||||
Z := Power(Z, 1.0/3.0)
|
||||
else
|
||||
Z := ( 7.787 * Z ) + ( 16.0 / 116.0 );
|
||||
|
||||
L := (116.0 * Y ) - 16.0;
|
||||
a := 500.0 * ( X - Y );
|
||||
b := 200.0 * ( Y - Z );
|
||||
end;
|
||||
|
||||
procedure CIELabtoXYZ(L, a, b: Extended; out X, Y, Z: Extended);
|
||||
begin
|
||||
Y := ( L + 16 ) / 116.0;
|
||||
X := ( a / 500.0 )+ Y;
|
||||
Z := Y - ( b / 200.0 );
|
||||
|
||||
if ( Power(Y, 3) > 0.008856 ) then
|
||||
Y := Power(Y, 3)
|
||||
else
|
||||
Y := ( Y - (16.0 / 116.0 )) / 7.787;
|
||||
if ( Power(X, 3) > 0.008856 ) then
|
||||
X := Power(X, 3)
|
||||
else
|
||||
X := ( X - (16.0 / 116.0) ) / 7.787;
|
||||
if ( Power(Z, 3) > 0.008856 ) then
|
||||
Z := Power(Z, 3)
|
||||
else
|
||||
Z := ( Z - (16.0 / 116.0) ) / 7.787;
|
||||
|
||||
|
||||
X := 95.047 * X;
|
||||
Y := 100.000 * Y;
|
||||
Z := 108.883 * Z;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -60,6 +60,14 @@ type
|
||||
TRGB32Array = array of TRGB32;
|
||||
TPRGB32Array = array of PRGB32; //Array of Pointers
|
||||
|
||||
THSL = record
|
||||
H, S, L: extended;
|
||||
end;
|
||||
PHSL = ^THSL;
|
||||
|
||||
THSLArray = array of THSL;
|
||||
T2DHSLArray = array of array of THSL;
|
||||
|
||||
TRetData = record
|
||||
Ptr : PRGB32;
|
||||
IncPtrWith : integer;
|
||||
|
Loading…
Reference in New Issue
Block a user