LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::fastCircleExtraction Class Reference

This functor implements a fast circle extraction using the line segments found in digital images. More...

#include <ltiFastCircleExtraction.h>

Inheritance diagram for lti::fastCircleExtraction:
Inheritance graph
[legend]
Collaboration diagram for lti::fastCircleExtraction:
Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 the parameters for the class fastCircleExtraction More...

Public Member Functions

 fastCircleExtraction ()
 fastCircleExtraction (const parameters &par)
 fastCircleExtraction (const fastCircleExtraction &other)
virtual ~fastCircleExtraction ()
virtual const char * getTypeName () const
bool apply (const channel8 &srcdest)
bool apply (const channel &srcdest)
fastCircleExtractioncopy (const fastCircleExtraction &other)
fastCircleExtractionoperator= (const fastCircleExtraction &other)
virtual functorclone () const
const parametersgetParameters () const
virtual std::vector< segmEntry > & getSegmentList (const int group_number)
virtual std::vector< lineEntry > & getLineList (const int group_number)
virtual std::vector< arcEntry > & getArcList (const int group_number)
virtual std::vector
< extArcEntry > & 
getExtArcList (const int group_number)
virtual std::vector
< circleEntry > & 
getCircleList ()

Detailed Description

This functor implements a fast circle extraction using the line segments found in digital images.

To achieve this, the lines of an image are extracted by a fast line extraction. The edge lines of circles are filtered by several checks. In further passes these lines are combined to arcs, adjacent arcs are combined to extended arcs which at last are used to extract circles.

The fastCircleExtraction::parameters specify several ranges and conditions that the lines and arcs must fulfill. The result strongly depends on these parameters, especially the number and the precision of the extracted circles.

The extracted arcs and circles are stored in STL vector containers of the types <arcEntry>, <extArcEntry> and <circleEntry>. They can be accessed by the methods getArcList(), getExtArcList and getCircleList().

arcEntry is the data struct for arcs:

 struct arcEntry
 {
   ipoint  start;    // start point
   ipoint  end;      // end point
   ipoint  mid;      // midpoint 
   int     r2;       // length or squared radius
   ipoint  firstVec; // first line vector                 
   ipoint  lastVec;  // last line vector                  
   int     used;     // counts arc<->extarc assignments
   int     group;    // base line group (1,2,3 or 4)
   std::vector<int> *lineIdxList;  // base line index list
 };

extArcEntry is the data struct for extended arcs:

 struct extArcEntry
 {
   ipoint  start;     // start point
   ipoint  end;       // end point
   ipoint  mid;       // circle midpoint 
   int     r2;        // squared radius
   ipoint  firstMid;  // midpoint of the first segment
   double  firstTang; // tangent of the first segment
   ipoint  lastMid;   // midpoint of the last segment
   double  lastTang;  // tangent of the last segment
   int     used;      // counts extarc<->circle assignments
   int     group;     // ext arc group (1,2,3 or 4)
   int     arcIdxA;   // 1st base arc index (groups I:1, II:3, III:2, IV:4)
   int     arcIdxB;   // 2nd base arc index (groups I:3, II:2, III:4, IV:1)
 };

circleEntry is the data struct for circles:

struct circleEntry
 {
   ipoint center;     // circle center
   int    radius;     // circle radius
   double coverage;   // circle coverage (accuracy strongly depends on radius and other effects)
 };

The fast circle extraction does not perform any changes to the analyzed image. To visualize the extracted circles they have to be drawn by other code using the circle lists and a drawing functor.

Example:

 #include "ltiViewer.h"               // visualization tool
 #include "ltiDraw.h"                 // drawing tool
 #include "ltiALLfunctor.h"           // image loader
 #include "ltiCannyEdges.h"           // edge detector
 #include "ltiFastCircleExtraction.h" // circle detector
 
 // ...
 
 lti::image inputImg;
 lti::channel8 edges;
 lti::channel8 result;
 
 // load image
 lti::loadImage loader;
 loader.load("myImage.bmp", inputImg);
 
 // we need the edges
 lti::cannyEdges canny;
 canny.apply(inputImg, edges);
 
 // create FCE functor (using default parameters)
 lti::fastCircleExtraction fce;
 
 // extract some circles
 fce.apply(edges);
 
 // get the circle list
 std::vector<lti::fastCircleExtraction::circleEntry> &circles = fce.getCircleList();
 
 // create a drawing functor
 lti::draw<lti::channel8::value_type> drawer;
 drawer.use(result);
 drawer.setColor(255);
 
 // create background with grey edges
 result = edges;
 result /= 2;
 
 for(int i=0; i<circles.size(); i++) {
   // draw all circles
    drawer.circle(circles[i].center.x, circles[i].center.y, circles[i].radius, false);
   // print circle data
   printf("circle[%i]: center=(%i,%i) radius=%i coverage=%.1f%% \n",
          i, circles[i].center.x, circles[i].center.y, circles[i].radius, circles[i].coverage*100);
 }
 
 // show the extracted circles
 lti::viewer view("Detected circles");
 view.show(result);

 // wait for a mouse click in the viewer window
 view.waitButtonPressed();

Constructor & Destructor Documentation

lti::fastCircleExtraction::fastCircleExtraction (  ) 

default constructor

lti::fastCircleExtraction::fastCircleExtraction ( const parameters par  ) 

Construct a functor using the given parameters.

lti::fastCircleExtraction::fastCircleExtraction ( const fastCircleExtraction other  ) 

copy constructor

Parameters:
other the object to be copied
virtual lti::fastCircleExtraction::~fastCircleExtraction (  )  [virtual]

destructor


Member Function Documentation

bool lti::fastCircleExtraction::apply ( const channel srcdest  ) 

Applies fast circle detection on-place.

Parameters:
srcdest channel with the source data.
Returns:
true if apply was successful or false otherwise.
bool lti::fastCircleExtraction::apply ( const channel8 srcdest  ) 

Applies fast circle detection on-place.

Parameters:
srcdest channel8 with the source data.
Returns:
true if apply was successful or false otherwise.
virtual functor* lti::fastCircleExtraction::clone (  )  const [virtual]

returns a pointer to a clone of this functor.

Reimplemented from lti::featureExtractor.

fastCircleExtraction& lti::fastCircleExtraction::copy ( const fastCircleExtraction other  ) 

copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::featureExtractor.

virtual std::vector<arcEntry>& lti::fastCircleExtraction::getArcList ( const int  group_number  )  [virtual]

returns a vector with arcs of the specified group

Parameters:
group_number number of the arc group (1,2,3,4, or 0 for all arcs)
Returns:
vector with extracted arcs
virtual std::vector<circleEntry>& lti::fastCircleExtraction::getCircleList (  )  [virtual]

returns a vector with extracted circles.

Returns:
vector with extracted circles
virtual std::vector<extArcEntry>& lti::fastCircleExtraction::getExtArcList ( const int  group_number  )  [virtual]

returns a vector with extended arcs of the specified group

Parameters:
group_number number of the arc group (1,2,3,4, or 0 for all arcs)
Returns:
vector with extracted extended arcs
virtual std::vector<lineEntry>& lti::fastCircleExtraction::getLineList ( const int  group_number  )  [virtual]

returns a vector with lines of the specified group

Parameters:
group_number number of the line group (1,2,3,4, or 0 for all lines)
Returns:
vector with extracted lines
const parameters& lti::fastCircleExtraction::getParameters (  )  const

returns used parameters

Reimplemented from lti::featureExtractor.

virtual std::vector<segmEntry>& lti::fastCircleExtraction::getSegmentList ( const int  group_number  )  [virtual]

returns a vector with line segments of the specified group

Parameters:
group_number number of the line segment group (1,2,3,4)
Returns:
vector with detected line segments
virtual const char* lti::fastCircleExtraction::getTypeName (  )  const [virtual]

returns the name of this type ("fastCircleExtraction")

Reimplemented from lti::featureExtractor.

fastCircleExtraction& lti::fastCircleExtraction::operator= ( const fastCircleExtraction other  ) 

alias for copy member

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::functor.


The documentation for this class was generated from the following file:

Generated on Sat Apr 10 15:27:17 2010 for LTI-Lib by Doxygen 1.6.1