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

Class for a line segment with descriptor. More...


Detailed Description

Class for a line segment with descriptor.

This class contains attributes (e.g. coordinates of ending points, coordinates of midpoint, slope) of a line segment.

Attention, there are two kinds of length. In the length member the number of pixels on the line is stored, the eucLength member is the euclidean distance of endpoints. There are two kinds of orientation as well. The alpha member is the orientation of the line and oAlpha member is the directed orientation from endpoint (x1, y1) to (x2, y2).

The very most attibutes are set in the setPoints() function. If only the direction of the line changed, but not the orientation or the coordinates of endpoints, the changePointOrder() function can be used.

In the setPoints() function the covariances for endpoints and olar coordinates are calculated. They are calculated from assumed uncertainty parallel and perpendicular to the line. There is a special covariance for the merging process which assumes the only uncertainty perpendicular to the line.

Several containers for descriptors (e.g. graylevel, gradient, LaPlace of pixels underlying the line) are provided. Functions to extract the descriptors are provided as well. Furthermore there is a storrage for lines that describe the neighbouhood of the line. The number of this parallel lines is arbitrary, this feature can also be ignored.

Definition at line 36 of file lineSegment.hpp.

#include <lineSegment.hpp>

List of all members.

Public Member Functions

 LineSegment ()
 Constructor without generating parallel lines.
 LineSegment (int _numberOfNeighbours)
 Constructor that generates parallel lines.
 LineSegment (const LineSegment &ls)
 Copy-constructor.
 ~LineSegment ()
 Destructor.
void extractGreyscale (jafar::image::Image *image, int parallel_flag=0)
 Extracts grey values of pixels on the line segment.
void extractGradientscale (jafar::image::Image *image, int gradientimage, int parallel_flag=0)
 Extracts gradient values of pixels on the line segment.
void extractLaplacescale (jafar::image::Image *image, int laplaceimage, int parallel_flag=0)
 Extracts Laplace values of pixels on the line segment.
void setPoints (double _x1, double _y1, double _x2, double _y2, bool resetFlag=1)
 Sets point coordinates and initialises parallels.
LineSegmentoperator= (const LineSegment &ls)
 Assignment operator.
void setNumberOfNeighbours (int number)
 Sets numberOfNeighbours and updates parallels.
double assignContourPts (jafar::image::Image *image)
 Assigns contour pixels to each point of the line.
void changePointOrder ()
 Changes direction of line without changing the orientation or endpoint coordinates.
void orientLine (jafar::image::Image *image)
 Orient line with respect to the average greylevels on both sides of the line.
void calcHistogramDescriptor (jafar::image::Image *image, int nParallels=1, int d=3, jafar::image::Image *colorImage=0)
 Compute histograms of line from image.
void calcHistogramDescriptor ()
 Compute histograms of line form parallels vector.
void normaliseHistogramDescriptor ()
 Normalize the histogram descriptor.
void calcGreyspaceDescriptor (jafar::image::Image *image)
 Compute descriptor based on contour points acording to line points.
bool fitLine (jafar::image::Image *image, int gradientimage=0, int nPoints=20, int pDist=25, jafar::image::Image *colorImage=0)
 Fit line to gradient maxima, using RANSAC. Result is a single line.
int fitLineCandidates (jafar::image::Image *image, int gradientimage, std::vector< CvPoint > &startPts, std::vector< CvPoint > &endPts, int nPoints, int pDist, int nIter, jafar::image::Image *colorImage)
 Fit line to gradient maxima, using RANSAC. Result is a set of candidate lines.
bool fitLineOrientation (LineSegmentSet &lsSet, jafar::image::Image *gradX, jafar::image::Image *gradY, int nPoints=10, int pDist=25, double aDist=M_PI *0.5, double minLength=0, double extend=0, jafar::image::Image *colorImage=0)
 Fit line to gradient maxima with respect to gradient orientation.
void searchGradMax (CvPoint p1, CvPoint p2, std::vector< CvPoint > &points, std::vector< double > &pointGrads, jafar::image::Image *gradX, jafar::image::Image *gradY, int nPoints, double pDist)
 This function searches for gradient maxima perpendicular to the line between p1 and p1.
void interpolateLineRansac (std::vector< LineSegment > lines, std::vector< CvPoint > &points, std::vector< double > &pointGrads, jafar::image::Image *gradX, jafar::image::Image *gradY, int nPoints, int nIt, double minInlierRate, double minLength, jafar::image::Image *colorImage)
 This function uses RANSAC to interpolate a set of points by lines.
void interpolateLineGrowline (std::vector< LineSegment > &lines, std::vector< CvPoint > &points, std::vector< double > &pointGrads, jafar::image::Image *gradX, jafar::image::Image *gradY, int nPoints, double minLength, double aDist, jafar::image::Image *colorImage)
 This function interpolates a set of points by lines.
double getEPPredictionByRhoThetaPrediction (double x1Old, double y1Old, double x2Old, double y2Old, double &x1Pred, double &y1Pred, double &x2Pred, double &y2Pred)
 Calculates the prediction of the endpoints from the prediction in polar coordinates stored in rhoPred and thetaPred.
double getEPPrediction (double &_x1Pred, double &_y1Pred, double &_x2Pred, double &_y2Pred)
 Access the prediction of the endpoints.
bool growLineParallel (jafar::image::Image *image, int dist=3, int thresh=5, int distThresh=20)
 Grow line with use of the parallel lines.
bool growLine (jafar::image::Image *image, int gapThresh=1, int thresh=40, int maxOffset=2)
void drawLine (jafar::image::Image *image, CvScalar color, int width=1)
unsigned int getId ()
 To get Id.
double getX1 ()
 To get x1 (Coordinate of ending point)
double getY1 ()
 To get y1 (Coordinate of ending point)
double getX2 ()
 To get x2 (Coordinate of ending point)
double getY2 ()
 To get y2 (Coordinate of ending point)
double getMx ()
 To get mx (Coordinate of midpoint)
double getMy ()
 To get my (Coordinate of midpoint)
double getAlpha ()
 To get alpha (Angel to positiv x-axis)
double getOAlpha ()
 To get oAlpha (oriented Angel to positiv x-axis)
double getEucLength ()
 To get euclidean length.
bool isValid ()
 To know if line is valid. validFlag is for user to indicated invalid lines.
void setValid ()
 Set line valid.(Done by constructor, too)
void setInvalid ()
 Marke line as invalid. (e.g. if merged with another line)
void setPredictionPolar (double rho, double theta, double covRR, double covRT, double covTT)
 Set the prediction for that line in polar coordinates.
void setPrediction (double x1P, double y1P, double x2P, double y2P, double cov1xxP, double cov1xyP, double cov1yyP, double cov2xxP, double cov2xyP, double cov2yyP)
 Set the prediction for the endpoints of that line.

Static Public Member Functions

static bool calcSupportingLine (double x1, double y1, double x2, double y2, double &alpha, double &y0)
 Provides alpha and y0 of a line given by endpoints.
static bool calcEndpointsOfSupportingLine (double alpha, double y0, int height, int width, double &x1, double &y1, double &x2, double &y2)
 Provides cross points of a supporting line with image borders.
static double mahaDistLines (LineSegment &lA, LineSegment &lB, double varEP, double varDir, double varGrey, double varVGrey)
static double compareGreyspace (std::vector< int > &greyA, std::vector< int > &greyB)
 Compares the greyspace of two lines.
static double compareAvLR (LineSegment &lsA, LineSegment &lsB)
 Compares the average grey levels of two lines.
static double chi2TestLocalPolarCOS (LineSegment &lsA, LineSegment &lsB, double *pDiffRho=0)
 Apply Chi2 similarity test on lines.
static int tryMergeLinesChiSq (LineSegment &lA, LineSegment &lB, double maxGap=0)
 Merges two lines on base of Chi2-Test.
static void mergeLinesProb (LineSegment &lsA, LineSegment &lsB)
 Compute the "average" line of two lines.
static int mergeLinesEP (LineSegment &lsA, LineSegment &lsB)
 This function process a merging by connecting the endpoints of the line that defines the longest possible lineSegment.
static double sizeOfGap (LineSegment &lsA, LineSegment &lsB)
 Returns the size of the gap between two line segments.

Public Attributes

int length
 The number of pixels on this line given by Bresenham algorithm (8-neighbourhood)
CvScalar color
 Color for drawing the line.
std::vector< int > greyscale
 Container for grey values of underlying pixels.
std::vector< int > gradientscale
 Container for gradient values of underlying pixels.
std::vector< int > laplacescale
 Container for LaPlace values of underlying pixels.
int numberOfNeighbours
 Number of neighboured parallel lines.
LineSegment ** parallels
 Array of neighboured parallel lines.
jafar::lines::HistogramhistogramB
 Histogram of brighter side.
jafar::lines::HistogramhistogramD
 Histogram of darker side.
std::vector< int > greyspace
 Descriptor of greyvalues along the line segment.
std::vector< int > greyspaceL
 Descriptor of greyvalues along the line segment left side.
std::vector< int > greyspaceR
 Descriptor of greyvalues along the line segment right side.
double avL
 Average grey level on left side of the line.
double avR
 Average grey level on right side of the line.
double varL
 Average change of neighboured greyscales on left side of the line.
double varR
 Average change of neighboured greyscales on right side of the line.
double polarD
 Polar coordinate distance (rho)
double polarAlpha
 Polar coordinate angle (theta) ,polarAlpha is in range [-pi, pi].
double covDD
 Covariance of polar coordinates.
double covAA
 Covariance of polar coordinates.
double covAD
 Covariance of polar coordinates.
double covXX
 Element of covariance matrix of endpoints and orientation.
double covXY
 Element of covariance matrix of endpoints and orientation.
double covYY
 Element of covariance matrix of endpoints and orientation.
double covAlpha
 Element of covariance matrix of endpoints and orientation.
double covXA
 Element of covariance matrix of endpoints and orientation.
double covYA
 Element of covariance matrix of endpoints and orientation.
double covXX_M
 Element of covariance matrix for merging (no uncertainty parallel to line)
double covXY_M
 Element of covariance matrix for merging (no uncertainty parallel to line)
double covYY_M
 Element of covariance matrix for merging (no uncertainty parallel to line)
double covXA_M
 Element of covariance matrix for merging (no uncertainty parallel to line)
double covYA_M
 Element of covariance matrix for merging (no uncertainty parallel to line)
double u
 x coordinate of closest point to origin on the infinite line
double v
 y coordinate of closest point to origin on the infinite line
uint id
 Unique identifier of the line.
std::vector< std::vector
< CvPoint > > 
contourPoints
 Storage for the contour points of that line.
int param1
 Special parameter, in LsTracker used as storage for longest antecessor line.
std::vector< int > parameters
 set of special parameters, in LsTracker used as storage for all antecessor lines
jafar::lines::LsPredictor2D predictor
 Motion predcitor for the line, used for tracking in LsTracker.
double rhoPred
 rho value of polar coordinates of the prediction
double thetaPred
 theta value of polar coordinates of the predicition
double covRRpred
 variance of predicted rho
double covRTpred
 correlation of predicted rho and theta
double covTTpred
 variance of predicted theta
bool predFlag
 indicates if there is a valid prediction stored in rhoPred, thetaPred
double x1Pred
 predicted endpoint coordinate
double y1Pred
 predicted endpoint coordinate
double x2Pred
 predicted endpoint coordinate
double y2Pred
 predicted endpoint coordinate
double rangePred
 searchc range resulting from the prediction

Private Attributes

bool validFlag
double x1
 Coordinate of ending point.
double y1
 Coordinate of ending point.
double x2
 Coordinate of ending point.
double y2
 Coordinate of ending point.
double mx
 Coordinate of midpoint.
double my
 Coordinate of midpoint.
double slope
 Slope of the line segment.
double eucLength
 Euclidean distance of ending points.
double alpha
 Angle to positiv x-axis, [-pi/2 , +pi/2], calculated in setPoints()
double oAlpha
 (oriented) Angle to positiv x-axis, not of the total line but of the line segment with (x1,y1) shifted to origin, [-pi, +pi], calculated in orientLine()

Constructor & Destructor Documentation

Constructor without generating parallel lines.

Simple constructor. Initializes color randomly. Number of parallels is 0.

jafar::lines::LineSegment::LineSegment ( int  _numberOfNeighbours)

Constructor that generates parallel lines.

Constructor. Initializes color randomly. Number of parallels is given by parameter. Memory for that lines is allocated, but the lines are not initialized, this is done by using the LineSegment::setPoints function for this line. In this function the coordinates for the ending points of parallel lines are calculated.

Parameters:
_numberOfNeighboursInitialisation for number of parallel lines to describe neighbourhood of the line segment. .

Member Function Documentation

Assigns contour pixels to each point of the line.

This function assigns a list of contour pixels to each pixel of the line. This is usefull for calculating more robust descriptors. Returns the proportional share of pixels, that are neighboured to a contour pixel, range: [0...1]

Parameters:
imageImage should be a black and white immage with white pixels for all contour points (e.g. the result of Canny edge detection).
static bool jafar::lines::LineSegment::calcEndpointsOfSupportingLine ( double  alpha,
double  y0,
int  height,
int  width,
double &  x1,
double &  y1,
double &  x2,
double &  y2 
) [static]

Provides cross points of a supporting line with image borders.

This function calculates intersectionpoints of suporting line with image boarders. That means the angel to positiv x-axis and the y-value of intersection point with y-axis of a line are given and the (x,y) coordinates of the intersection points with the image boarders are provided. Therefore the height and width of the image must be given. The coordinate frame is origined in the upper left corner, x-axis is horizontally and y-axis vertically.

Parameters:
alphaAngel to positiv x-axis of the line (in radian).
y0y-value of intersection point with y-axis
heightHeight of the image for that intersection points should be calculated
widthWidth of the image for that intersection points should be calculated
x1Reference, storage for x coordinate of first intersection point
y1Reference, storage for y coordinate of first intersection point
x2Reference, storage for x coordinate of second intersection point
y2Reference, storage for y coordinate of second intersection point Calculate Mahalanobis distance of two line segments

Compute descriptor based on contour points acording to line points.

Compute descriptor based on contour points acording to line points. To compute descriptor based on just line points, assign each line point to itself bevor calling this function.

void jafar::lines::LineSegment::calcHistogramDescriptor ( jafar::image::Image image,
int  nParallels = 1,
int  d = 3,
jafar::image::Image colorImage = 0 
)

Compute histograms of line from image.

This function computes the histograms histogramB (left side) and histogramD (right side) for that line with respect to the graylevel values in image. The histograms are calculated on parallels with distance d to the line. The colorImage parameter can be used for debugging to draw the respected lines on an image

Compute histograms of line form parallels vector.

This function computes the histograms histogramB (left side) and histogramD (right side) for that line with respect to the graylevel values in parallels.

static bool jafar::lines::LineSegment::calcSupportingLine ( double  x1,
double  y1,
double  x2,
double  y2,
double &  alpha,
double &  y0 
) [static]

Provides alpha and y0 of a line given by endpoints.

This function calculates supporting line for a line segment given by two points. Alpha is the angle to positiv x-axis in radian and y is y coordinate of the intersection point with y-axis, if alpha==pi/2 then y0 is the x-coordinate of the intersection point with the x-axis (because there is probably no intersection point with y-axis). (origin of the image COS is the upper left corner, x-axis is horizontally and y-axis vertically)

Parameters:
x1x Coordinate of the first point
y1y Coordinate of the first point
x2x Coordinate of the first point
y2y Coordinate of the first point
alphaReference, storage for angel to positiv x-axis (in radian)
y0Reference, storage for y-coordinate of intersection point with y-axis
Returns:
0 if points are equal, else returns 1

Changes direction of line without changing the orientation or endpoint coordinates.

Changes direction of line without changing the orientation or endpoint coordinates. The oAlpha value some covariances are updated. The histograms are swap.

static double jafar::lines::LineSegment::chi2TestLocalPolarCOS ( LineSegment lsA,
LineSegment lsB,
double *  pDiffRho = 0 
) [static]

Apply Chi2 similarity test on lines.

Apply Chi2 similarity test on two lines. For lsB the polar coordinate representation in a local coordinate system with origin in [x1,y1] of lsA is computed. On that representation a Chi2 test is applied. Returns the Mahalanobis distance. pDiffRho can be the pointer to a storage for the difference in rho coordinate, that can be used to verify the test.

static double jafar::lines::LineSegment::compareAvLR ( LineSegment lsA,
LineSegment lsB 
) [static]

Compares the average grey levels of two lines.

Compares the average grey levels of two lines independently for both sides. The two results are fusioned and returned. The avL and avR values of both lines have to be set before, therefore have a look at orientLine() function.

static double jafar::lines::LineSegment::compareGreyspace ( std::vector< int > &  greyA,
std::vector< int > &  greyB 
) [static]

Compares the greyspace of two lines.

Compares the greyspace of two lines. Lines have to be oriented, (have a look at orientLine() function) before the greyspace is extracted with calcGreyspaceDescriptor() function.

void jafar::lines::LineSegment::extractGradientscale ( jafar::image::Image image,
int  gradientimage,
int  parallel_flag = 0 
)

Extracts gradient values of pixels on the line segment.

Extracts gradient values of pixels according to the line if the line would be drawn on _image. To determine the according pixels Bresenham-algorithm (8-neighbourhood) is used. This function can deal with greyscale and gradien images. The flag _gradientimage must be set accordingly. If an greyscale image is given, the gradien image is calculated, that decreases speed of this function. If this function is called for serveral lines on one image, it's better to calculate the gradient image outside this function. If parallel_flag!=0 the scale is also extracted for parallels (with respect to numberOfNeighbours). In that case the ending points and the length of the parallel lines are updated with respect to _image size. (This is done by the use of LineSegment::setPoints function.

Parameters:
imageTyp: jafar::image::Image*. Can be a pointer to an greyscale image or to an gradient image. If it's an pointer to an greyscale image _gradientimage must be 0, otherwise _gradienimage must be !=0.
gradientimageFlag to indicate if _image is an greyscale or an gradient image.
parallel_flagIf !=0 the scale is also extracted for parallels (with respect to numberOfNeighbours)
void jafar::lines::LineSegment::extractGreyscale ( jafar::image::Image image,
int  parallel_flag = 0 
)

Extracts grey values of pixels on the line segment.

This function extracts grey values of pixels according to the line if the line would be drawn in image. To determine the according pixels Bresenham-algorithm (8-neighbourhood) is used. If parallel_flag!=0 the scale is also extracted for parallels (with respect to numberOfNeighbours). In that case the ending points and the length of the parallel lines are updated with respect to _image size. (This is done by the use of LineSegment::setPoints function.) If a parallel line lies completly out of image, it gets the same point coordinates of the next neighboured parallel line (or of the line itself if there is no neighboured parallel line).

Parameters:
imageTyp: jafar::image::Image*. Image that's greyvalues are used.
parallel_flagIf !=0 the scale is also extracted for parallels (with respect to numberOfNeighbours)
void jafar::lines::LineSegment::extractLaplacescale ( jafar::image::Image image,
int  laplaceimage,
int  parallel_flag = 0 
)

Extracts Laplace values of pixels on the line segment.

Extracts Laplace values of pixels according to the line if the line would be drawn on _image. To determine the according pixels Bresenham-algorithm (8-neighbourhood) is used. This function can deal with greyscale and Laplace images. The flag _laplacetimage must be set accordingly. If an greyscale image is given, the Laplace image is calculated, that decreases speed of this function. If this function is called for serveral lines on one image, it's better to calculate the gradient image outside this function. If parallel_flag!=0 the scale is also extracted for parallels (with respect to numberOfNeighbours). In that case the ending points and the length of the parallel lines are updated with respect to _image size. (This is done by the use of LineSegment::setPoints function.

Parameters:
imageTyp: jafar::image::Image*. Can be a pointer to an greyscale image or to an laplace image. If it's an pointer to an greyscale image _laplacetimage must be 0, otherwise _laplaceimage must be !=0.
laplaceFlag to indicate if _image is an greyscale or an laplace image.
parallel_flagIf !=0 the scale is also extracted for parallels (with respect to numberOfNeighbours)
bool jafar::lines::LineSegment::fitLine ( jafar::image::Image image,
int  gradientimage = 0,
int  nPoints = 20,
int  pDist = 25,
jafar::image::Image colorImage = 0 
)

Fit line to gradient maxima, using RANSAC. Result is a single line.

Fit line to gradient maxima, using RANSAC.Result is a single line. This function does not care about the orientation of the gradients. To fit a line with respect to the orientation of the gradient, use fitLineOrientation.

Parameters:
imagethe graylevel image in which the line is contained
gradientimageflag that indicates if the image is already a gradient image
nPointsnumber of controlpoints for whose the gradient maxima are searched
pDistserach range perpendicular to the line
colorImagecolorImage for debuging
int jafar::lines::LineSegment::fitLineCandidates ( jafar::image::Image image,
int  gradientimage,
std::vector< CvPoint > &  startPts,
std::vector< CvPoint > &  endPts,
int  nPoints,
int  pDist,
int  nIter,
jafar::image::Image colorImage 
)

Fit line to gradient maxima, using RANSAC. Result is a set of candidate lines.

Fit line to gradient maxima, using RANSAC. Similar to fitLine function, but here a number of candidate lines is stored in startPts and endPts and the number of lines is returned. The origin line is not changed

Parameters:
imagethe graylevel image in which the line is contained
gradientimageflag that indicates if the image is already a gradient image
startPtsstorage for the start points
endpointsstorage for the endpoints
nPointsnumber of controlpoints for whose the gradient maxima are searched
pDistserach range perpendicular to the line
nIternumber of iterations for RANSAC
colorImagecolorImage for debuging
bool jafar::lines::LineSegment::fitLineOrientation ( LineSegmentSet lsSet,
jafar::image::Image gradX,
jafar::image::Image gradY,
int  nPoints = 10,
int  pDist = 25,
double  aDist = M_PI *0.5,
double  minLength = 0,
double  extend = 0,
jafar::image::Image colorImage = 0 
)

Fit line to gradient maxima with respect to gradient orientation.

Fit line to gradient maxima with respect to gradient orientation. gradX and gradY are [IPL_DEPTH_16S JfrImage_CS_GRAY] Jafar-Images with gradient in x and y direction, the gradient has to be signed. The function can handle lines that are partialy out of the image. Line has to be oriented (have a look at LineSegment::orientLine()) nPoints has to be in [1, 16]

Parameters:
lsSetstorage for the resulting line segments
gradXgradient image in x direction
gradYgradient image in y direction
nPointsnumber of control points from which the gradient maxima are searched
pDistperpendicular search range
aDistmaximal angular difference of resulting line to current line
minLengthminimal length of resulting lines
extendlength of the extention of the line at both ends (to have a kind of parallel shift fitting)
colorImageimage for debuging
double jafar::lines::LineSegment::getEPPrediction ( double &  _x1Pred,
double &  _y1Pred,
double &  _x2Pred,
double &  _y2Pred 
)

Access the prediction of the endpoints.

Calculates the prediction of the predicted endpoints stored in **Pred members (prediction from external predictor (use of setPrediction) and not of lsPredictor2D). Returns a search range.

double jafar::lines::LineSegment::getEPPredictionByRhoThetaPrediction ( double  x1Old,
double  y1Old,
double  x2Old,
double  y2Old,
double &  x1Pred,
double &  y1Pred,
double &  x2Pred,
double &  y2Pred 
)

Calculates the prediction of the endpoints from the prediction in polar coordinates stored in rhoPred and thetaPred.

Calculates the prediction of the endpoints from the prediction in polar coordinates stored in rhoPred and thetaPred. The old endpoints of the line segmenent are projected onn the predicted line to get the predicted endpoints.

bool jafar::lines::LineSegment::growLine ( jafar::image::Image image,
int  gapThresh = 1,
int  thresh = 40,
int  maxOffset = 2 
)

Grow LineSegment based on image.

bool jafar::lines::LineSegment::growLineParallel ( jafar::image::Image image,
int  dist = 3,
int  thresh = 5,
int  distThresh = 20 
)

Grow line with use of the parallel lines.

Grow line with use of the parallel lines

Parameters:
imagePointer to grey value image
distDistance of the parallels to origin lineSegment
threshMaximal difference between two consecutive points on parallel to increase origin lineSegment
threshDistMinimal difference between left and right parallel to increase origin lineSegment
void jafar::lines::LineSegment::interpolateLineGrowline ( std::vector< LineSegment > &  lines,
std::vector< CvPoint > &  points,
std::vector< double > &  pointGrads,
jafar::image::Image gradX,
jafar::image::Image gradY,
int  nPoints,
double  minLength,
double  aDist,
jafar::image::Image colorImage 
)

This function interpolates a set of points by lines.

This function solves the same problem as the interpolateLineRansac() function but in a deterministical way.

void jafar::lines::LineSegment::interpolateLineRansac ( std::vector< LineSegment lines,
std::vector< CvPoint > &  points,
std::vector< double > &  pointGrads,
jafar::image::Image gradX,
jafar::image::Image gradY,
int  nPoints,
int  nIt,
double  minInlierRate,
double  minLength,
jafar::image::Image colorImage 
)

This function uses RANSAC to interpolate a set of points by lines.

This function uses RANSAC to interpolate a set of points by lines. Therefore nIt often two points of points are chosen and the line defined by the two points is calculated. The number of inliers is counted and compared to nPoints*minInlierRate. If its is larger or equal the validLine() Test is applyd. If it is passd, the line is put into lines. If colorImage is set, the lines are drawn on it.

static double jafar::lines::LineSegment::mahaDistLines ( LineSegment lA,
LineSegment lB,
double  varEP,
double  varDir,
double  varGrey,
double  varVGrey 
) [static]

Calculate Mahalanobis distance of two line segments. The components of the state vector are assumed to be uncorrelated. Line segments have to be oriented befor using this function. (Have a look at LineSegment::orientLine())

static int jafar::lines::LineSegment::mergeLinesEP ( LineSegment lsA,
LineSegment lsB 
) [static]

This function process a merging by connecting the endpoints of the line that defines the longest possible lineSegment.

This function process a merging by connecting the endpoints of the line that defines the longest possible lineSegment. If it return 3, the returned line is a new line (maybe you want to apply orientLine() on this new line) If it returns 2, both lines stay the same. It should be tested before if you want the lines to be merged (you can modify tryMergeLinesChiSq() function to combine these two steps)

static void jafar::lines::LineSegment::mergeLinesProb ( LineSegment lsA,
LineSegment lsB 
) [static]

Compute the "average" line of two lines.

Find average line parameters (weighted by the length of the lines) and calculate the projection of the endpoints on this line. Use the the extremal endpoints as new endpoints. It should be tested before if you want the lines to be merged (tryMergeLinesChiSq() function combines these two steps)

Normalize the histogram descriptor.

Normalize histogramB and histogramD to 1

Orient line with respect to the average greylevels on both sides of the line.

Calculate average greylevel on both sides of the line (on a parallel line at the distance 2) and arange ending points such that from (x1,y1) to (y2,x2) the brighter side is on the left. The members avL and avR are updated. The member oAlpha is updated. If one of the parallels used to calculate the average grey value on left and right side is completly out of image, both grey values are 0.

void jafar::lines::LineSegment::searchGradMax ( CvPoint  p1,
CvPoint  p2,
std::vector< CvPoint > &  points,
std::vector< double > &  pointGrads,
jafar::image::Image gradX,
jafar::image::Image gradY,
int  nPoints,
double  pDist 
)

This function searches for gradient maxima perpendicular to the line between p1 and p1.

This function searches for gradient maxima perpendicular to the line between p1 and p1. At the begining the function calcultes nPoints-often a search point on the line. These search points are distributed with equal distance over the line. From these points it searches for gradient maxima in the perpendicular direction to the line. The point on each side of the line with the maximal gradient is chosen and stored in points. Its gradient is stored in pointGrads. pDist is the maximum distance to the line in that is searched for maxima. gradX and gradY are [IPL_DEPTH_16S JfrImage_CS_GRAY] Jafar-Images with gradient in x and y direction, the gradient has to be signed.

Sets numberOfNeighbours and updates parallels.

Set numberOfNeighbours member. parallels is updated according to the relation between the old numberOfNeighbours and _number. If the new number is smaller, the appropriate parallels are deleted. If the new number is greater, the old parallels stay and memory for the new parallels is allocated. The LineSegment::setPoints function is called for the new parallels, but the desciptors are not set!

Parameters:
numberThe new numberOfNeighbours
void jafar::lines::LineSegment::setPoints ( double  _x1,
double  _y1,
double  _x2,
double  _y2,
bool  resetFlag = 1 
)

Sets point coordinates and initialises parallels.

This function sets points according to parameters. The coordinates of midpoint, slope, eucLength (Eulidean langth) and alpha ( angle to positiv x-axis) are calculated. Furthermore the parallel lines (LineSegment::parallels) are initialized with their setPoints-functions. The coordinates of start and endpoint of these parallel lines are calculated accordingly to the slope of the origin line. If abs(slope)<1 then the points are located above and under the origin points, otherwise left and right. The parallels are ordered alterning above - under (left - right) according to their index mod 2. oAlpha is set value according to direction (x1,y1)->(x2,y2) without respect to the image-gradients along the line, to set it according to the gradient, use orientLine() The resetFlag indicates if the predictor member is reinitialized.

void jafar::lines::LineSegment::setPrediction ( double  x1P,
double  y1P,
double  x2P,
double  y2P,
double  cov1xxP,
double  cov1xyP,
double  cov1yyP,
double  cov2xxP,
double  cov2xyP,
double  cov2yyP 
)

Set the prediction for the endpoints of that line.

Set the prediction for the endpoints of that line To indicate that there is a useful prediction, the predFlag of that LineSegment is set-

Parameters:
x1Pcoordinate of predicted endpoint
y1Pcoordinate of predicted endpoint
x2Pcoordinate of predicted endpoint
y2Pcoordinate of predicted endpoint
cov1xxPvariance of x1P
cov1yxPcorrelation of x1P and y1P
cov1yPvariance of y1P
cov2xxPvariance of x2P
cov2yxPcorrelation of x2P and y2P
cov2yPvariance of y2P
void jafar::lines::LineSegment::setPredictionPolar ( double  rho,
double  theta,
double  covRR,
double  covRT,
double  covTT 
) [inline]

Set the prediction for that line in polar coordinates.

Set the prediction for the infinite line of that line segment in polar coordinates. To indicate that there is a useful prediction, the predFlag of that LineSegment is set-

Parameters:
rhorho value of polar coordinates of the prediction
thetatheta value of polar coordinates of the predicition
covRRvariance of predicted rho
covRTcorrelation of predicted rho and theta
covTTvariance of predicted theta

Definition at line 429 of file lineSegment.hpp.

References covRRpred, covRTpred, covTTpred, predFlag, rhoPred, and thetaPred.

static double jafar::lines::LineSegment::sizeOfGap ( LineSegment lsA,
LineSegment lsB 
) [static]

Returns the size of the gap between two line segments.

Returns the size of the gap between two line segments. This is useful for merging. If the lines overlap, 0 is returned;

static int jafar::lines::LineSegment::tryMergeLinesChiSq ( LineSegment lA,
LineSegment lB,
double  maxGap = 0 
) [static]

Merges two lines on base of Chi2-Test.

Merges two lines on base of Chi2-Test. The return value indicates the number of results. If there is only one resulting line, it is stored in lA. If it return 3, the returned line is a new line (maybe you want to apply orientLine() on this new line) If it returns 2, both lines stay the same. Lines have to be oriented.


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