Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Protected Attributes
jafar::lines::LsExtractor Class Reference

Class with functions to extract line segments of an image. More...


Detailed Description

Class with functions to extract line segments of an image.

This class provides a set of functions to extract line segments of an image. The idea is to extract all line segments contained in an image (global extraction). To re-extract a line from a prediction of that line (local extraction) have a look at LineSegment::fitLineOrientation() function and its Usage in the LsTracker class.

To simply extract the set of lines of an image, the extractLineSegments() function can be used. It combines the extraction steps with the currently best performance.

The functions of LsExtractor class works all with the same scheme: calculate gradient image or Canny image and find contour points by maxima suppression with hysteresis and find lines either with polygonalisation There is a combination of the two OpenCV function for that task, but the contour representation that result by OpenCv cvFindContours runs a lot of contour points for multiple times if there are branched contours, thus the contours are very long. Therefore the well tested Calife functions for that task can be used alternatively. Some documentation of the Calife functions is contained in ctdef.hpp file. The OpenCv polygonalization algorithm seems to be a little bit buggy (CVS version avaiable at January 2008), therefore a simple implementation of Douglas-Peucker Algorithm is provided.

Further there is a function to apply a Hough-transformation to find lines.

Definition at line 28 of file lsExtractor.hpp.

#include <lsExtractor.hpp>

List of all members.

Public Member Functions

bool procCanny (jafar::image::Image *image, jafar::image::Image *cannyIm)
 Procced cvCanny on _image with member variables as Canny parameters.
void extractLineSegments (jafar::image::Image *image, jafar::image::Image *cannyIm, LineSegmentSet &segmentStorage, double thresh=15)
 Extraction of line segments with memeber variables as parameters.
bool procHough (jafar::image::Image *image, LineSegmentSet &newSegments)
 Procced cvHoughLines2 on image and gives resulting set of lines.
bool procCvFindContour (jafar::image::Image *image, LineSegmentSet &newSegments, double thresh=15)
 Proceed cvFindContours and cvApproxPoly on image Therefore the image has be a binary image (e.g.
void setCannyLowerThresh (int lowerThresh)
void setCannyHigherThresh (int higherThresh)
void setCannyAp (int ap)
void setCannyPara (int lowerThresh, int higherThresh, int ap)
void setHoughMethod (int method)
void setHoughRho (double rho)
void setHoughTheta (double theta)
void setHoughThreshold (int thresh)
void setHoughParam1 (double param)
void setHoughParam2 (double param)
void setHoughPara (int method, double rho, double theta, int thresh, int param1, int param2)

Static Public Member Functions

static bool procCannySt (jafar::image::Image *image, jafar::image::Image *cannyIm, int lowerThresh, int higherThresh, int ap)
 Procced cvCanny on _image with function parameters as Canny parameters.
static void extractLineSegmentsSt (jafar::image::Image *image, jafar::image::Image *cannyIm, LineSegmentSet &segmentStorage, double thresh=15, int lowerThresh=75, int higherThresh=150, int ap=3)
 Extraction of line segments with function parameters as parameters.
static void findLinesDP (jafar::image::Image *image, LineSegmentSet &newSegments, double thresh)
 Input image should either be canny or gradient image, attention: an image with height or width which is not a multiple of 4 slows down the function (because the whole image data must be copied) The content of the image is changed.
static void findLinesCalife (jafar::image::Image *image, LineSegmentSet &newSegments, double thresh=15)
 Input image should either be canny or gradient image, attention: an image with height or width which is not a multiple of 4 slows down the function (because the whole image data must be copied) The content of the image is changed.
static int dp (short *x, short *y, int startIdx, int endIdx, std::vector< CvPoint > &endpoints, double thresh=1)
 Recursive function for polygonal approximation of a set of points.

Protected Attributes

int cannyLowerThresh
 Parameter for cvCanny.
int cannyHigherThresh
 Parameter for cvCanny.
int cannyAp
 Parameter for cvCanny.
int houghMethod
 Parameter for cvHoughLines2.
double houghRho
 Parameter for cvHoughLines2.
double houghTheta
 Parameter for cvHoughLines2.
int houghThreshold
 Parameter for cvHoughLines2.
double houghParam1
 Parameter for cvHoughLines2.
double houghParam2
 Parameter for cvHoughLines2.

Member Function Documentation

static int jafar::lines::LsExtractor::dp ( short *  x,
short *  y,
int  startIdx,
int  endIdx,
std::vector< CvPoint > &  endpoints,
double  thresh = 1 
) [static]

Recursive function for polygonal approximation of a set of points.

The points are given by x and y coordinates. The used algorithm is Douglas-Peucker. Designed for use with ExtractContours1 function.

void jafar::lines::LsExtractor::extractLineSegments ( jafar::image::Image image,
jafar::image::Image cannyIm,
LineSegmentSet segmentStorage,
double  thresh = 15 
)

Extraction of line segments with memeber variables as parameters.

Extracts lines from image and appends result to _segmentStorage. If only the resulting lines are desired to be contained in _segmentStorage, then _segmentStorage should be cleared before calling this function (LineSegmentSet::clear()). The _image is used as container for the Canny image, therefore it is changed within this function. As parameters for Canny the member variables are taken.

Parameters:
imageGreyvalue image whose lines are extracted, image content is changed
cannyImStorage for the resulting image of Canny edge detection
segmentStorageStorage for resulting line segments
threshMinimum length of accepted lines.
static void jafar::lines::LsExtractor::extractLineSegmentsSt ( jafar::image::Image image,
jafar::image::Image cannyIm,
LineSegmentSet segmentStorage,
double  thresh = 15,
int  lowerThresh = 75,
int  higherThresh = 150,
int  ap = 3 
) [static]

Extraction of line segments with function parameters as parameters.

Extracts lines from image and appends result to _segmentStorage. If only the resulting lines are desired to be contained in _segmentStorage, then _segmentStorage should be cleared before calling this function (LineSegmentSet::clear()). The _image is used as container for the Canny image, therefore it is changed within this function. As parameters for Canny the function parameters are taken.

Parameters:
imageGreyvalue image whose lines should be extracted, image content is changed
cannyImStorage for the resulting image of Canny edeg detection
segmentStorageStorage for resulting line segments
threshMinimum length of accepted lines.
lowerThreshLower threshold for Canny edge detection
higherThreshHigher threshold for Canny edge detection
apAperture size for Canny edge detection
static void jafar::lines::LsExtractor::findLinesCalife ( jafar::image::Image image,
LineSegmentSet newSegments,
double  thresh = 15 
) [static]

Input image should either be canny or gradient image, attention: an image with height or width which is not a multiple of 4 slows down the function (because the whole image data must be copied) The content of the image is changed.

All pixels, that are contained in a taken contour are set to 127.

static void jafar::lines::LsExtractor::findLinesDP ( jafar::image::Image image,
LineSegmentSet newSegments,
double  thresh 
) [static]

Input image should either be canny or gradient image, attention: an image with height or width which is not a multiple of 4 slows down the function (because the whole image data must be copied) The content of the image is changed.

All pixels, that are contained in a taken contour are set to 127. The polygonal approximation is done with db() function, witch implements Douglas-Peucker algorithm.

Parameters:
imageGreyvalue image whose lines are extracted, image content is changed
newSegmentsStorage for resulting line segments
threshMinimum length of accepted lines.

Procced cvCanny on _image with member variables as Canny parameters.

Applies Canny edge detection on image and saves the result in cannyIm. The member variables are taken as parameters for Canny.

static bool jafar::lines::LsExtractor::procCannySt ( jafar::image::Image image,
jafar::image::Image cannyIm,
int  lowerThresh,
int  higherThresh,
int  ap 
) [static]

Procced cvCanny on _image with function parameters as Canny parameters.

Applies Canny edge detection on image and saves the result in cannyIm. The function parameters are taken as parameters for Canny

bool jafar::lines::LsExtractor::procCvFindContour ( jafar::image::Image image,
LineSegmentSet newSegments,
double  thresh = 15 
)

Proceed cvFindContours and cvApproxPoly on image Therefore the image has be a binary image (e.g.

the result of cvCanny, have a look at the procCanny function) To accept only large lineSegments a threshold is used

Procced cvHoughLines2 on image and gives resulting set of lines.

Applies Hough on image and saves the result in image.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:42 for Jafar by doxygen 1.7.6.1
LAAS-CNRS