Einzelnen Beitrag anzeigen

bernhard_LA

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

Hough transformation for Kreise

  Alt 24. Dez 2010, 16:02
sieht jemand einen Bug in dieser Version der Hough Transformation für Kreise ?
Das thema Hough und Lines gabe es bereits hier : http://www.delphipraxis.net/156893-h...formation.html



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;

Geändert von mkinzler (26. Dez 2010 um 10:48 Uhr) Grund: Delphi-Tag eingefügt
  Mit Zitat antworten Zitat