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

lti::fastEllipseExtraction Class Reference

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

#include <ltiFastEllipseExtraction.h>

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

List of all members.

Classes

class  parameters
 the parameters for the class fastEllipseExtraction More...

Public Member Functions

 fastEllipseExtraction ()
 fastEllipseExtraction (const parameters &par)
 fastEllipseExtraction (const fastEllipseExtraction &other)
virtual ~fastEllipseExtraction ()
virtual const char * getTypeName () const
bool apply (const channel8 &srcdest)
bool apply (const channel &srcdest)
fastEllipseExtractioncopy (const fastEllipseExtraction &other)
fastEllipseExtractionoperator= (const fastEllipseExtraction &other)
virtual functorclone () const
const parametersgetParameters () const
virtual std::vector< segmEntry > & getSegmentList (const int groupNumber)
virtual std::vector< lineEntry > & getLineList (const int groupNumber)
virtual std::vector
< ellArcEntry > & 
getEllArcList (const int groupNumber)
virtual std::vector
< ellExtArcEntry > & 
getEllExtArcList (const int groupNumber)
virtual std::vector
< ellipseEntry > & 
getEllipseList ()

Detailed Description

This functor implements a fast ellipse 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 ellipses 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 ellipses.

The fastEllipseExtraction::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 ellipses.

The extracted arcs and ellipses are stored in STL vector containers of the types <ellArcEntry>, <ellExtArcEntry> and <ellipseEntry>. They can be accessed by the methods getEllArcList(), getEllExtArcList and getEllipseList().

ellArcEntry is the data struct for elliptic arcs:

 struct ellArcEntry
 {
   ipoint  start;    // start point                       
   ipoint  end;      // end point                         
   ipoint  mid;      // estimated circle midpoint         
   int     r2;       // estimated 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
 };

ellExtArcEntry is the data struct for elliptic extended arcs:

 struct ellExtArcEntry
 {
   double  x,y;      // estimated ellipse center           
   double  a,b;      // estimated ellipse semi-axis        
   double  t;        // estimated ellipse orientation angle                  
   double  ix, iy;   // intersection point of end tangents 
   double  slopeLB;  // slope of line beam                 
   int     used;     // counts extarc<->ellipse assignments
   int     group;    // group of 2nd base arc                   
   int     arcIdx[3];// base arc indices                    
 };

ellipseEntry is the data struct for ellipses:

struct ellipseEntry
 {
   double  x,y;      // estimated ellipse center   
   double  a,b;      // estimated ellipse semi-axis
   double  t;        // estimated ellipse orientation angle
   double  coverage; // ellipse coverage (accuracy 
   std::vector<int> *mergedArcs;  // arc index list
 };

The fast ellipse extraction does not perform any changes to the analyzed image. To visualize the extracted ellipses they have to be drawn by other code using the ellipse 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 "ltiFastEllipseExtraction.h" // ellipse 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 FEE functor (using default parameters)
 lti::fastEllipseExtraction fee;
 
 // extract some ellipses
 fee.apply(edges);
 
 // get the ellipse list
 std::vector<lti::fastEllipseExtraction::ellipseEntry> &ellipses = fee.getEllipseList();
 
 // 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<ellipses.size(); i++) {
   // draw ellipse
   lti::point center((int)ellipses[i].x, (int)ellipses[i].y);
   drawer.ellipse(center, (int)ellipses[i].b, (int)ellipses[i].a, ellipses[i].t, false);
   // print ellipse data
   printf("ellipse[%i]: center=(%.0f,%.0f) semiaxis=(%.0f,%.0f) angle=%.1f coverage=%.1f%% \n",
          i, ellipses[i].x, ellipses[i].y, ellipses[i].a, ellipses[i].b, ellipses[i].t*180/3.14, ellipses[i].coverage*100);
 }
 
 // show the extracted ellipses
 lti::viewer view("Detected ellipses");
 view.show(result);
 
 // wait for a mouse click in the viewer window
 view.waitButtonPressed();

Constructor & Destructor Documentation

lti::fastEllipseExtraction::fastEllipseExtraction (  ) 

default constructor

lti::fastEllipseExtraction::fastEllipseExtraction ( const parameters par  ) 

Construct a functor using the given parameters.

lti::fastEllipseExtraction::fastEllipseExtraction ( const fastEllipseExtraction other  ) 

copy constructor

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

destructor


Member Function Documentation

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

Applies fast ellipse detection on-place.

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

Applies fast ellipse detection on-place.

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

returns a pointer to a clone of this functor.

Reimplemented from lti::featureExtractor.

fastEllipseExtraction& lti::fastEllipseExtraction::copy ( const fastEllipseExtraction 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<ellArcEntry>& lti::fastEllipseExtraction::getEllArcList ( const int  groupNumber  )  [virtual]

returns a vector with arcs of the specified group

Parameters:
groupNumber number of the arc group (1,2,3,4,5,6,7,8 or 0 for all arcs)
Returns:
vector with extracted arcs
virtual std::vector<ellExtArcEntry>& lti::fastEllipseExtraction::getEllExtArcList ( const int  groupNumber  )  [virtual]

returns a vector with extended arcs of the specified group

Parameters:
groupNumber number of the arc group (1,2,3,4,5,6,7,8 or 0 for all arcs)
Returns:
vector with extracted extended arcs
virtual std::vector<ellipseEntry>& lti::fastEllipseExtraction::getEllipseList (  )  [virtual]

returns a vector with extracted ellipses.

Returns:
vector with extracted ellipses
virtual std::vector<lineEntry>& lti::fastEllipseExtraction::getLineList ( const int  groupNumber  )  [virtual]

returns a vector with lines of the specified group

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

returns used parameters

Reimplemented from lti::featureExtractor.

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

returns a vector with line segments of the specified group

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

returns the name of this type ("fastEllipseExtraction")

Reimplemented from lti::featureExtractor.

fastEllipseExtraction& lti::fastEllipseExtraction::operator= ( const fastEllipseExtraction 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