latest version v1.9 - last update 10 Apr 2010 |
This functor implements a fast line extraction using the line segments found in digital images. More...
#include <ltiFastLineExtraction.h>
Classes | |
class | parameters |
the parameters for the class fastLineExtraction More... | |
Public Member Functions | |
fastLineExtraction () | |
fastLineExtraction (const parameters &par) | |
fastLineExtraction (const fastLineExtraction &other) | |
virtual | ~fastLineExtraction () |
virtual const char * | getTypeName () const |
bool | apply (const channel8 &srcdest) |
bool | apply (const channel &srcdest) |
fastLineExtraction & | copy (const fastLineExtraction &other) |
fastLineExtraction & | operator= (const fastLineExtraction &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
virtual std::vector< segmEntry > & | getSegmentList (const int group_number) |
virtual std::vector< segmEntry > & | getLineList (const int group_number) |
virtual const int | getNonGroupedSegmentCount (const int group_number) const |
virtual const int | getMultiGroupedSegmentCount (const int group_number) const |
This functor implements a fast line extraction using the line segments found in digital images.
To achieve this, the (edge-)image is decomposed into line segments of four types (I=horizontal, II=vertical, III=diagonal horizontal, IV=diagonal vertical) which are recomposed to lines in a second pass.
The fastLineExtraction::parameters specify ranges for segments/lines and conditions that a set of segments must fulfill to be considered as a line. The result strongly depends on these parameters, especially the number and the precision of the extracted lines.
The extracted segments and lines are stored in STL vector containers of the type <segmEntry> and can be accessed by the methods getSegmentList() and getLineList().
ipoint
is the data type for coordinates:
typedef tpoint<int> ipoint;
segmEntry
is the data struct for segments/lines:
struct segmEntry { ipoint start; // start point of segment or line ipoint end; // end point of segment or line int len; // length of segment or line int used; // counts segment<->line assignments };
Additionally there are two methods which return some statistical information about the line extraction process: getNonGroupedSegmentCount() and getMultiGroupedSegmentCount()
The fast line extraction does not perform any changes to the analyzed image. To visualize the extracted lines they have to be drawn by other code using the segment 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 "ltiFastLineExtraction.h" // line 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 FLE functor (using default parameters) lti::fastLineExtraction fle; // extract the lines fle.apply(m_edges); // get the complete line list std::vector<lti::fastLineExtraction::segmEntry> &lines = fle.getLineList(0); // create a drawing functor lti::draw<lti::channel8::value_type> drawer; drawer.use(result); drawer.setColor(255); for(int i=0; i<lines.size(); i++) { // draw all lines drawer.line(lines[i].start, lines[i].end); // print line data printf("line[%i]: start=(%i,%i) end=(%i,%i) length=%i \n", i, lines[i].start.x, lines[i].start.y, lines[i].end.x, lines[i].end.y, lines[i].len); } // show the extracted lines lti::viewer view("Detected lines"); view.show(result); // wait for a mouse click in the viewer window view.waitButtonPressed();
lti::fastLineExtraction::fastLineExtraction | ( | ) |
default constructor
lti::fastLineExtraction::fastLineExtraction | ( | const parameters & | par | ) |
Construct a functor using the given parameters.
lti::fastLineExtraction::fastLineExtraction | ( | const fastLineExtraction & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::fastLineExtraction::~fastLineExtraction | ( | ) | [virtual] |
destructor
bool lti::fastLineExtraction::apply | ( | const channel & | srcdest | ) |
Applies fast line detection on-place.
srcdest | channel with the source data. |
bool lti::fastLineExtraction::apply | ( | const channel8 & | srcdest | ) |
Applies fast line detection on-place.
srcdest | channel8 with the source data. |
virtual functor* lti::fastLineExtraction::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this functor.
Reimplemented from lti::featureExtractor.
fastLineExtraction& lti::fastLineExtraction::copy | ( | const fastLineExtraction & | other | ) |
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::featureExtractor.
virtual std::vector<segmEntry>& lti::fastLineExtraction::getLineList | ( | const int | group_number | ) | [virtual] |
virtual const int lti::fastLineExtraction::getMultiGroupedSegmentCount | ( | const int | group_number | ) | const [virtual] |
returns number of segments that are used in several lines
group_number | number of the line group (1,2,3,4) |
virtual const int lti::fastLineExtraction::getNonGroupedSegmentCount | ( | const int | group_number | ) | const [virtual] |
returns number of segments that could not be grouped to a line
group_number | number of the line group (1,2,3,4) |
const parameters& lti::fastLineExtraction::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::featureExtractor.
virtual std::vector<segmEntry>& lti::fastLineExtraction::getSegmentList | ( | const int | group_number | ) | [virtual] |
virtual const char* lti::fastLineExtraction::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("fastLineExtraction")
Reimplemented from lti::featureExtractor.
fastLineExtraction& lti::fastLineExtraction::operator= | ( | const fastLineExtraction & | other | ) |