Thema: Delphi Vektorisierung

Einzelnen Beitrag anzeigen

blender

Registriert seit: 25. Feb 2008
95 Beiträge
 
Delphi 7 Personal
 
#5

Re: Vektorisierung

  Alt 21. Okt 2008, 13:42
Ich habe einen Hough Transformation Algorithmus gefunden und ihn meinem Code angepasst.
Nur: Was ist denn nach der Ausführung in dem "hougharray"?
Ich bin erst in der 9. Klasse und habe daher keine Ahnung was diese Formeln bedeuten.
(Nicht dass ich die Lehrer noch nicht gefragt hätte, aber die Antwort ist immer "Warte noch ein paar Jahre")

Delphi-Quellcode:
function IsPoint(x,y,region:integer):boolean;
begin
result := (Regions.Values[x][y] = region) and (regions.rand[x][y] = 'Ja');
end;

procedure GetLines(Region: Integer);
var x,y,theta: integer;
    r: Extended;
    HoughArray:Array of array of integer;
begin
SetLength(hougharray,360,round(Sqrt(form1.Image1.Height*form1.Image1.Height + form1.Image1.Width*form1.Image1.Width)));

// For all rows in image.
for y:=0 to form1.Image1.Height-1 do
begin

   // For all pixel in one row.
   for x:=0 to form1.Image1.Width-1 do
   begin

      // Is there a point there or not. If not, just skip the pixel.
      if IsPoint(x,y, region) then
      begin
           // Now you need to iterate for one of the unknown variables,
           // theta, to be able to determine the other unknown, r.
           for theta:=0 to 359 do
           begin
                r:=x*cos(theta*PI/360) + y*sin(theta*PI/360);

                // Plot the finding (theta,r) into an array.
                // Ignore negative values... trust me... its ok!
                if r>=0 then Inc(HoughArray[theta,round(r)]);
           end;
      end;
   end;
end;

end;
Edit:

Delphi-Quellcode:
procedure TForm1.Button6Click(Sender: TObject);
var x,y,i: Integer;
begin

for x := 0 to high(Regions.Values) do
 begin

  for y := 0 to high(Regions.Values[x]) do
   begin

   if (x > 0) and (y > 0) and (x < high(Regions.Values)) and (y < high(Regions.Values[x])) then
    begin

    if (regions.Values[x][y] <>
 regions.values[x,y-1])or(regions.Values[x][y] <>
 regions.values[x+1,y])or(regions.Values[x][y] <>
 regions.values[x-1,y])or(regions.Values[x][y] <>
 regions.values[x,y+1]) then regions.Rand[x][y] := 'Jaelse regions.Rand[x][y] := 'Nein';

    end
   else
    begin
    regions.Rand[x][y] := 'Ja';
    end;


   end;

 end;

end;
Ich habe vergessen, die Rand-Ermittlungs Prozedur zu posten.

edit 2

Anhang hinzugefügt.

Hinweis:

Der Hough Algorithmus gibt nichts für den Benutzer sichtbares zurück und tut eigentlich gar nichts außer Zählen, wenn nicht vorher Region Growing und Regionenränder ausgeführt worden ist.
Regionenränder und Kantenglättung mit Region haben keine Auswirkungen, wenn nicht vorher Region Growing durchgeführt wurde.
Bei verändern der Formulargröße werden viele Werte zurückgesetzt.
Angehängte Dateien
Dateityp: exe project1_444.exe (553,5 KB, 15x aufgerufen)
  Mit Zitat antworten Zitat