latest version v1.9 - last update 10 Apr 2010 |
This functor implements a fast circle extraction using the line segments found in digital images. More...
#include <ltiFastCircleExtraction.h>
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) |
fastCircleExtraction & | copy (const fastCircleExtraction &other) |
fastCircleExtraction & | operator= (const fastCircleExtraction &other) |
virtual functor * | clone () const |
const parameters & | getParameters () 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 () |
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();
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
other | the object to be copied |
virtual lti::fastCircleExtraction::~fastCircleExtraction | ( | ) | [virtual] |
destructor
bool lti::fastCircleExtraction::apply | ( | const channel & | srcdest | ) |
Applies fast circle detection on-place.
srcdest | channel with the source data. |
bool lti::fastCircleExtraction::apply | ( | const channel8 & | srcdest | ) |
Applies fast circle detection on-place.
srcdest | channel8 with the source data. |
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.
other | the functor to be copied |
Reimplemented from lti::featureExtractor.
virtual std::vector<arcEntry>& lti::fastCircleExtraction::getArcList | ( | const int | group_number | ) | [virtual] |
virtual std::vector<circleEntry>& lti::fastCircleExtraction::getCircleList | ( | ) | [virtual] |
virtual std::vector<extArcEntry>& lti::fastCircleExtraction::getExtArcList | ( | const int | group_number | ) | [virtual] |
virtual std::vector<lineEntry>& lti::fastCircleExtraction::getLineList | ( | const int | group_number | ) | [virtual] |
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] |
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 | ) |