Autor Beitrag
Darkpara
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61

Win XP

BeitragVerfasst: Fr 13.10.06 13:23 
hallo zusammen,

ich habe mir ma eine prozedur geschrieben die mir eine sorte von pixeln raussucht zur weiterverarbeitung, nur ist das problem das das ganze im mom sehr langsam ist :( hätte wer einen kleinen tip das ganze schneller zu gestalten?


ausblenden volle Höhe Delphi-Quelltext
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:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
var
  H1, S1, L1 :double;
  RGB1 : TColor;
  matrix :array[0..640of array[0..480of array[1..5of double;



procedure TForm1.RBG_to_HLSClick(Sender: TObject);
type
 TRGBColor = record
  R,
  G,
  B: byte;
end;
var
  pData: ^TRGBColor;
  x,y:integer;
begin
  FBitmap.PixelFormat:= pf24Bit;
  for y:= 0 to FBitmap.Height-1 do begin
    pData := Fbitmap.ScanLine[y];
    for x:= 0 to FBitmap.Width-1 do begin
       RGB1:=(pData^.R)*256*256+(pData^.G)*256+(pData^.B);
       RGBtoHSL (RGB1, H1, S1, L1);
       matrix[x,y,1]:= H1 ;
       matrix[x,y,2]:= S1 ;
       matrix[x,y,3]:= L1 ;
       inc(pData);

     if (matrix[x,y,1] > strtofloat(Fparam.EC1HMin.Text)) and
        (matrix[x,y,1] < strtofloat(Fparam.EC1HMax.Text)) and
        (matrix[x,y,2] > strtofloat(Fparam.EC1SMin.Text)) and
        (matrix[x,y,2] < strtofloat(Fparam.EC1SMax.Text)) and
        (matrix[x,y,3] > strtofloat(Fparam.EC1LMin.Text)) and
        (matrix[x,y,3] < strtofloat(Fparam.EC1LMax.Text))
        then
          matrix[x,y,4] := 1
        else
          matrix[x,y,4] := 0;

     if (matrix[x,y,1] > strtofloat(Fparam.EC2HMin.Text)) and
        (matrix[x,y,1] < strtofloat(Fparam.EC2HMax.Text)) and
        (matrix[x,y,2] > strtofloat(Fparam.EC2SMin.Text)) and
        (matrix[x,y,2] < strtofloat(Fparam.EC2SMax.Text)) and
        (matrix[x,y,3] > strtofloat(Fparam.EC2LMin.Text)) and
        (matrix[x,y,3] < strtofloat(Fparam.EC2LMax.Text))
        then
          matrix[x,y,5] := 1
        else
          matrix[x,y,5] := 0;

    end;
  end;
end;

vl. gehe ich das ganze auch komplett falsch an desswegen ma mein ziel welches ich mit dem programm verfolge:
ich habe eine webcam und einen kleinen roboter den ich mit bluetooth ansteuere, die webcam soll an der decke hängen und mir die position des roboters sagen können. ich male einen blauen und einen grünen kreis auf den roboter(wenn man die 2 kreise verbindet krigt man eine linie die die richtung angibt, 2 farben damit man bestimmen kann wo vorn und wo hinten ist) zurück zum programm, also ich filtere die grünen farben raus überall wo eine grüne farbe ist kommt eine 1 in das matrix[x,y,4] sont eine 0 für blau das geliche in matrix[x,y,5] dann berechne ich die summe aller umliegenden pixel und weiss somit wo der mittelpunkt des grössten (hoffe das wird mein kreis sein) blauflecks sein wird



was schon recht gut läuft ist das RGBtoHSL aber wenns wen interesiert hier die funktion die ich mal auf dem net gefunden hatte

ausblenden volle Höhe Delphi-Quelltext
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:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
procedure TForm1.RGBtoHSL (RGB: TColor; var H, S, L : double);

  function Max (a, b : double): double;
  begin
    if a > b then
      Result := a
    else
      Result := b
  end;


  function Min (a, b : double): double;
  begin
    if a < b then
      Result := a
    else
      Result := b
  end;


var
  R,
  G,
  B,
  D,
  Cmax,
  Cmin: double;


begin
  R := GetRValue (RGB) / 255;
  G := GetGValue (RGB) / 255;
  B := GetBValue (RGB) / 255;
  Cmax := Max (R, Max (G, B));
  Cmin := Min (R, Min (G, B));


// calculate luminosity
  L := (Cmax + Cmin) / 2;


  if Cmax = Cmin then  // it's grey
  begin
    H := 0// it's actually undefined
    S := 0
  end else begin
    D := Cmax - Cmin;


// calculate Saturation
    if L < 0.5 then
      S := D / (Cmax + Cmin)
    else
      S := D / (2 - Cmax - Cmin);


// calculate Hue
    if R = Cmax then
      H := (G - B) / D
    else
      if G = Cmax then
        H  := 2 + (B - R) /D
      else
        H := 4 + (R - G) / D;


    H := H / 6;
    if H < 0 then
      H := H + 1
  end
end;


EDIT:
was ich noch sagen kann: der teil der am meisten zeit inanspruch nimmt (1-2sekunden was inakzeptabel ist) sind die 2 if's, ohne die geht es sehr rasch also weniger als 200ms was schon eher akzeptabel is :)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
     if (matrix[x,y,1] > strtofloat(Fparam.EC1HMin.Text)) and
        (matrix[x,y,1] < strtofloat(Fparam.EC1HMax.Text)) and
        (matrix[x,y,2] > strtofloat(Fparam.EC1SMin.Text)) and
        (matrix[x,y,2] < strtofloat(Fparam.EC1SMax.Text)) and
        (matrix[x,y,3] > strtofloat(Fparam.EC1LMin.Text)) and
        (matrix[x,y,3] < strtofloat(Fparam.EC1LMax.Text))
        then
          matrix[x,y,4] := 1
        else
          matrix[x,y,4] := 0;
   
     if (matrix[x,y,1] > strtofloat(Fparam.EC2HMin.Text)) and
        (matrix[x,y,1] < strtofloat(Fparam.EC2HMax.Text)) and
        (matrix[x,y,2] > strtofloat(Fparam.EC2SMin.Text)) and
        (matrix[x,y,2] < strtofloat(Fparam.EC2SMax.Text)) and
        (matrix[x,y,3] > strtofloat(Fparam.EC2LMin.Text)) and
        (matrix[x,y,3] < strtofloat(Fparam.EC2LMax.Text))
        then
          matrix[x,y,5] := 1
        else
          matrix[x,y,5] := 0;
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: So 15.10.06 19:28 
Versuch es mal so, ich weiß nicht ob es wirklich schneller wird, musst du ausprobieren.
ausblenden volle Höhe Delphi-Quelltext
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:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
var  
  H1, S1, L1: Single;  
  RGB1: TColor;  
  matrix: array[0..640of array[0..480of array[1..5of Single;  

procedure TForm1.RBG_to_HLSClick(Sender: TObject);  
type  
  TRGBColor = record
    R, G, B: Byte;  
  end;  
var  
  pData: ^TRGBColor;  
  x, y : Integer;
  EC1HMin, EC1HMax, EC1SMin, EC1SMax, EC1LMin, EC1LMax,
  EC2HMin, EC2HMax, EC2SMin, EC2SMax, EC2LMin, EC2LMax: Single;  
begin  
  ECI1HMin := StrToFloat(FParam.EC1HMin.Text);
  ECI1HMax := StrToFloat(FParam.EC1HMax.Text);
  ECI1SMin := StrToFloat(FParam.EC1SMin.Text);
  ECI1SMax := StrToFloat(FParam.EC1SMax.Text);
  ECI1LMin := StrToFloat(FParam.EC1LMin.Text);
  ECI1LMax := StrToFloat(FParam.EC1LMax.Text);
  ECI2HMin := StrToFloat(FParam.EC2HMin.Text);
  ECI2HMax := StrToFloat(FParam.EC2HMax.Text);
  ECI2SMin := StrToFloat(FParam.EC2SMin.Text);
  ECI2SMax := StrToFloat(FParam.EC2SMax.Text);
  ECI2LMin := StrToFloat(FParam.EC2LMin.Text);
  ECI2LMax := StrToFloat(FParam.EC2LMax.Text);
  FBitmap.PixelFormat := pf24Bit;  
  for y := 0 to FBitmap.Height - 1 do 
  begin  
    pData := FBitmap.ScanLine[y];  
    for x := 0 to FBitmap.Width - 1 do
    begin  
       RGB1 := (pData^.R)*256*256 + (pData^.G)*256 + (pData^.B);  
       RGBtoHSL(RGB1, H1, S1, L1);  
       matrix[x, y, 1]:= H1;  
       matrix[x, y, 2]:= S1;  
       matrix[x, y, 3]:= L1;  
       inc(pData);  
       if (matrix[x, y, 1] > EC1HMin) and  
          (matrix[x, y, 1] < EC1HMax) and  
          (matrix[x, y, 2] > EC1SMin) and  
          (matrix[x, y, 2] < EC1SMax) and  
          (matrix[x, y, 3] > EC1LMin) and  
          (matrix[x, y, 3] < EC1LMax) then  
         matrix[x, y, 4] := 1  
       else  
         matrix[x, y, 4] := 0;  
       if (matrix[x, y, 1] > EC2HMin) and  
          (matrix[x, y, 1] < EC2HMax) and  
          (matrix[x, y, 2] > EC2SMin) and  
          (matrix[x, y, 2] < EC2SMax) and  
          (matrix[x, y, 3] > EC2LMin) and  
          (matrix[x, y, 3] < EC2LMax) then  
         matrix[x, y, 5] := 1  
       else  
         matrix[x, y, 5] := 0
    end;  
  end;  
end;
Allesquarks
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 510

Win XP Prof
Delphi 7 E
BeitragVerfasst: So 15.10.06 23:28 
Multiplikationen mit 2er Potenzen kann man auch mit shiftleft etc realisieren. Der Delphi Compiler optimiert das glaube ich nicht.
Darkpara Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61

Win XP

BeitragVerfasst: So 15.10.06 23:41 
danke für die antworten @Chryzler werd ich gelich ma ausprobiern
und wegen shiftleft, werd ich machen, wobei es wirklich der teil mit den 2 if abfragen is der die 1-2sekunden pro bild in anspruch nimmt :(
Darkpara Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61

Win XP

BeitragVerfasst: Mo 16.10.06 21:13 
so, entlich zeit gehabt das ganze zu testen :) diese lösung hat gut geklappt :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
  ECI1HMin := StrToFloat(FParam.EC1HMin.Text);
  ECI1HMax := StrToFloat(FParam.EC1HMax.Text);
  ECI1SMin := StrToFloat(FParam.EC1SMin.Text);
  ECI1SMax := StrToFloat(FParam.EC1SMax.Text);
  ECI1LMin := StrToFloat(FParam.EC1LMin.Text);
  ECI1LMax := StrToFloat(FParam.EC1LMax.Text);
  ECI2HMin := StrToFloat(FParam.EC2HMin.Text);
  ECI2HMax := StrToFloat(FParam.EC2HMax.Text);
  ECI2SMin := StrToFloat(FParam.EC2SMin.Text);
  ECI2SMax := StrToFloat(FParam.EC2SMax.Text);
  ECI2LMin := StrToFloat(FParam.EC2LMin.Text);
  ECI2LMax := StrToFloat(FParam.EC2LMax.Text);


brauch nun noch etwa 200ms was ok ist danke euch :)
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Mo 16.10.06 21:25 
Hast du mal versucht zu shiften? Würd mich interessieren, wie sich das auswirkt.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Phantom1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 390



BeitragVerfasst: Di 17.10.06 00:09 
Die Farbtiefe auf 32bit erhöhen dürfte auch schneller sein, geht jedoch auf kosten des speichers.

mfg
Stefan.Buchholtz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 612

WIN 2000, WIN XP, Mac OS X
D7 Enterprise, XCode, Eclipse, Ruby On Rails
BeitragVerfasst: Di 17.10.06 10:01 
Ich würde die RGBtoHSL-Funktion noch so ändern, dass sie die RGB-Werte einzeln übergeben bekommt. Im Moment baust du aus einem Pixel der Bitmap einen TColor-Wert zusammen, den RGBtoHSL wieder in die einzelnen Farbkomponenten zerlegt.
Die Funktionen Max und Min kannst du dir auch sparen, sie sind in der Unit Math enthalten.

ausblenden volle Höhe Delphi-Quelltext
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:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
procedure TForm1.RGBtoHSL (const red, green, blue: Byte; out H, S, L : Single);  
var  
  R,  
  G,  
  B,  
  D,  
  Cmax,  
  Cmin: Single;  
begin  
  R := red / 255;  
  G := green / 255;  
  B := blue / 255;  
  Cmax := Max (R, Max (G, B));  
  Cmin := Min (R, Min (G, B));  
 
  // calculate luminosity  
  L := (Cmax + Cmin) / 2;  
 
  if Cmax = Cmin then  // it's grey  
  begin  
    H := 0// it's actually undefined  
    S := 0  
  end 
  else 
  begin  
    D := Cmax - Cmin;  
 
    // calculate Saturation  
    if L < 0.5 then  
      S := D / (Cmax + Cmin)  
    else  
      S := D / (2 - Cmax - Cmin);  
 
    // calculate Hue  
    if R = Cmax then  
      H := (G - B) / D  
    else  
      if G = Cmax then  
        H  := 2 + (B - R) /D  
      else  
        H := 4 + (R - G) / D;  
 
    H := H / 6;  
    if H < 0 then  
      H := H + 1  
  end  
end;


Meiner Meinung nach kannst du bei Farbwerten auch überall mit Singles statt Doubles arbeiten, ein Farbkanal hat ja nur 8 Bit Genauigkeit - Doubles sind da unnötig. Ich bin aber nicht sicher, ob Delphi bei Singles auch tatsächlich schneller rechnet - das müsstest du wohl testen.

_________________
Ein Computer ohne Windows ist wie eine Schokoladentorte ohne Senf.
Stefan.Buchholtz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 612

WIN 2000, WIN XP, Mac OS X
D7 Enterprise, XCode, Eclipse, Ruby On Rails
BeitragVerfasst: Di 17.10.06 10:17 
Noch was: machst du mit den berechneten HSL-Werten nach der Schleife noch was oder wertest du dann nur noch matrix[x,y,4] und matrix[x,y,5] aus? Nach deiner Beschreibung des Algorithmus werden nach der Schleife die HSL-Werte nich mehr benötigt - du brauchst sie also nicht in deiner Matrix zu speichern, sondern kannst einfach mit lokalen Variablen arbeiten. Das bringt in mehrerer Hinsicht was: Zugriffe auf lokale Variablen sind schneller als auf Array-Elemente und du brauchst weniger Speicher - ein grösserer Teil von matrix passt in den Prozessor-Cache, was vergleichsweise langsame Speicherzugriffe vermeidet.

Stefan

_________________
Ein Computer ohne Windows ist wie eine Schokoladentorte ohne Senf.
Darkpara Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61

Win XP

BeitragVerfasst: Di 17.10.06 10:56 
hm, stimmt, werd ich dann bei der end version korigieren, ist manchma ganz praktisch zum nachschauen ob die werte wirklich stimmen :)
Phantom1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 390



BeitragVerfasst: Di 17.10.06 16:11 
Bei dem TRGBColor record solltest du aufpassen, die daten werden immer BGR und nicht RGB gespeichert.

Ich hab das mal korrigiert und noch ein paar Verbesserungen vorgenommen:
ausblenden volle Höhe Delphi-Quelltext
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:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
var
  matrix: array[0..6400..480of (cNone, cGreen, cBlue);

procedure TForm1.RBG_to_HLSClick(Sender: TObject);
type
  TRGBColor = packed record
    B, G, R, A: Byte;
  end;
var
  pData: ^TRGBColor;
  H, S, L: Single;
  x, y : Integer;
  EC1HMin, EC1HMax, EC1SMin, EC1SMax, EC1LMin, EC1LMax,
  EC2HMin, EC2HMax, EC2SMin, EC2SMax, EC2LMin, EC2LMax: Single;
begin
  ECI1HMin := StrToFloat(FParam.EC1HMin.Text);
  ECI1HMax := StrToFloat(FParam.EC1HMax.Text);
  ECI1SMin := StrToFloat(FParam.EC1SMin.Text);
  ECI1SMax := StrToFloat(FParam.EC1SMax.Text);
  ECI1LMin := StrToFloat(FParam.EC1LMin.Text);
  ECI1LMax := StrToFloat(FParam.EC1LMax.Text);
  ECI2HMin := StrToFloat(FParam.EC2HMin.Text);
  ECI2HMax := StrToFloat(FParam.EC2HMax.Text);
  ECI2SMin := StrToFloat(FParam.EC2SMin.Text);
  ECI2SMax := StrToFloat(FParam.EC2SMax.Text);
  ECI2LMin := StrToFloat(FParam.EC2LMin.Text);
  ECI2LMax := StrToFloat(FParam.EC2LMax.Text);
  FBitmap.PixelFormat := pf32Bit;
  for y := 0 to FBitmap.Height - 1 do
  begin
    pData := FBitmap.ScanLine[y];
    for x := 0 to FBitmap.Width - 1 do
    begin
      RGBtoHSL(pData^.R, pData^.G, pData^.B, H, S, L);
      if (H > EC1HMin) and (H < EC1HMax) and
         (S > EC1SMin) and (S < EC1SMax) and
         (L > EC1LMin) and (L < EC1LMax) then
        matrix[x, y] := cGreen
      else
        if (H > EC2HMin) and (H < EC2HMax) and
           (S > EC2SMin) and (S < EC2SMax) and
           (L > EC2LMin) and (L < EC2LMax) then
          matrix[x, y] := cBlue
        else
          matrix[x, y] := cNone;
      inc(pData);
    end;
  end;
end;


mfg
Horst_H
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1654
Erhaltene Danke: 244

WIN10,PuppyLinux
FreePascal,Lazarus
BeitragVerfasst: Di 17.10.06 18:31 
Hallo,

nur so am Rande. Multiplizieren mit dem Kehrwert ist bei Konstanten einfach viel schneller.
Das sparte 25% also statt 2 nur 1,5 Sekunden fuer alle RGB to HSL.
(2^24=16,2?? Mio->10 Mio Umwandlungen in der Sekunde, dann betraegt der Anteil an Deiner Rechnung ~30ms spart also nur 10 ms )
Überraschenderweise machte sich der Übergang auf double sehr stark bemerkbar.Es war dann 40% langsamer.
ausblenden volle Höhe Delphi-Quelltext
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:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
const 
  rez255= 1/255;
  rez6  = 1/6;
....
procedure TForm1.RGBtoHSL (const red, green, blue: Byte; out H, S, L : Single);   
var   
  R,   
  G,   
  B,   
  D,   
  Cmax,   
  Cmin: Single;   
begin   
  R := red * rez255;   
  G := green * rez255;  
  B := blue * rez255;  
  Cmax := Max (R, Max (G, B));   
  Cmin := Min (R, Min (G, B));   
  
  // calculate luminosity   
  L := (Cmax + Cmin) * 0.5;   
  
  if Cmax = Cmin then  // it's grey   
  begin   
    H := 0.0// it's actually undefined   
    S := 0.0   
  end  
  else  
  begin   
    D := Cmax - Cmin;   
  
    // calculate Saturation   
    if L < 0.5 then   
      S := D / (Cmax + Cmin)   
    else   
      S := D / (2.0 - Cmax - Cmin);   
  
    // calculate Hue   
    if R = Cmax then   
      H := (G - B) / D   
    else   
      if G = Cmax then   
        H  := 2.0 + (B - R) /D   
      else   
        H := 4.0 + (R - G) / D;   
  
    H := H * rez6;   
    if H < 0.0 then   
      H := H + 1.0   
  end   
end;


Gruss Horst
Allesquarks
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 510

Win XP Prof
Delphi 7 E
BeitragVerfasst: Di 17.10.06 19:00 
Falls es wirklich essentiell ist, dass es schneller wird, bietet sich in deinem Fall wohl auch SSE an!

Nebenbei weiß jetzt nicht, ob es schon gesagt wurde aber

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
 if (matrix[x,y,1] > strtofloat(Fparam.EC1HMin.Text)) and
        (matrix[x,y,1] < strtofloat(Fparam.EC1HMax.Text)) and
        (matrix[x,y,2] > strtofloat(Fparam.EC1SMin.Text)) and
        (matrix[x,y,2] < strtofloat(Fparam.EC1SMax.Text)) and
        (matrix[x,y,3] > strtofloat(Fparam.EC1LMin.Text)) and
        (matrix[x,y,3] < strtofloat(Fparam.EC1LMax.Text))
        then
          matrix[x,y,4] := 1
        else
          matrix[x,y,4] := 0;


müsste man auch direkt als Aussage schreiben können:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
matrix[x,y,4] := (matrix[x,y,1] > strtofloat(Fparam.EC1HMin.Text)) and
        (matrix[x,y,1] < strtofloat(Fparam.EC1HMax.Text)) and
        (matrix[x,y,2] > strtofloat(Fparam.EC1SMin.Text)) and
        (matrix[x,y,2] < strtofloat(Fparam.EC1SMax.Text)) and
        (matrix[x,y,3] > strtofloat(Fparam.EC1LMin.Text)) and
        (matrix[x,y,3] < strtofloat(Fparam.EC1LMax.Text))
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 18.10.06 09:59 
Hi,

user profile iconAllesquarks hat folgendes geschrieben:
Nebenbei weiß jetzt nicht, ob es schon gesagt wurde aber

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
 if (matrix[x,y,1] > strtofloat(Fparam.EC1HMin.Text)) and
        (matrix[x,y,1] < strtofloat(Fparam.EC1HMax.Text)) and
        (matrix[x,y,2] > strtofloat(Fparam.EC1SMin.Text)) and
        (matrix[x,y,2] < strtofloat(Fparam.EC1SMax.Text)) and
        (matrix[x,y,3] > strtofloat(Fparam.EC1LMin.Text)) and
        (matrix[x,y,3] < strtofloat(Fparam.EC1LMax.Text))
        then
          matrix[x,y,4] := 1
        else
          matrix[x,y,4] := 0;


müsste man auch direkt als Aussage schreiben können:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
matrix[x,y,4] := (matrix[x,y,1] > strtofloat(Fparam.EC1HMin.Text)) and
        (matrix[x,y,1] < strtofloat(Fparam.EC1HMax.Text)) and
        (matrix[x,y,2] > strtofloat(Fparam.EC1SMin.Text)) and
        (matrix[x,y,2] < strtofloat(Fparam.EC1SMax.Text)) and
        (matrix[x,y,3] > strtofloat(Fparam.EC1LMin.Text)) and
        (matrix[x,y,3] < strtofloat(Fparam.EC1LMax.Text))


Nicht ganz ...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
matrix[x,y,4] := Ord((matrix[x,y,1] > strtofloat(Fparam.EC1HMin.Text)) and
        (matrix[x,y,1] < strtofloat(Fparam.EC1HMax.Text)) and
        (matrix[x,y,2] > strtofloat(Fparam.EC1SMin.Text)) and
        (matrix[x,y,2] < strtofloat(Fparam.EC1SMax.Text)) and
        (matrix[x,y,3] > strtofloat(Fparam.EC1LMin.Text)) and
        (matrix[x,y,3] < strtofloat(Fparam.EC1LMax.Text)));


Ferner sollte man aber auch die StrToFloat aus der Schleife entfernen, da sich der Wert ja nicht mehr ändert ...

Wie das dann aussähe, wurde oben bereits gezeigt ...

ausblenden Delphi-Quelltext
1:
2:
3:
matrix[x, y] := Ord((H > EC2HMin) and (H < EC2HMax) and
           (S > EC2SMin) and (S < EC2SMax) and
           (L > EC2LMin) and (L < EC2LMax));


Ansonsten schau mal in diesem Post etwas weiter oben ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.


Zuletzt bearbeitet von BenBE am Do 19.10.06 21:44, insgesamt 1-mal bearbeitet
Darkpara Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 61

Win XP

BeitragVerfasst: Do 19.10.06 15:52 
grml, da ist man paar tage ned im forum und hat scho unzählige sachen zu verbessern, ich meld mich sobald ich mit den obrigen vorschlägen durch bin danke euch :) werde dann den aktualisierten code ma posten