SRL Archive - Research & Development Lounge

DTM scanner release


nielskool

2010-05-26 15:19:59

Heej guys,

Well it isn't finished yet but it is useable… i think:P

Needed:
"c:\tmp"

How to use:
Step 1: Click "add bmp"
Step 2: Click "Open Image"
Step 3: Make a selection around every same object in the image
The selection must be made from the upper left to the bottom right(bug)
Step 4: click "Analyze 4"
Step 5: click "Analyze 4b"
Step 6: click "Analyze 4c"

For now the DTM is limited to two points and no tolerance.

Ow and you may just skip/ok every popup box.

Just found out the max upload is 19 kb so here is the link:
DTM scanner(BETA).exe - 746 Kb

P.S.
DON't click any of the other buttons because some may crash the program.


Special thanks to:
Nielsie95 for its DTM converting functions.

//edit
the picture must not need to be scrolled to make a selection, if you need to make a selection you can enlarge the screen but don't scroll because it won't work.(bug)

list of working DTMs:
Pot of flour:
78DA634C6362609065644006FE16CA601A26CA980C54A3885F0D0063AD0266

coal:
78DA63BCC2C0C070960105181BAB836946289FF12A613500CB BF0462

//
New improved DTM Scanner BETA 2
Added Tolerance
Added Settings
shortened the interface
Added the possibility to extend the DTM


How to use:
Step 1: Click "Open Image"
Step 2: Make a selection around every same object in the image
The selection must be made from the upper left to the bottom right(bug)
Step 3: click "Full scan"

DTM Scanner (BETA 2).exe - 736 Kb
DTM scanner (incl.source).rar - 898 Kb Made in: Delphi Second Edition v7.2.. will clean the source this week.

nielskool

2010-05-26 15:21:01

Scanning methode:

Step1(Button:Analyze 4):
Put every color of the first selection in an array.
Put all the coordinates of the colors in an array
The coordinates are spread over diffrent arrays.
The first array poses the coordinates points that are not within a selection.
The rest of the arrays are the different selections.

Step2(Button:Analyze 4b): :
Find out which color comes most in the selection with the lowest count of that color.
Do this for another 2 colors.

Step3(Button:Analyze 4c): :
Put all coordinates of the 3 best colors in a stringgrid.
Make every possible combination of 2 coordinates and count the amount of that found DTM.
Remember the DTM with the highest good/bad ratio.

Step1:
procedure TForm1.Button8Click(Sender: TObject);
var
myFile : TextFile;
text : string;
//gkleur, fkleur: array[0..2550] of integer;
rowcount: integer;
xt:integer;
startpixelcolor,pixel2color:integer;
startpixelx,startpixely,pixelsy2,pixelsx2,pixel2y,pixel2x:integer;
goedgevonden,slechtgevonden,verschil1x,verschil1y:integer;
zoeky,zoekx,zoekx2,zoeky2:integer;
tempprocent,tempprocent2,procent: variant;
tempje,color: integer;
color2: array[0..10000] of integer;
startpixx,startpixy,startpixcol : integer;
directory : string;
selecs,tempje2, tempje3,i, error:integer;
bestaat: Boolean;
fout: Boolean;
aantalkleuren: array of integer;
goedeselectie: integer;
k:integer;

begin
xt:=Form1.PageControl1.TabIndex+1;

DelTree('c:/tmp/berekend');
CreateDir('c:/tmp/berekend');
SetLength(aantalkleuren, numforma+1); //[selectie(0= niet selctie; >1 = selecties)](aatal kleuren)
SetLength(kleurreeksx, numforma+1);
SetLength(kleurreeksy, numforma+1);
SetLength(kleurreeks, numforma+1);
//SetLength(kleurreeks, 1); //[selectie][kleuren]
//SetLength(kleurreeksx,1); //[selectie][kleur][hoeveelste x]
//SetLength(kleurreeksy,1); //[selectie][kleur][hoeveelste y]
tempje2:= 0;
//DelTree('c:\tmp');
//CreateDir('C:\tmp');
//CreateDir('C:\tmp\goed');
//CreateDir('C:\tmp\fout');
for selecs:=0 to numforma-1 do
begin
//CreateDir('C:\tmp\goed'+inttostr(selecs));
//ChDir('C:\tmp\goed'+inttostr(selecs));
end;
for zoeky2 := forma[0].top to forma[0].top+forma[0].Height-1 do
begin
for zoekx2 := forma[0].left to forma[0].left+forma[0].Width-1 do
begin
color2[tempje2] := img[xt].Canvas.Pixels[zoekx2, zoeky2];
tempje3:= 0;
for i:=0 to tempje2-1 do
begin
if(color2[i] = color2[tempje2])then tempje3:= 1;
end;
if(tempje3 =1)then tempje2:=tempje2-1;
tempje2:= tempje2+1;
end;
end;
//tempje2:= 0;
ShowMessage(inttostr(tempje2));


for zoeky := img[xt].top to img[xt].top+img[xt].Height-1 do
begin
for zoekx := img[xt].left to img[xt].left+img[xt].width-1 do
begin
Gauge1.Progress:= floor((zoeky*img[xt].width+zoekx)/(img[xt].Height*img[xt].Width)*100);
color:= img[xt].Canvas.Pixels[zoekx, zoeky];
bestaat := false;
for i:=0 to tempje2-1 do
begin
if(color2[i] = color)then bestaat:= true;
end;
if(bestaat)then begin
//dir:='C:\tmp\fout';
//CreateDir('C:\tmp\fout');
goedeselectie:= 0;
fout:= true;
//ChDir('C:\tmp\fout');
for selecs:=0 to numforma-1 do
begin
if(zoekx >= forma[selecs].left) AND (zoekx <= forma[selecs].left+forma[selecs].width) AND (zoeky >= forma[selecs].top) AND (zoeky <= forma[selecs].top+forma[selecs].height)then
begin
//CreateDir('C:\tmp\goed'+inttostr(selecs));
//ChDir('C:\tmp\goed'+inttostr(selecs));
//dir:='C:\tmp\goed'+inttostr(selecs);
fout:=false;
goedeselectie:=selecs+1;
end;
end;
//ChDir(dir);
//SetCurrentDir(dir);
//AssignFile(myFile, inttostr(color)+'.txt');
i:=-1;
huidigkleur:= -1;
while(huidigkleur = -1)AND(i<length(kleurreeks[0])-1) do
begin
i:= i+1;
if(kleurreeks[0][i] = color)then
begin
huidigkleur := i;
//ShowMessage('kleur is:'+inttostr(color)+'/n genomen kleur is:'+inttostr(kleurreeks[0][i]));
end;
end;

if huidigkleur > -1 then
begin
StatusBar1.SimpleText:= GetCurrentDir+'\'+inttostr(color)+'.txt';
//append(myFile);



end else
begin
//Rewrite(myFile);
//WriteLn(myFile, color);
//WriteLn(myFile, '1');

for i:=0 to numforma do
begin
SetLength(kleurreeksx[i], length(kleurreeksx[i])+1);
SetLength(kleurreeksy[i], length(kleurreeksy[i])+1);
SetLength(kleurreeks[i], length(kleurreeks[i])+1);
kleurreeks[i][Length(kleurreeks[i])-1] := color;
end;
huidigkleur:= Length(kleurreeks[0])-1;

end;
i:=-1;
while(huidigkleur = -1)AND(i<length(kleurreeks[0])-1) do
begin
i:= i+1;
if(kleurreeks[0][i] = color)then
begin
huidigkleur := i;
//ShowMessage('kleur is:'+inttostr(color)+'/n genomen kleur is:'+inttostr(kleurreeks[0][i]));
end;
end;

//kijk welke kleur

SetLength(kleurreeksx[goedeselectie][huidigkleur], length(kleurreeksx[goedeselectie][huidigkleur])+1);
SetLength(kleurreeksy[goedeselectie][huidigkleur], length(kleurreeksy[goedeselectie][huidigkleur])+1);
kleurreeksx[goedeselectie][huidigkleur][Length(kleurreeksx[goedeselectie][huidigkleur])-1]:= zoekx;
kleurreeksy[goedeselectie][huidigkleur][Length(kleurreeksy[goedeselectie][huidigkleur])-1]:= zoeky;

//WriteLn(myFile, '['+inttostr(zoekx)+', '+inttostr(zoeky)+']');



// Close the file
//CloseFile(myFile);





end;
rowcount:= length(kleurreeks[0]);
end;
end;


end;

Step2:
procedure TForm1.Button3Click(Sender: TObject);
var
myFile : TextFile;
text : string;
rowcount: integer;
temp,temp2,temp3: integer;
xt:integer;
startpixelcolor,pixel2color:integer;
startpixelx,startpixely,pixelsy2,pixelsx2,pixel2y,pixel2x:integer;
goedgevonden,slechtgevonden,verschil1x,verschil1y:integer;
zoeky,zoekx:integer;
tempprocent,tempprocent2,procent: variant;
tempje,color: integer;
startpixx,startpixy,startpixcol,regel,fout : integer;
directory : string;
selecs, selecs2:integer;
verwijder:Boolean;

begin
kleur1:= 0;
kleur2:= 0;
kleur3:= 0;
kleuren:= 0;
xt:=Form1.PageControl1.TabIndex+1;
CreateDir('C:\tmp\berekend');
ChDir('C:\tmp\berekend');
for zoeky := forma[0].top to forma[0].top+forma[0].Height-1 do
begin
for zoekx := forma[0].left to forma[0].left+forma[0].Width-1 do
begin
Gauge1.Progress:= floor((zoeky*forma[0].width+zoekx)/(forma[0].Height*forma[0].Width)*100);
color:= img[xt].Canvas.Pixels[zoekx, zoeky];
verwijder:= false;
for selecs:=0 to numforma-1 do
begin
// ChDir('C:\tmp\goed'+inttostr(selecs));
//if not FileExists(inttostr(color)+'.txt') then
i:=-1;
huidigkleur:= -1;
while(huidigkleur = -1)AND(i<length(kleurreeks[0])-1) do
begin
i:= i+1;
if(kleurreeks[0][i] = color)then
begin
huidigkleur := i;
//ShowMessage('kleur is:'+inttostr(color)+'/n genomen kleur is:'+inttostr(kleurreeks[0][i]));
end;
end;

if huidigkleur = -1 then
begin

verwijder:= true;

end;

end;
if(verwijder = false)then
begin
ChDir('C:\tmp\berekend');
if not FileExists(inttostr(color)+'.txt') then
begin
//CreateDir('C:\tmp\fout');
//ChDir('C:\tmp\fout');
//if FileExists(inttostr(color)+'.txt') then


i:=-1;
huidigkleur:= -1;
while(huidigkleur = -1)AND(i<length(kleurreeks[0])-1) do
begin
i:= i+1;
if(kleurreeks[0][i] = color)then
begin
huidigkleur := i;
//ShowMessage('kleur is:'+inttostr(color)+'/n genomen kleur is:'+inttostr(kleurreeks[0][i]));
end;
end;

if huidigkleur > -1 then
begin
//AssignFile(myFile, inttostr(color)+'.txt');
//Reset(myFile);
regel:= 0;
fout:= 0;

// while not Eof(myFile) do
//begin
//fout:= fout+1;
//ReadLn(myFile, text);

//end;
i:=-1;
huidigkleur := -1;
while(huidigkleur = -1)do
begin
i:= i+1;
if(kleurreeks[0][i] = color)then
begin
huidigkleur := i;
//ShowMessage('kleur is:'+inttostr(color)+'/n genomen kleur is:'+inttostr(kleurreeks[0][i]));
end;
end;
//ShowMessage(inttostr(kleurreeks[0][huidigkleur]));
fout:= length(kleurreeksx[0][huidigkleur]);
//CloseFile(myFile);
end;
//000000
temp:= 99999999;
//bestaat := 1;

for selecs:=0 to numforma-1 do
begin
//ChDir('C:\tmp\goed'+inttostr(selecs));
//if FileExists(inttostr(color)+'.txt') then

if huidigkleur > -1 then
begin
//AssignFile(myFile, inttostr(color)+'.txt');
//Reset(myFile);
regel:= 0;

//while not Eof(myFile) do
// begin
// regel:= regel+1;
// ReadLn(myFile, text);

// end;
huidigkleur := -1;
i:=-1;
while(huidigkleur = -1)do
begin
i:= i+1;
if(kleurreeks[0][i] = color)then
begin
huidigkleur := i;
//ShowMessage('kleur is:'+inttostr(color)+'/n genomen kleur is:'+inttostr(kleurreeks[0][i]));
end;
end;

regel:= length(kleurreeksx[selecs+1][huidigkleur]);
//CloseFile(myFile);
if(temp > regel)then temp:= regel;
end;
regel:= temp;
//000000
end;
if(regel = 99999999)then regel:= 0;
CreateDir('C:\tmp\berekend');
ChDir('C:\tmp\berekend');
AssignFile(myFile, inttostr(color)+'.txt');
Rewrite(myFile);
if(regel >2)then
begin
regel:= regel-2;
if(fout >=0)AND(fout < 3)then
fout:=0 else
fout:= fout -2;
end;
if(regel > 5)AND(regel+fout <> 0)then //5 staat voor minimaal aantal
procent:= floor(regel/(regel+fout)*100) else procent:= 0;
WriteLn(myFile, inttostr(regel));
WriteLn(myFile, inttostr(fout));
WriteLn(myFile, inttostr(procent));
kleuren:= kleuren+1;
SetLength(kleur,kleuren);
SetLength(kleurp,kleuren);
SetLength(kleurg,kleuren);
kleur[kleuren-1]:= color;
kleurp[kleuren-1]:= procent;
kleurg[kleuren-1]:= regel;
//ShowMessage(inttostr(kleurp[kleuren-1])+'/'+inttostr(kleurg[kleuren-1])+'/'+inttostr(kleur[kleuren-1]));


CloseFile(myFile);


end;
end;
end;
end;
ShowMessage('hoog'+inttostr(kleuren));
for i := kleuren-1 Downto 0 do
begin
for j := i to kleuren-2 do
begin
if kleurg[j] < kleurg[j + 1] then
begin
tmp := kleurg[j];
kleurg[j] := kleurg[j + 1];
kleurg[j + 1] := tmp;

tmp := kleurp[j];
if(kleurp[j+1] > 100)then ShowMessage(inttostr(j+1));
if(kleurp[j] > 100)then ShowMessage(inttostr(j+1));
kleurp[j] := kleurp[j + 1];
kleurp[j + 1] := tmp;

tmp := kleur[j];
kleur[j] := kleur[j + 1];
kleur[j + 1] := tmp;

end;
end;
end;

for i := kleuren-1 Downto 0 do
begin
for j := i to kleuren-2 do
begin
if kleurp[j] < kleurp[j + 1] then
begin
tmp := kleurg[j];
kleurg[j] := kleurg[j + 1];
kleurg[j + 1] := tmp;

tmp := kleurp[j];
if(kleurp[j+1] > 100)then ShowMessage(inttostr(j+1));
if(kleurp[j] > 100)then ShowMessage(inttostr(j+1));
kleurp[j] := kleurp[j + 1];
kleurp[j + 1] := tmp;

tmp := kleur[j];
kleur[j] := kleur[j + 1];
kleur[j + 1] := tmp;

end;
end;
end;






//QuickSort(kleurg,kleur,kleurp,High(kleurg), Low(kleurg));
//QuickSort(kleurp,kleur,kleurg,High(kleurp), Low(kleurp));
ShowMessage(inttostr(kleurp[0])+'/'+inttostr(kleur[0])+'/'+inttostr(kleurg[0]));
ShowMessage(inttostr(kleurp[1])+'/'+inttostr(kleur[1])+'/'+inttostr(kleurg[1]));
ShowMessage(inttostr(kleurp[2])+'/'+inttostr(kleur[2])+'/'+inttostr(kleurg[2]));
end;

Step3:
procedure TForm1.Button5Click(Sender: TObject);
var
myFile,myFile2 : TextFile;
text : string;
master1, master2, delimiter, found1, found2 : string;
i, j, K : integer; //operating variables
i2, j2, K2 : integer;
pixelkleur, pixelx, pixely: array[0..1000] of integer;
aantal,regel, aantal2, aantal3: integer;
selecs:integer;
firstcolor, secondcolor:integer;
firstx, secondx:integer;
firsty, secondy:integer;
gfirstcolor, gsecondcolor:integer;
gfirstx, gsecondx:integer;
gfirsty, gsecondy:integer;
verschilx, verschily:integer;
xt:integer;
goed: array of integer;
fout, verhouding,verhoudingvorig:integer;
goedvorig,goedvorig2:integer;
zoeky, zoekx:integer;
goedbol : Boolean;
DTM: TDDTMarray;
gevonden:integer;
kleurpos, kleurpos2:integer;

huidigkleur2, tempx, tempy, temppos:integer;


begin
goedvorig:= 0;
ShowMessage(inttostr(kleur[0]));
kleurpos:= kleurpositie(kleur[0]);
for i:=0 to length(kleurreeksx[1][kleurpos])-1 do
begin
Form6.StringGrid3.Cells[1,Form6.StringGrid3.RowCount-1] := inttostr(kleurreeks[1][kleurpos]);
Form6.StringGrid3.Cells[2,Form6.StringGrid3.RowCount-1] := inttostr(kleurreeksx[1][kleurpos][i]);
Form6.StringGrid3.Cells[3,Form6.StringGrid3.RowCount-1] := inttostr(kleurreeksy[1][kleurpos][i]);
Form6.StringGrid3.RowCount:= Form6.StringGrid3.RowCount+1;
end;

kleurpos:= kleurpositie(kleur[1]);
for i:=0 to length(kleurreeksx[1][kleurpos])-1 do
begin
Form6.StringGrid3.Cells[1,Form6.StringGrid3.RowCount-1] := inttostr(kleurreeks[1][kleurpos]);
Form6.StringGrid3.Cells[2,Form6.StringGrid3.RowCount-1] := inttostr(kleurreeksx[1][kleurpos][i]);
Form6.StringGrid3.Cells[3,Form6.StringGrid3.RowCount-1] := inttostr(kleurreeksy[1][kleurpos][i]);
Form6.StringGrid3.RowCount:= Form6.StringGrid3.RowCount+1;
end;

kleurpos:= kleurpositie(kleur[2]);
for i:=0 to length(kleurreeksx[1][kleurpos])-1 do
begin
Form6.StringGrid3.Cells[1,Form6.StringGrid3.RowCount-1] := inttostr(kleurreeks[1][kleurpos]);
Form6.StringGrid3.Cells[2,Form6.StringGrid3.RowCount-1] := inttostr(kleurreeksx[1][kleurpos][i]);
Form6.StringGrid3.Cells[3,Form6.StringGrid3.RowCount-1] := inttostr(kleurreeksy[1][kleurpos][i]);
Form6.StringGrid3.RowCount:= Form6.StringGrid3.RowCount+1;
end;
for i:=0 to Form6.StringGrid3.RowCount-2 do
begin
for k:=i+1 to Form6.StringGrid3.RowCount-2 do
begin
firstcolor:= strtoint(Form6.StringGrid3.Cells[1,i]);
firstx:= strtoint(Form6.StringGrid3.Cells[2,i]);
firsty:= strtoint(Form6.StringGrid3.Cells[3,i]);
secondcolor:= strtoint(Form6.StringGrid3.Cells[1,k]);
secondx:= strtoint(Form6.StringGrid3.Cells[2,k]);
secondy:= strtoint(Form6.StringGrid3.Cells[3,k]);
verschilx:= firstx - secondx;
verschily:= firsty - secondy;

huidigkleur:= kleurpositie(firstcolor);
huidigkleur2:= kleurpositie(secondcolor);

fout:= 0;
SetLength(goed, 0);
SetLength(goed, Numforma+1);
For selecs:=0 to Numforma do
begin
for j:=0 to length(kleurreeksx[selecs][huidigkleur])-1 do
begin
for j2:=j to length(kleurreeksx[selecs][huidigkleur2])-1 do
begin

if((kleurreeksx[selecs][huidigkleur][j]-kleurreeksx[selecs][huidigkleur2][j2]) = verschilx)then
begin
if((kleurreeksy[selecs][huidigkleur][j]-kleurreeksy[selecs][huidigkleur2][j2]) = verschily)then
begin

goed[selecs]:= goed[selecs]+1;
//ShowMessage(inttostr(goed[selecs]));


end;
end;

end;

end;
end;
goedvorig2 := 999999999;
for selecs:=1 to Numforma do
begin
if(goedvorig2 > goed[selecs])then goedvorig2:= goed[selecs];
end;
if(goedvorig2 <> goed[0]+goedvorig2)then
verhouding:= floor((goedvorig2/(goed[0]+goedvorig2))*100)else
verhouding:= 100;
if (verhouding >verhoudingvorig) or ((verhouding =verhoudingvorig) AND (goedvorig2 > goedvorig))then
begin
goedvorig := goedvorig2;
verhoudingvorig:= verhouding;
gfirstcolor:=firstcolor;
gfirstx:= firstx;
gfirsty:= firsty;
gsecondcolor:= secondcolor;
gsecondx:= secondx;
gsecondy:= secondy;

end;
end;

end;
Form6.StaticText1.Caption:= inttostr(gfirstcolor);
Form6.StaticText2.Caption:= inttostr(gfirstx);
Form6.StaticText3.Caption:= inttostr(gfirsty);
Form6.StaticText4.Caption:= inttostr(gsecondx);
Form6.StaticText5.Caption:= inttostr(gsecondy);
Form6.StaticText6.Caption:= inttostr(gsecondcolor);
Form6.StaticText7.Caption:= inttostr(verhoudingvorig);
Form6.StaticText8.Caption:= inttostr(goedvorig);
SetLength(DTM, 2);
DTM[0].x:= gfirstx;
DTM[0].y:= gfirsty;
DTM[0].size:= 0;
//DTM.shape:= pixely[i];
DTM[0].color:= gfirstcolor;
DTM[0].Tolerance:= 0;
DTM[1].x:= gsecondx;
DTM[1].y:= gsecondy;
DTM[1].size:= 0;
//DTM.shape:= pixely[i];
DTM[1].color:= gsecondcolor;
DTM[1].Tolerance:= 0;
Form6.memo1.lines.text:= DDTMtoDTM(DTM);
ShowMessage('klaar');



end;

If you look at the code you will see allot of showmessages and allot commented away. thats because of the testing.
you will also see that i have more variables declared than i use, well that is just because i am unorganized and change my mind continuesly or try a diffrent way of coding with diffrent names:tongue:

Tim0suprem0

2010-05-26 16:14:43

First post! I'm psyched to try it out :)

Edit: Works great! :D First time I tried it I clicked "Analyze 4c" too soon and it froze, but the second try I did it, it worked great. I also manually input the values into SCAR's DTM Editor and the DTM String was exactly the same.

Nice work!!

And regarding speed, I don't know what to say because I've never seen anything like this, so I'll say it was normal. I certainly didn't feel impatient using it.

nielskool

2010-05-26 16:19:46

I will add tollerance soon. that would make it 10 times better.. I hope and think.
Tell me when you tryed it. I also want to know if you think it is slow or fast or just normal…

//edit

@Tim0suprem0
great! and I am also glad to hear it doesn't take to much time.

so it is downloaded a few times but no one says something except @Tim0suprem0:crying::(

Bebe

2010-05-27 17:51:08

From: nielskool
so it is downloaded a few times but no one says something except @Tim0suprem0:crying::(

Get used to it. Don't whore for attention. If your DTM scanner is worthwhile then word will spread.

Post source. I won't even download it personally unless there is source included.

Edit:
Also more information (i.e. language used, methods, explanations, pictures etc.).

masterBB

2010-05-27 19:20:13

Nice, works great. Speed is good enough for me!

Just one small tiny little note: If you're releasing code on this forum, than it would be wise to translate all Dutch words to english, I'm dutch myself, but most people on this forum can't read it. It's no big deal, just a small note.

nielskool

2010-05-27 19:26:43

haha nice one.. will fix it with the next release:P

Sir R. M8gic1an

2010-05-28 08:34:35

This could come to be used in Simba ;)

Nielsie was working on one of these, although it's not finished yet.. If you think you're code is clean enough, how about getting in touch with Wizzup?

Moved.

~RM

nielsie95

2010-05-28 10:44:18

From: Rasta Magician
This could come to be used in Simba ;)

Nielsie was working on one of these, although it's not finished yet.. If you think you're code is clean enough, how about getting in touch with Wizzup?

Moved.

~RM


I made a DTM editor for Simba, which is pretty much finished (see the Simba forums) ;)

nielskool

2010-05-28 16:50:16

i found the code for color tolerance but i don't know if I understand it all:P
I need to know whether a color is in range of an other color toleranced or not.
So does this work:


function colorinrange(color, color2, Tol:integer): Boolean;
var
clR, clG, clB: Integer;
clR2, clG2, clB2: Integer;

begin
ColorToRGB(Color, clR, clG, clB);
ColorToRGB(Color2, clR2, clG2, clB2);

if ((abs(clB-clB2) <= Tol) and (abs(clG-clG2) <= Tol) and (Abs(clR-clR2) <= Tol)) then Result:= true;

end;
And i don't know what abs does(yet):P

//edit
Offcourse abs!!!!!!!
Why didn't i know before:P
Now i know the meaning of abs i think the code above should be allright… Right?

//edit2
Just tryed it on ore mining spots… didn't work..;( well that will be my challenge!
After color tolerance and more points it should work!
And wel if that doesn't work than there is always area… but thats a long way before i get to that point:P

//edit3
Yeaa! In the mining guild i got a working DTM:P
78DA63BCC2C0C070960105181BAB836946289FF12A613500CBBF0462 (coal)
Imagine what it could do with more points and tolerance!

Anyone got a challenge for the program?

//edit4
:blushing: Is this good enough to apply for srl member? Or do i really need to script a runescape script?

Sir R. M8gic1an

2010-05-29 07:23:38

Use scripting standards before you think of applying ;)

~RM

nielskool

2010-05-29 09:23:41

From: Rasta Magician
Use scripting standards before you think of applying ;)

~RM


hmm no srl member for me then… i script my way and i am a bit unorganized:( well maybe in the futur but don't think so.

i luffs yeww

2010-05-29 09:58:16


procedure TForm1.Button8Click(Sender: TObject);
var
WowCount, XT, StartPixelColor, Pixel2Color, StartPixelX, StartPixelY: Integer;
Verschil1X, Verschil1Y, ZoekY, ZoekX, ZoekX2, ZoekY2, Tempje, Color: Integer;
PixelSY2, PixelSX2, Pixel2Y, Pixel2X, Goedgevonden, Slechtgevonden: Integer;
StartPixX, StartPixY, StartPixCol, Selecs, Tempje2, Tempje3, Error: Integer;
Goedeselectie, i, k: Integer;
Tempprocent, Tempprocent2, Procent: Variant;
Color2: array [0..10000] of Integer;
Aantalkleuren: array of Integer;
Text, Directory: string;
Bestaat, Fout: Boolean;
MyFile: TextFile;

begin
XT := Form1.PageControl1.TabIndex + 1;
DelTree('C:/tmp/berekend');
CreateDir('C:/tmp/berekend');
SetLength(Aantalkleuren, NumFormA + 1); //[selectie(0= niet selctie; >1 = selecties)](aatal kleuren)
SetLength(KleurreeksX, NumFormA + 1);
SetLength(KleurreeksY, NumFormA + 1);
SetLength(Kleurreeks, NumFormA + 1);
Tempje2 := 0;
for Zoeky2 := FormA[0].Top to FormA[0].Top + FormA[0].Height - 1 do
for Zoekx2 := FormA[0].Left to FormA[0].Left + FormA[0].Width - 1 do
begin
Color2[Tempje2] := Img[XT].Canvas.Pixels[ZoekX2, ZoekY2];
Tempje3 := 0;
for i := 0 to Tempje2 - 1 do
if(Color2[i] = Color2[Tempje2])then
Tempje3 := 1;
if(Tempje3 = 1)then
Tempje2 := Tempje2 - 1;
Tempje2 := Tempje2 + 1;
end;
ShowMessage(IntToStr(Tempje2));
for ZoekY := Img[XT].Top to Img[XT].Top + Img[XT].Height - 1 do
for ZoekX := Img[XT].Left to Img[XT].Left + Img[XT].Width - 1 do
begin
Gauge1.Progress := Floor((ZoekY * Img[XT].Width + ZoekX) / (Img[XT].Height * Img[XT].Width) * 100);
Color := Img[XT].Canvas.Pixels[ZoekX, ZoekY];
Bestaat := False;
for i := 0 to Tempje2 - 1 do
if(Color2[i] = Color)then
Bestaat := True;
if(Bestaat)then
begin
Goedeselectie := 0;
Fout := True;
for Selecs := 0 to NumFormA - 1 do
if(ZoekX >= FormA[Selecs].Left) and (ZoekX <= FormA[Selecs].Left + FormA[Selecs].Width) and (ZoekY >= FormA[Selecs].Top) and (ZoekY <= FormA[Selecs].Top + FormA[Selecs].Height)then
begin
Fout := False;
Goedeselectie := Selecs + 1;
end;
end;
i := -1;
Huidigkleur := -1;
while(Huidigkleur = -1) and (i < Length(Kleurreeks[0]) - 1) do
begin
i:= i + 1;
if(Kleurreeks[0][i] = Color)then
Huidigkleur := i;
end;
if(Huidigkleur > -1)then
StatusBar1.SimpleText:= GetCurrentDir + '\' + IntToStr(Color)+'.txt'
else
for i := 0 to NumFormA do
begin
SetLength(KleurreeksX[i], Length(KleurreeksX[i]) + 1);
SetLength(KleurreeksY[i], Length(KleurreeksY[i]) + 1);
SetLength(Kleurreeks[i], Length(Kleurreeks[i]) + 1);
Kleurreeks[i][Length(Kleurreeks[i]) - 1] := Color;
end;
Huidigkleur := Length(Kleurreeks[0]) - 1;
end;
i := -1;
while (Huidigkleur = -1) and (i < Length(Kleurreeks[0]) - 1) do
begin
i := i + 1;
if(Kleurreeks[0][i] = Color)then
Huidigkleur := i;
end;
SetLength(KleurreeksX[Goedeselectie][Huidigkleur], Length(KleurreeksX[Goedeselectie][Huidigkleur]) + 1);
SetLength(Kleurreeksy[Goedeselectie][Huidigkleur], Length(Kleurreeksy[Goedeselectie][Huidigkleur]) + 1);
KleurreeksX[Goedeselectie][Huidigkleur][Length(KleurreeksX[Goedeselectie][Huidigkleur]) - 1] := ZoekX;
KleurreeksY[Goedeselectie][Huidigkleur][Length(KleurreeksY[Goedeselectie][Huidigkleur]) - 1] := ZoekY;
RowCount := Length(Kleurreeks[0]);
end;

I *think* that's all correct standards for the first part. I'm working on steps two and three right now. Only posting step one now because I might fall asleep working on the other ones. :p


procedure TForm1.Button3Click(Sender: TObject);
var
Goedgevonden, Slechtgevonden, Verschil1X, Verschil1Y, ZoekY, ZoekX: Integer;
RowCount, Temp, Temp2, Temp3, XT, StartPixelColor, Pixel2Color: Integer;
StartPixelX, StartPixelY, PixelSY2, PixelSX2, Pixel2Y, Pixel2X: Integer;
Tempje, Color, StartPixX, StartPixY, StartPixCol, Regel, Fout: Integer;
Selecs, Selecs2: Integer;
Tempprocent, Tempprocent2, Procent: Variant;
Text, Directory: String;
Verwijder: Boolean;
MyFile: TextFile;

begin
Kleur1 := 0;
Kleur2 := 0;
Kleur3 := 0;
Kleuren := 0;
XT := Form1.PageControl1.TabIndex + 1;
CreateDir('C:\tmp\berekend');
ChDir('C:\tmp\berekend');
for ZoekY := FormA[0].Top to FormA[0].Top + FormA[0].Height - 1 do
begin
for ZoekX := FormA[0].Left to FormA[0].Left + FormA[0].Width - 1 do
begin
Gauge1.Progress:= Floor((ZoekY * FormA[0].Width + ZoekX) / (FormA[0].Height * FormA[0].Width) * 100);
Color := Img[XT].Canvas.Pixels[ZoekX, ZoekY];
Verwijder := False;
for Selecs := 0 to NumFormA - 1 do
begin
i := -1;
Huidigkleur := -1;
while(Huidigkleur = -1) and (i < Length(Kleurreeks[0]) - 1)do
begin
i := i + 1;
if(Kleurreeks[0][i] = Color)then
Huidigkleur := i;
end;
if(Huidigkleur = -1)then
Verwijder := True;
end;
if(Verwijder = False)then
begin
ChDir('C:\tmp\berekend');
if(not(FileExists(IntToStr(Color) + '.txt')))then
begin
i := -1;
Huidigkleur := -1;
while(Huidigkleur = -1) and (i < Length(Kleurreeks[0]) - 1)do
begin
i := i + 1;
if(Kleurreeks[0][i] = Color)then
Huidigkleur := i;
end;
if(Huidigkleur > -1)then
begin
Regel := 0;
Fout := 0;
i := -1;
Huidigkleur := -1;
while(Huidigkleur = -1)do
begin
i := i + 1;
if(Kleurreeks[0][i] = Color)then
Huidigkleur := i;
end;
Fout := Length(KleurreeksX[0][Huidigkleur]);
end;
Temp := 99999999;
for Selecs := 0 to NumFormA - 1 do
if(Huidigkleur > -1)then
begin
Regel := 0;
Huidigkleur := -1;
i := -1;
while(Huidigkleur = -1)do
begin
i := i + 1;
if(Kleurreeks[0][i] = Color)then
Huidigkleur := i;
end;
Regel := Length(KleurreeksX[Selecs + 1][Huidigkleur]);
if(Temp > Regel)then
Temp := Regel;
end;
Regel := Temp;
end;
if(Regel = 99999999)then
Regel := 0;
CreateDir('C:\tmp\berekend');
ChDir('C:\tmp\berekend');
AssignFile(MyFile, IntToStr(Color)+'.txt');
Rewrite(MyFile);
if(Regel > 2)then
begin
Regel := Regel - 2;
if(Fout >= 0) and (Fout < 3)then
Fout := 0
else
Fout := Fout - 2;
end;
if(Regel > 5) and (Regel + Fout <> 0)then //5 staat voor minimaal aantal
Procent := Floor(Regel / (Regel + Fout) * 100)
else
Procent := 0;
Writeln(MyFile, IntToStr(Regel));
Writeln(MyFile, IntToStr(Fout));
Writeln(MyFile, IntToStr(Procent));
Kleuren := Kleuren + 1;
SetLength(Kleur, Kleuren);
SetLength(Kleurp, Kleuren);
SetLength(Kleurg, Kleuren);
Kleur[Kleuren - 1] := Color;
Kleurp[Kleuren - 1] := Procent;
Kleurg[Kleuren - 1] := Regel;
CloseFile(MyFile);
end;
end;
ShowMessage('hoog' + IntToStr(Kleuren));
for i := Kleuren - 1 downto 0 do
for j := i to Kleuren - 2 do
if(Kleurg[j] < Kleurg[j + 1])then
begin
Tmp := Kleurg[j];
Kleurg[j] := Kleurg[j + 1];
Kleurg[j + 1] := Tmp;
Tmp := Kleurp[j];
if(Kleurp[j + 1] > 100)then
ShowMessage(IntToStr(j + 1));
if(Kleurp[j] > 100)then
ShowMessage(IntToStr(j + 1));
Kleurp[j] := Kleurp[j + 1];
Kleurp[j + 1] := Tmp;
Tmp := kleur[j];
Kleur[j] := Kleur[j + 1];
Kleur[j + 1] := Tmp;
end;
for i := Kleuren - 1 downto 0 do
for j := i to Kleuren - 2 do
if(Kleurp[j] < Kleurp[j + 1])then
begin
Tmp := Kleurg[j];
Kleurg[j] := Kleurg[j + 1];
Kleurg[j + 1] := Tmp;
Tmp := Kleurp[j];
if(Kleurp[j + 1] > 100)then
ShowMessage(IntToStr(j + 1));
if(Kleurp[j] > 100)then
ShowMessage(IntToStr(j + 1));
Kleurp[j] := Kleurp[j + 1];
Kleurp[j + 1] := Tmp;
Tmp := Kleur[j];
Kleur[j] := Kleur[j + 1];
Kleur[j + 1] := Tmp;
end;
end;
ShowMessage(IntToStr(Kleurp[0]) + '/' + IntToStr(Kleur[0]) + '/' + IntToStr(Kleurg[0]));
ShowMessage(IntToStr(Kleurp[1]) + '/' + IntToStr(Kleur[1]) + '/' + IntToStr(Kleurg[1]));
ShowMessage(IntToStr(Kleurp[2]) + '/' + IntToStr(Kleur[2]) + '/' + IntToStr(Kleurg[2]));
end;

Again, not completely sure if I have the correct amount of begin/ends, but I should. I'll do the last part when my hands/wrists don't hurt as much. :p


procedure TForm1.Button5Click(Sender: TObject);
var
VerschilX, VerschilY, Four, Verhouding, Verhoudingvorig, Goedvorig: Integer;
Goedvorig2, ZoekX, ZoekY, Gevonden, Kleurpos, Kleurpos2, TempPos: Integer;
i, i2, j, j2, k, k2, Aantal, Aantal2, Aantal3, Regel, Selecs, XT: Integer;
GFirstColor, GSecondColor, GFirstX, GSecondX, GFirstY, GSecondY: Integer;
FirstColor, SecondColor, FirstX, SecondX, FirstY, SecondY: Integer;
Huidigkleur2, TempX, TempY: Integer;
Text, Master1, Master2, Delimiter, Found1, Found2: String;
Pixelkleur, PixelX, PixelY: array [0..1000] of Integer;
MyFile, MyFile2: TextFile;
Goed: array of Integer;
Goedbol: Boolean;
DTM: TDDTMArray;

begin
Goedvorig := 0;
ShowMessage(IntToStr(Kleur[0]));
Kleurpos := Kleurpositie(Kleur[0]);
for i := 0 to Length(KleurreeksX[1][Kleurpos]) - 1 do
begin
Form6.StringGrid3.Cells[1, Form6.StringGrid3.RowCount - 1] := IntToStr(Kleurreeks[1][Kleurpos]);
Form6.StringGrid3.Cells[2, Form6.StringGrid3.RowCount - 1] := IntToStr(KleurreeksX[1][Kleurpos][i]);
Form6.StringGrid3.Cells[3, Form6.StringGrid3.RowCount - 1] := IntToStr(KleurreeksY[1][Kleurpos][i]);
Form6.StringGrid3.RowCount := Form6.StringGrid3.RowCount + 1;
end;
Kleurpos := Kleurpositie(Kleur[1]);
for i := 0 to Length(KleurreeksX[1][Kleurpos]) - 1 do
begin
Form6.StringGrid3.Cells[1, Form6.StringGrid3.RowCount - 1] := IntToStr(Kleurreeks[1][Kleurpos]);
Form6.StringGrid3.Cells[2, Form6.StringGrid3.RowCount - 1] := IntToStr(KleurreeksX[1][Kleurpos][i]);
Form6.StringGrid3.Cells[3, Form6.StringGrid3.RowCount - 1] := IntToStr(KleurreeksY[1][Kleurpos][i]);
Form6.StringGrid3.RowCount:= Form6.StringGrid3.RowCount + 1;
end;
Kleurpos := Kleurpositie(Kleur[2]);
for i := 0 to Length(KleurreeksX[1][Kleurpos]) - 1 do
begin
Form6.StringGrid3.Cells[1, Form6.StringGrid3.RowCount - 1] := IntToStr(Kleurreeks[1][Kleurpos]);
Form6.StringGrid3.Cells[2, Form6.StringGrid3.RowCount - 1] := IntToStr(KleurreeksX[1][Kleurpos][i]);
Form6.StringGrid3.Cells[3, Form6.StringGrid3.RowCount - 1] := IntToStr(KleurreeksY[1][Kleurpos][i]);
Form6.StringGrid3.RowCount := Form6.StringGrid3.RowCount + 1;
end;
for i := 0 to Form6.StringGrid3.RowCount - 2 do
begin
for k := i + 1 to Form6.StringGrid3.RowCount - 2 do
begin
FirstColor := StrToInt(Form6.StringGrid3.Cells[1, i]);
FirstX := StrToInt(Form6.StringGrid3.Cells[2, i]);
FirstY := StrToInt(Form6.StringGrid3.Cells[3, i]);
SecondColor := StrToInt(Form6.StringGrid3.Cells[1, k]);
SecondX := StrToInt(Form6.StringGrid3.Cells[2, k]);
SecondY := StrtoInt(Form6.StringGrid3.Cells[3, k]);
VerschilX := FirstX - SecondX;
VerschilY := FirstY - SecondY;
Huidigkleur := Kleurpositie(FirstColor);
Huidigkleur2 := Kleurpositie(SecondColor);
Fout := 0;
SetLength(Goed, 0);
SetLength(Goed, NumFormA + 1);
for Selecs := 0 to NumFormA do
for j := 0 to Length(KleurreeksX[Selecs][Huidigkleur]) - 1 do
for j2 := j to Length(KleurreeksX[Selecs][Huidigkleur2]) - 1 do
if((KleurreeksX[Selecs][Huidigkleur][j] - KleurreeksX[Selecs][Huidigkleur2][j2]) = VerschilX)then
if((KleurreeksY[Selecs][Huidigkleur][j] - KleurreeksY[Selecs][Huidigkleur2][j2]) = VerschilY)then
Goed[Selecs] := Goed[Selecs] + 1;
Goedvorig2 := 999999999;
for Selecs := 1 to NumFormA do
if(Goedvorig2 > Goed[Selecs])then
Goedvorig2 := Goed[Selecs];
if(Goedvorig2 <> Goed[0] + Goedvorig2)then
Verhouding := Floor((Goedvorig2 / (Goed[0] + Goedvorig2)) * 100)
else
Verhouding := 100;
if(Verhouding > Verhoudingvorig) or ((Verhouding = Verhoudingvorig) and (Goedvorig2 > Goedvorig))then
begin
Goedvorig := Goedvorig2;
Verhoudingvorig := Verhouding;
GFirstColor := FirstColor;
GFirstX := FirstX;
GFirsty := FirstY;
GSecondColor := SecondColor;
GSecondX := SecondX;
GSecondY := SecondY;
end;
Form6.StaticText1.Caption := IntToStr(GFirstColor);
Form6.StaticText2.Caption := IntToStr(GFirstX);
Form6.StaticText3.Caption := IntToStr(GFirstY);
Form6.StaticText4.Caption := IntToStr(GSecondX);
Form6.StaticText5.Caption := IntToStr(GSecondY);
Form6.StaticText6.Caption := IntToStr(GSecondColor);
Form6.StaticText7.Caption := IntToStr(Verhoudingvorig);
Form6.StaticText8.Caption := IntToStr(Goedvorig);
SetLength(DTM, 2);
DTM[0].x := GFirstX;
DTM[0].y := GFirstY;
DTM[0].Size := 0;
DTM[0].Color := GFirstColor;
DTM[0].Tolerance := 0;
DTM[1].x := GSecondX;
DTM[1].y := GSecondY;
DTM[1].Size := 0;
DTM[1].Color := GSecondColor;
DTM[1].Tolerance := 0;
Form6.Memo1.Lines.Text := DDTMToDTM(DTM);
ShowMessage('klaar');
end;

:) Everything should work.

nielskool

2010-05-29 10:15:33

From: i luffs yeww

procedure TForm1.Button8Click(Sender: TObject);
var
WowCount, XT, StartPixelColor, Pixel2Color, StartPixelX, StartPixelY: Integer;
Verschil1X, Verschil1Y, ZoekY, ZoekX, ZoekX2, ZoekY2, Tempje, Color: Integer;
PixelSY2, PixelSX2, Pixel2Y, Pixel2X, Goedgevonden, Slechtgevonden: Integer;
StartPixX, StartPixY, StartPixCol, Selecs, Tempje2, Tempje3, Error: Integer;
Goedeselectie, i, k: Integer;
Tempprocent, Tempprocent2, Procent: Variant;
Color2: array [0..10000] of Integer;
Aantalkleuren: array of Integer;
Text, Directory: string;
Bestaat, Fout: Boolean;
MyFile: TextFile;

begin
XT := Form1.PageControl1.TabIndex + 1;
DelTree('C:/tmp/berekend');
CreateDir('C:/tmp/berekend');
SetLength(Aantalkleuren, NumFormA + 1); //[selectie(0= niet selctie; >1 = selecties)](aatal kleuren)
SetLength(KleurreeksX, NumFormA + 1);
SetLength(KleurreeksY, NumFormA + 1);
SetLength(Kleurreeks, NumFormA + 1);
Tempje2 := 0;
for Zoeky2 := FormA[0].Top to FormA[0].Top + FormA[0].Height - 1 do
for Zoekx2 := FormA[0].Left to FormA[0].Left + FormA[0].Width - 1 do
begin
Color2[Tempje2] := Img[XT].Canvas.Pixels[ZoekX2, ZoekY2];
Tempje3 := 0;
for i := 0 to Tempje2 - 1 do
if(Color2[i] = Color2[Tempje2])then
Tempje3 := 1;
if(Tempje3 = 1)then
Tempje2 := Tempje2 - 1;
Tempje2 := Tempje2 + 1;
end;
ShowMessage(IntToStr(Tempje2));
for ZoekY := Img[XT].Top to Img[XT].Top + Img[XT].Height - 1 do
for ZoekX := Img[XT].Left to Img[XT].Left + Img[XT].Width - 1 do
begin
Gauge1.Progress := Floor((ZoekY * Img[XT].Width + ZoekX) / (Img[XT].Height * Img[XT].Width) * 100);
Color := Img[XT].Canvas.Pixels[ZoekX, ZoekY];
Bestaat := False;
for i := 0 to Tempje2 - 1 do
if(Color2[i] = Color)then
Bestaat := True;
if(Bestaat)then
begin
Goedeselectie := 0;
Fout := True;
for Selecs := 0 to NumFormA - 1 do
if(ZoekX >= FormA[Selecs].Left) and (ZoekX <= FormA[Selecs].Left + FormA[Selecs].Width) and (ZoekY >= FormA[Selecs].Top) and (ZoekY <= FormA[Selecs].Top + FormA[Selecs].Height)then
begin
Fout := False;
Goedeselectie := Selecs + 1;
end;
end;
i := -1;
Huidigkleur := -1;
while(Huidigkleur = -1) and (i < Length(Kleurreeks[0]) - 1) do
begin
i:= i + 1;
if(Kleurreeks[0][i] = Color)then
Huidigkleur := i;
end;
if(Huidigkleur > -1)then
StatusBar1.SimpleText:= GetCurrentDir + '\' + IntToStr(Color)+'.txt'
else
for i := 0 to NumFormA do
begin
SetLength(KleurreeksX[i], Length(KleurreeksX[i]) + 1);
SetLength(KleurreeksY[i], Length(KleurreeksY[i]) + 1);
SetLength(Kleurreeks[i], Length(Kleurreeks[i]) + 1);
Kleurreeks[i][Length(Kleurreeks[i]) - 1] := Color;
end;
Huidigkleur := Length(Kleurreeks[0]) - 1;
end;
i := -1;
while (Huidigkleur = -1) and (i < Length(Kleurreeks[0]) - 1) do
begin
i := i + 1;
if(Kleurreeks[0][i] = Color)then
Huidigkleur := i;
end;
SetLength(KleurreeksX[Goedeselectie][Huidigkleur], Length(KleurreeksX[Goedeselectie][Huidigkleur]) + 1);
SetLength(Kleurreeksy[Goedeselectie][Huidigkleur], Length(Kleurreeksy[Goedeselectie][Huidigkleur]) + 1);
KleurreeksX[Goedeselectie][Huidigkleur][Length(KleurreeksX[Goedeselectie][Huidigkleur]) - 1] := ZoekX;
KleurreeksY[Goedeselectie][Huidigkleur][Length(KleurreeksY[Goedeselectie][Huidigkleur]) - 1] := ZoekY;
RowCount := Length(Kleurreeks[0]);
end;

I *think* that's all correct standards for the first part. I'm working on steps two and three right now. Only posting step one now because I might fall asleep working on the other ones. :p


heey man thanks for cleaning the script but… why do you do it? is it to show me the proper way and learn me something or just to be nice?

i luffs yeww

2010-05-29 10:35:17

:p I tend to do that for people. I'm just glad this isn't a few thousand lines of terribly coded stuff to standardize. >_>

I don't mind doing it. :) I like to see the original and then the nicer-looking (no offense) script, and it's nice. :3 Don't worry about it; I do it for fun mostly.

nielskool

2010-05-29 10:49:04

i like making scripts with algorithmes, zo did i make a script once for bejeweled and for searching a formule behind something.
and as long as it works i'm happy! i can cleanup my scripts but.. there is some kind of wall stopping me:redface:

still thanks for cleaning!

i luffs yeww

2010-05-29 10:52:55

x] I'm not saying you can't or anything. :) Just since there isn't one posted (a clean, easy to read version), I posted it. I like to read through scripts, if they're legible, and I know others here do, too. Sooo yeah. Anyway, I'll finish up that last one after I sleep.

nielskool

2010-05-29 11:00:53

From: i luffs yeww
x] I'm not saying you can't or anything. :) Just since there isn't one posted (a clean, easy to read version), I posted it. I like to read through scripts, if they're legible, and I know others here do, too. Sooo yeah. Anyway, I'll finish up that last one after I sleep.


I have to admit it feels much better if i look through your version. It almost gives me a good feeling by just looking at it xD.
This way i see how and what i scripted.. with my own i have to figure it out first:P

//edit
@i luffs yeww's Avatar
i luffs yeww
hmm:( need to find out where which loop is going wrong.. the first script doesn't do something i don't know what yet.
second does to much it does the same but like 10 times or so, and the last one misses 2 ends… maybe i just need to cleanup the code myself…

//edit2
i got my self a goal! giant rats under varrock.. i used to bot on them, made my chars str atk and def to 60

Heej guyz,

I already told you i wanted to add tolerance and add more poits to the DTM
I finished my exams today so I want to continue the project.
First I will share my thoughts with you on how I was planning to do it.

For now it just searches for the best 2point DTM
If it is a working dtm it stops
If it isn't then continue with searching
If it isn't found enough times than it increases the tolerance
If it is found to many times in a wrong section then it adds a extra point.

Well this is how i think it shold work

If anyone got an idea to improve this feel free to say so

//edit
See first post, updated the program.

nielskool

2010-06-11 07:36:03

Released a new version including the source(see first post)

Tollerance included now.
Possibility to add point to the found DTM.

The tollerance you set in the settings is used for finding the DTM.
Best to do for now is:
Set tollerance to about 4-6.

If the result is 100% within the selection you may increase the tollerance and search again.

If the result is <100% within the selection you can do 2 things.
You can add a point to the DTM wich will increase the accurancy alot but decreases the finding rate

You can also lower the tollerance a bit.

So sometimes its good to higher the tollerance and add a point
Sometime its just better to lower the tollerance.


You can also change the "Max search points" and the "Max colors searched"

they are conected to each other.
in the image you want to generate a DTM for are alot of colors.
It searches the image on all colors and sorts it from best to worst.
the "Max colors searched" says how many different colors may be used.
the "Max search points" says what the maximum points are.

Example:
I got 4 colors
Color1 is 40 times found
Color2 is 110 times found
Color3 is 60 times found
Color4 is 30 times found

My "Max colors searched" is set to 3
My "Max search points" is set to 100

Color1 < 100 so it will take color 2
Color1+color2 > 100 after getting all the points of color2 it wil stop taking extra points

My Max colors searched is set to 3
My Max search points is set to 400

Color1 < 400 so it will take color 2
Color1+color2 < 400 so it will take color3 also
Color1+color2+color3 < 400 but we now have 3 colors so it will stop because It reached the maximum different colors.

P.S.
The higher the "search points" is the longer the search will take.