Thema: Delphi Objektverfolgung

Einzelnen Beitrag anzeigen

Funk

Registriert seit: 24. Feb 2006
11 Beiträge
 
#11

Re: Objektverfolgung

  Alt 18. Mär 2006, 15:38
Hallo,
habe jetzt ein kleines Programm geschrieben, wo ich mein Bild in 4 Flächen aufteile und jeweils von der Fläche den mittleren Grauwert errechne. Doch ich bekomme nicht die gewünschte Werte heraus.
Delphi-Quellcode:
procedure TForm1.GrauwertClick(Sender: TObject);
var
a,b,c,d,x,y,Grauwert1,Grauwert2,Grauwert3,Grauwert4:integer;
G: PByteArray;
begin
Grauwert1:=0; Grauwert2:=0; Grauwert3:=0; Grauwert4:=0;
a:=TestImage.Picture.Bitmap.Width;
b:=TestImage.Picture.Bitmap.Height;
c:= round(TestImage.Picture.Bitmap.Width/2);
d:= round(TestImage.Picture.Bitmap.Height/2);

 for y := 0 to d do
  begin
     G := TestImage.Picture.Bitmap.ScanLine[y];
     for x := 0 to c do
    begin
      Grauwert1:=Grauwert1+G[x];
    end;
     for x := c to a -1 do
    begin
      Grauwert2:=Grauwert2+G[x];
    end;
 end;
 for y := d to b-1 do
  begin
  G := TestImage.Picture.Bitmap.ScanLine[y];
     for x := 0 to c do
    begin
      Grauwert3:=Grauwert3 + G[x];
    end;
     for x:= c +1 to a -1 do
    begin
      Grauwert4:=Grauwert4+G[x];
    end;
 end;
  Form1.Label1.Caption:=floattostr(Grauwert1 div (d * c));
  Form1.Label2.Caption:=floattostr(Grauwert2 div (d * c));
  Form1.Label3.Caption:=floattostr(Grauwert3 div (d * c));
  Form1.Label4.Caption:=floattostr(Grauwert4 div (d * c));
end;
Bekomme nur ein richtiges Ergebnis, wenn das Objekt unten-links oder oben-Links positioniert ist.
Sobald das Objkt nach rechts verschoben wird bekomme ich falsche Werte!
Was mache ich falsch?
Meine Idee ist das ich die Veränderungen des mittleren Grauwerts der einzelnen Flächen vergleiche, und somit Auswertungen treffe.
  Mit Zitat antworten Zitat