Einzelnen Beitrag anzeigen

bernhard_LA

Registriert seit: 8. Jun 2009
Ort: Bayern
1.123 Beiträge
 
Delphi 11 Alexandria
 
#7

AW: Hough transformation for Kreise

  Alt 30. Dez 2010, 07:33
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
  Mit Zitat antworten Zitat