latest version v1.9 - last update 10 Apr 2010 |
This functor implements a fast ellipse extraction using the line segments found in digital images. More...
#include <ltiFastEllipseExtraction.h>
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) |
fastEllipseExtraction & | copy (const fastEllipseExtraction &other) |
fastEllipseExtraction & | operator= (const fastEllipseExtraction &other) |
virtual functor * | clone () const |
const parameters & | getParameters () 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 () |
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();
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
other | the object to be copied |
virtual lti::fastEllipseExtraction::~fastEllipseExtraction | ( | ) | [virtual] |
destructor
bool lti::fastEllipseExtraction::apply | ( | const channel & | srcdest | ) |
Applies fast ellipse detection on-place.
srcdest | channel with the source data. |
bool lti::fastEllipseExtraction::apply | ( | const channel8 & | srcdest | ) |
Applies fast ellipse detection on-place.
srcdest | channel8 with the source data. |
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.
other | the functor to be copied |
Reimplemented from lti::featureExtractor.
virtual std::vector<ellArcEntry>& lti::fastEllipseExtraction::getEllArcList | ( | const int | groupNumber | ) | [virtual] |
virtual std::vector<ellExtArcEntry>& lti::fastEllipseExtraction::getEllExtArcList | ( | const int | groupNumber | ) | [virtual] |
virtual std::vector<ellipseEntry>& lti::fastEllipseExtraction::getEllipseList | ( | ) | [virtual] |
virtual std::vector<lineEntry>& lti::fastEllipseExtraction::getLineList | ( | const int | groupNumber | ) | [virtual] |
const parameters& lti::fastEllipseExtraction::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::featureExtractor.
virtual std::vector<segmEntry>& lti::fastEllipseExtraction::getSegmentList | ( | const int | groupNumber | ) | [virtual] |
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 | ) |