Entwickler-Ecke

Algorithmen, Optimierung und Assembler - Optimirung einer Bildanalyse


Darkpara - Fr 13.10.06 13:23
Titel: Optimirung einer Bildanalyse
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?



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


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 :)

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 - So 15.10.06 19:28

Versuch es mal so, ich weiß nicht ob es wirklich schneller wird, musst du ausprobieren.

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 - 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 - 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 - Mo 16.10.06 21:13

so, entlich zeit gehabt das ganze zu testen :) diese lösung hat gut geklappt :


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 - Mo 16.10.06 21:25

Hast du mal versucht zu shiften? Würd mich interessieren, wie sich das auswirkt.


Phantom1 - 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 - 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.


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.


Stefan.Buchholtz - 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


Darkpara - 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 - 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:

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 - 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.

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 - 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


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:

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 - Mi 18.10.06 09:59

Hi,

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


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:

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 ...

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 ...


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 [http://www.delphi-forum.de/viewtopic.php?p=394806#394806] etwas weiter oben ...


Darkpara - 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