![]() |
Hough transformation for Kreise
sieht jemand einen Bug in dieser Version der Hough Transformation für Kreise ?
Das thema Hough und Lines gabe es bereits hier : ![]()
Delphi-Quellcode:
///
/// Hough transformation for line detection /// /// /// AnalysisBitmap : TBitMap; -> the image for hough tranmsformation /// aHoughResult : THoughResult -> the result of the Hough transformation /// r : Integer; -> the search radius /// /// procedure Hough_CircleDetection ( AnalysisBitmap : TBitMap; var aHoughResult : THoughResult ; r : Integer ); var x,y, a,b : integer; ImageWidth : integer; ImageHeight : Integer; max_d : Integer; help : Real; begin /// size of hough array ImageWidth := AnalysisBitmap.Width; ImageHeight:= AnalysisBitmap.Height; // a // b SetLength(aHoughResult,ImageWidth, ImageHeight ); // For all rows in image: for y:=0 to AnalysisBitmap.Height-1 do begin // For all pixel in one row : for x:=0 to AnalysisBitmap.Width-1 do begin // Is there a point ? if IsPixel(x,y, AnalysisBitmap, 128 ) then begin // circle // r *r = ( x-a) *(x-a) + (y-b) *( y-b) for a:=0 to ImageWidth do begin // r * r := (x-a) * (x-a) + (y-b) * (y-b); // solve equation and get y ... help := r * r - (x-a) * (x-a); if ( help >= 0 ) then begin b := Round( sqrt (help) + y ) ; Inc(aHoughResult [a, b]); end; end; end; end; end; end; |
AW: Hough transformation for Kreise
Aus welcher Quelle hast du das denn umgesetzt ?
Die Houghtransformation so aus dem Kopf wird wohl keiner können .. |
AW: Hough transformation for Kreise
Kreise analog zu Linien behandelt, habe keinen Source Code incl. Akkumulator gefunden - vielleicht hat jemand schon mal das ganze in Delphi implementiert
die Kreisgleichung : r *r = (x-a) *(x-a) + (y-b) *(y-b) über alles (x,y) falls ein Pixel gefunden -> gibt es einen Kreis mit Mittelpunlkt (a,b) und Radius r, fix der die Gleichung löst .... PS: den Ganzen Code habe ich unter Sourge forge eingestellt |
AW: Hough transformation for Kreise
Ich meinte nicht irgend einen Source,
Sondern eher die Mathematische Abhandlung darüber, dass es bei den Kreisen Prinzipiell das selbe ist wie bei den Geraden war mir bewusst. Nun hast du mich auf jeden Fall neugierig genug gemacht, dass ich mich auch mal daran versuche, ich werde dann berichten.. |
AW: Hough transformation for Kreise
unter
![]() gibt eine Lösung in Java mit einem 1D acc -Array Math. wurde hier x = a + r * sin q und y=b + y * sin q gelöst, eigentlich sollte mein Code das gleiche erledigen nur habe ich mich von sin q und cos q befreit.... |
AW: Hough transformation for Kreise
Liste der Anhänge anzeigen (Anzahl: 1)
So, ich habe mal das Java Ding nach Lazarus "portiert", da ich ja kein Delphi mehr habe.
Ich habe aber extra keine LCL spezifischen Sachen benutzt. Du müsstest relativ einfach mein "gewerksel" nach Delphi portieren können. Im Zip ebenfalls die Ausgabe des Akkumulators für "basic.bmp" Die ganzen 1D Sachen sind nur weil Java ( wie alle C ähnlichen Dinge ) so bescheiden mit 2D-Arrays umgeht. Die Portierung in 2D-Arrays sollte aber kein Problem für dich darstellen. |
AW: Hough transformation for Kreise
Danke für die schnelle Hilfe, der Port in eine 2D Array analog zur Linienerkennung ist fertig.
Ich kann zwar den Akku vom TestBild reproduzieren bei vielen anderen Testbeispielen bekomme ich aber kein sinnvolles Ergebnis /// /// Hough transformation for circle detection /// /// /// AnalysisBitmap : TBitMap; -> the image for hough tranmsformation /// aHoughResult : THoughResult -> the result of the Hough transformation array of array of integer /// r : Integer; -> the search radius /// /// procedure Hough_CircleDetection ( AnalysisBitmap : TBitMap; var aHoughResult : THoughResult ; r : Integer ); var x,y, x0,y0 : integer; ImageWidth : integer; ImageHeight : Integer; max_d : Integer; help : Real; theta : Integer; max_theta : Integer; Box_LL : FPoint; Box_UR : FPoint; TestPoint : TPoint; begin /// size of hough array ImageWidth := AnalysisBitmap.Width; ImageHeight:= AnalysisBitmap.Height; /// Box_LL.X := 0; Box_UR.y := 0; Box_UR.X := ImageWidth; Box_UR.Y := ImageHeight; max_theta := 360; // a // b SetLength(aHoughResult,ImageWidth, ImageHeight ); // For all rows in image: for y:=0 to AnalysisBitmap.Height-1 do begin // For all pixel in one row : for x:=0 to AnalysisBitmap.Width-1 do begin // Is there a point ? if IsPixel(x,y, AnalysisBitmap, 128 ) then begin for theta:=0 to max_theta do begin TestPoint.x := round ( x - r * cos(theta*PI/max_theta) ); TestPoint.y := round ( y - r * sin(theta*PI/max_theta)); // if IsPointInBox( Box_LL , Box_UR, testPoint ) then Inc(aHoughResult[x,y]); if ((testPoint.x < ImageWidth) and (testPoint.x > 0 ) and (testPoint.y < ImageHeight ) and (testPoint.y > 0 ) ) then Inc(aHoughResult[TestPoint.x,TestPoint.y]); end; end; end; end; end |
AW: Hough transformation for Kreise
1. Bitte nutze Code Tags
2. ich hatte auch so meine Schwierigkeiten vernünftige Akkus zu erzeugen. Das Hauptproblem ist hierbei der Radius. Eigentlich müsstest du alle Radien, von 2 bis sqrt( sqr(image.width) + sqr(image.height))/2 testen. Und alle Ergebnisse hieraus "vereinigen". Was die Kreis Houghtransformation ein klein wenig "aufwendig macht :(. |
AW: Hough transformation for Kreise
unter
![]() die Hough circle detection für Bilder mit unbekannten Radius , der Akku gleicht meinem ersten Vorschlag, nur habe ich bisher den Fehler im ersten Akku nicht gefunden so ein 3D Integer Array für ein Bild mit 1000 x 1000 Pixel und Radius 1 ... 1000 sind 10E9 Zahlen .... in Matlab speichern sie nur die Pixel im Bild in einer AusgangsMatrix ab : totalpix = Länge (x); und dann den Hough Accu dimensioniert nach Bedarf : " Construct the Hough Matrix of 50 layers " .... val = ones(length(ind),1); val = Ones (Länge (ind), 1); data=accumarray(ind,val); data = accumarray (ind, val); .... |
AW: Hough transformation for Kreise
Damit übersteigt das ganze meinen Wissenshorizont ..
Evtl hilft dir jemand in einem Mathematiker Forum weiter. An deiner Stelle würde ich das Ding eh komplett von 0 Anfangen und dann selbst Programmieren, dann weist du auch sicher woran es hackt, wenn es hackt. Sry das ich nicht mehr weiterhelfen kann. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:26 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz