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

lti::fastLineExtraction Class Reference

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

#include <ltiFastLineExtraction.h>

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

List of all members.

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)
fastLineExtractioncopy (const fastLineExtraction &other)
fastLineExtractionoperator= (const fastLineExtraction &other)
virtual functorclone () const
const parametersgetParameters () 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

Detailed Description

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();

Constructor & Destructor Documentation

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

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

destructor


Member Function Documentation

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

Applies fast line detection on-place.

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

Applies fast line detection on-place.

Parameters:
srcdest channel8 with the source data.
Returns:
true if apply was successful or false otherwise.
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.

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

Reimplemented from lti::featureExtractor.

virtual std::vector<segmEntry>& lti::fastLineExtraction::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
virtual const int lti::fastLineExtraction::getMultiGroupedSegmentCount ( const int  group_number  )  const [virtual]

returns number of segments that are used in several lines

Parameters:
group_number number of the line group (1,2,3,4)
Returns:
number of multi-grouped line segments
virtual const int lti::fastLineExtraction::getNonGroupedSegmentCount ( const int  group_number  )  const [virtual]

returns number of segments that could not be grouped to a line

Parameters:
group_number number of the line group (1,2,3,4)
Returns:
number of non-grouped line segments
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]

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::fastLineExtraction::getTypeName (  )  const [virtual]

returns the name of this type ("fastLineExtraction")

Reimplemented from lti::featureExtractor.

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