KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Friends | List of all members
kjb::Edge_segment Class Reference

#include <edge_segment.h>

Inheritance diagram for kjb::Edge_segment:
kjb::Line_segment kjb::Readable kjb::Writeable

Public Member Functions

 Edge_segment (const kjb::Edge &iedge, bool use_num_pts_as_length=true)
 
 Edge_segment (const kjb::Edge &iedge, const kjb::Line_segment &ls)
 
 Edge_segment (const kjb::Edge &iedge, std::istream &in)
 
 Edge_segment (const Edge_segment &src)
 
Edge_segmentoperator= (const Edge_segment &src)
 
 ~Edge_segment ()
 
bool operator== (const Edge_segment &edg)
 
const kjb::Edgeget_edge ()
 returns the set of edge points this line segment was fit to More...
 
kjb::Edge_point get_edge_point (unsigned int i)
 
double get_least_squares_fitting_error () const
 returns the sum of square residuals between the edge points and the fitted line segment. More...
 
double get_strength () const
 returns the average gradient magnitude of this edge More...
 
void read (std::istream &in)
 Reads this Edge_segment from an input stream. More...
 
void write (std::ostream &out) const
 Writes this Edge_segment to an output stream. More...
 
bool is_overlapping (const Edge_segment &es, double collinear_threshold=0.12, double overlapping_threshold=10) const
 Returns true if the edge_segments are overlapping, ie one is mostly contained in the other. More...
 
void set_edge (const kjb::Edge &iedge_pts)
 Sets the pointer to the edge points this edge_segment was fit to. More...
 
- Public Member Functions inherited from kjb::Line_segment
 Line_segment ()
 Constructor without initializations. More...
 
 Line_segment (double icentre_x, double icentre_y, double iorientation, double ilength)
 Constructs a new Line_segment from centre, orientation, length. More...
 
 Line_segment (const Vector &start, const Vector &end)
 Constructs a new Line_segment from a starting and ending point. More...
 
 Line_segment (std::istream &in)
 Constructs this line segment by reading from an input stream. More...
 
 Line_segment (const Line_segment &ls)
 Copy constructor. More...
 
Line_segmentoperator= (const Line_segment &ls)
 Assignment operator. More...
 
bool operator== (const Line_segment &ls) const
 
bool operator< (const Line_segment &ls) const
 
void init_from_slope_and_intercept (double x_start, double x_end, double islope, double iintercept)
 Initialize from x_start, x_end, slope, y_axis intercept. More...
 
void init_vertical_segment (double y_start, double y_end, double x)
 Initialize a vertical Line_segment from y_start, y_end, x coord. More...
 
void init_from_end_points (double x_1, double y_1, double x_2, double y_2)
 Initialize a new Line_segment from position of its end points. More...
 
void init_from_centre_and_orientation (double icentre_x, double icentre_y, double iorientation, double ilength)
 
double get_centre_x () const
 Returns the x-coordinate of the mid-point. More...
 
double get_centre_y () const
 Returns the y-coordinate of the mid-point. More...
 
bool point_outside_segment (const Vector &point) const
 Check whether point is inside the ending points of this segment Note point is collinear with this line segment. More...
 
const kjb::Vectorget_centre () const
 Returns the mid-point. More...
 
double get_start_x () const
 Returns the x-coordinate of the leftmost point of the segment. More...
 
double get_start_y () const
 Returns the y-coordinate of the leftmost point of the segment. More...
 
const kjb::Vectorget_start () const
 Returns the leftmost point of the segment. More...
 
double get_end_x () const
 Returns the x-coordinate of the rightmost point of the segment. More...
 
double get_end_y () const
 Returns the y-coordinate of the rightmost point of the segment. More...
 
const kjb::Vectorget_end () const
 Returns the rightmost point of the segment. More...
 
double get_slope () const
 Returns the slope of the line segment. More...
 
double get_y_intercept () const
 Returns the y-intercept of the line segment. More...
 
double get_x_intercept () const
 Returns the x-intercept of the line segment. More...
 
const Vectorget_line_params () const
 
const Lineget_line () const
 
double get_orientation () const
 Returns the orientation. More...
 
double get_length () const
 Returns the length. More...
 
void read (std::istream &in)
 Reads this Line segment from an input stream. More...
 
void write (std::ostream &out) const
 Writes this Line segment to an output stream. More...
 
void draw (kjb::Image &img, double ir, double ig, double ib, double width=1.0) const
 Draws this line segment. More...
 
void randomly_color (kjb::Image &img, double width=1.0) const
 Randomly colors this line segment on an image. More...
 
bool get_intersection (const Line_segment &line, kjb::Vector &point) const
 Finds the intersection point of the this line_segment and the input Line_segment line. Return false if these two lines are parallel and therefore do not intersect. More...
 
double get_distance_from_point (const kjb::Vector &point) const
 Returns distance between this line segment and the input point. More...
 
double get_angle_between_line (const Line_segment &line) const
 Returns the angle between this line segment and the input line. More...
 
double find_t (const kjb::Vector &point) const
 
double get_distance_from_point (const kjb::Vector &point, double *perp_dist) const
 Returns distance between this line segment and the input point. More...
 
double get_dx () const
 Returns the dx of this segment. More...
 
double get_dy () const
 Returns the dy of this segment. More...
 
bool is_horizontal () const
 Function object of testing whehter a line is horizontal. More...
 
bool is_vertical () const
 Function object of testing whehter a line is horizontal. More...
 
void get_direction (kjb::Vector &idirection) const
 Returns a vector representing the normalized direction of this line_segment. More...
 
bool is_line_segment_consistent ()
 
bool is_collinear (const Line_segment &ls, double collinear_threshold) const
 
- Public Member Functions inherited from kjb::Readable
virtual ~Readable ()
 Deletes this Readable. More...
 
virtual void read (const char *fname)
 Reads this Readable from a file. More...
 
- Public Member Functions inherited from kjb::Writeable
virtual ~Writeable ()
 Deletes this Writeable. More...
 
virtual void write (const char *fname) const
 Writes this Writeable to a file. More...
 

Friends

std::ostream & operator<< (std::ostream &out, const Edge_segment &es)
 

Additional Inherited Members

- Static Public Member Functions inherited from kjb::Line_segment
static std::pair< Vector, Vectorproject_line_segment_onto_line (const Line_segment &segment, const Line &iline)
 Project a line segment onto a line. More...
 
static bool project_line_segment_onto_line_segment (const Line_segment &segment_project, const Line_segment &segment_target, std::pair< Vector, Vector > &projected_points, double &length_inside, double &length_outside)
 Project a line segment onto a line segment. More...
 
static bool less_than (const Vector &point1, const Vector &point2)
 Returns true if point1.x < point2.x || (point1.x == point2.x && point1.y < point2.y. More...
 
static bool collision_detection (double start_1, double end_1, double start_2, double end_2, int &direction, double &delta)
 
static bool collision_detection_with_direction (double start_1, double end_1, double start_2, double end_2, int &direction, double &delta, int idirection)
 
static double get_overlap (double start_1, double end_1, double start_2, double end_2)
 
- Static Public Member Functions inherited from kjb::Readable
static const char * read_field_value (std::istream &in, const char *field_name, char *field_buf, size_t buf_len, char separator=':')
 Reads a line off in into a buffer and returns a pointer to the field value in the buffer. More...
 
static const char * read_field_value (std::istream &in, const char *field_name, char separator=':')
 Reads a line off in into an internal buffer and returns a pointer to the field value in the buffer. More...
 
- Protected Member Functions inherited from kjb::Line_segment
void compute_extrema ()
 Computes the extrema of this line segments from centre, orientation, and length. This information is redundant, but it can be very useful to have them pre-computed. More...
 
void compute_line_parameters ()
 
- Protected Attributes inherited from kjb::Line_segment
kjb::Vector centre
 X coordinate of the centre of this line segment. More...
 
double orientation
 Orientation of this line segment, defined as the angle between the x axis and the segment, positive angle meaning counter clockwise. Ranges between 0 and 180 degrees. Stored in radian. More...
 
double length
 length of the line segment More...
 
kjb::Vector start_point
 
kjb::Vector end_point
 
Line line
 
- Static Protected Attributes inherited from kjb::Line_segment
static Matrix _line_segment_rotation
 

Detailed Description

manipulate a line segment associated to an edge detected in an image. We fit a line segment to the edge points associated to an edge detected in the image. This class offers all the functionalities of a line segment, and contains a pointer to the edge points the line segment was fit to. The line segment is fit to the edge points using least squares, the error being computed as the sum of the squares of the perpendicular distances between each point and the fit line.

Constructor & Destructor Documentation

kjb::Edge_segment::Edge_segment ( const kjb::Edge iedge,
bool  use_num_pts_as_length = true 
)
inline
Parameters
iedgethe detected image edge
use_num_pts_as_lengthwhen this option is true, use the number of edge points as the length.
kjb::Edge_segment::Edge_segment ( const kjb::Edge iedge,
const kjb::Line_segment ls 
)
inline
Edge_segment::Edge_segment ( const kjb::Edge iedge,
std::istream &  in 
)
Parameters
iedgethe detected image edge
inthe input stream to read this edge_segment from
kjb::Edge_segment::Edge_segment ( const Edge_segment src)
inline
kjb::Edge_segment::~Edge_segment ( )
inline

Member Function Documentation

const kjb::Edge& kjb::Edge_segment::get_edge ( )
inline

returns the set of edge points this line segment was fit to

kjb::Edge_point kjb::Edge_segment::get_edge_point ( unsigned int  i)
inline

@ brief returns the ith edge point forming this edge segment

double kjb::Edge_segment::get_least_squares_fitting_error ( ) const
inline

returns the sum of square residuals between the edge points and the fitted line segment.

double kjb::Edge_segment::get_strength ( ) const
inline

returns the average gradient magnitude of this edge

bool Edge_segment::is_overlapping ( const Edge_segment es,
double  collinear_threshold = 0.12,
double  overlapping_threshold = 10 
) const

Returns true if the edge_segments are overlapping, ie one is mostly contained in the other.

Returns true if the edge_segments are overlapping, ie one is mostly contained in the other. Two segments are considered overlapping if their cross product is close to zero (meaning they are parallel) AND they are very close to each other AND the projection of one almost fully falss onto the other

Parameters
esThe edge segment to check against
Edge_segment& kjb::Edge_segment::operator= ( const Edge_segment src)
inline
bool kjb::Edge_segment::operator== ( const Edge_segment edg)
inline
void Edge_segment::read ( std::istream &  in)
virtual

Reads this Edge_segment from an input stream.

Reads this Edge_segment from an input stream.

Parameters
inThe input stream to read this edge segment from

Implements kjb::Readable.

void kjb::Edge_segment::set_edge ( const kjb::Edge iedge_pts)
inline

Sets the pointer to the edge points this edge_segment was fit to.

Parameters
iedge_ptsThe pointer to the edge points
void Edge_segment::write ( std::ostream &  out) const
virtual

Writes this Edge_segment to an output stream.

Writes this Edge_segment to an output stream.

Parameters
Theoutput stream to write this Edge segment to

Implements kjb::Writeable.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const Edge_segment es 
)
friend

The documentation for this class was generated from the following files: