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

Class to manipulate a set of edge segments. More...

#include <line_segment_set.h>

Inheritance diagram for kjb::Edge_segment_set:
kjb::Readable kjb::Writeable

Public Member Functions

 Edge_segment_set ()
 
 Edge_segment_set (const std::vector< Edge_segment > &isegments)
 
 Edge_segment_set (const kjb::Edge_set *edge_set, const std::vector< Line_segment > &isegments)
 
 Edge_segment_set (const kjb::Edge_set *edge_set, bool use_num_pts_as_length=true)
 
 Edge_segment_set (const kjb::Edge_set *edge_set, const char *filename)
 
 Edge_segment_set (const kjb::Edge_set *edge_set, std::istream &in)
 
 Edge_segment_set (const Edge_segment_set &src)
 
Edge_segment_setoperator= (const Edge_segment_set &iseg)
 
 ~Edge_segment_set ()
 
void init_from_edge_set (const kjb::Edge_set *edge_set, bool use_num_pts_as_length=true)
 
const std::vector< Edge_segment > & get_segments ()
 
unsigned int size () const
 
const Edge_segmentget_segment (unsigned int i) const
 returns the ith fitted line segment More...
 
void add_segment (const Edge_segment &isegment)
 Adds a line segment to this collection. More...
 
const kjb::Edgeget_edge (unsigned int i)
 returns the ith collection of edge points the segments were fitted to More...
 
void draw (kjb::Image &img, double ir, double ig, double ib, double width=1.0) const
 Draws this line segment set. More...
 
void randomly_color (kjb::Image &img, double width=1.0) const
 Randomly colors this line segment set on an image. More...
 
void read (std::istream &in, const kjb::Edge_set *edge_set)
 Reads this Edge_segment_set from an input stream. More...
 
void read (const char *filename, const kjb::Edge_set *edge_set)
 Reads this Edge_segment_set from an input file. More...
 
void read (std::istream &in)
 Reads this Edge_segment_set from an input stream. More...
 
void read (const char *fname)
 Reads this Edge_segment_set from an input file. More...
 
void write (std::ostream &out) const
 Writes this Edge_segment_set to an output stream. More...
 
void write (const char *fname) const
 Writes this Edge_segment_set to a file. More...
 
void remove_overlapping_segments (kjb::Edge_set &edges, double collinear_threshold=0.12, double overlapping_threshold=10)
 In case there are multiple roughly collinear edge segments, only the longest one is kept. This function is mostly for debug purposes. More...
 
void remove_non_straight_segments (kjb::Edge_set &edges, double threshold)
 
void remove_frame_segments (unsigned int num_rows, unsigned int num_cols, kjb::Edge_set &edges)
 
kjb::Edge_setconvert_to_edge_set (unsigned int num_rows, unsigned int num_cols)
 
void find_vertical_segment_pairs (std::vector< Segment_pair > &pairs, int num_rows) const
 
- Public Member Functions inherited from kjb::Readable
virtual ~Readable ()
 Deletes this Readable. More...
 
- Public Member Functions inherited from kjb::Writeable
virtual ~Writeable ()
 Deletes this Writeable. More...
 

Additional Inherited Members

- 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...
 

Detailed Description

Class to manipulate a set of edge segments.

Constructor & Destructor Documentation

kjb::Edge_segment_set::Edge_segment_set ( )
inline
kjb::Edge_segment_set::Edge_segment_set ( const std::vector< Edge_segment > &  isegments)
inline
Edge_segment_set::Edge_segment_set ( const kjb::Edge_set edge_set,
const std::vector< Line_segment > &  isegments 
)
Edge_segment_set::Edge_segment_set ( const kjb::Edge_set edge_set,
bool  use_num_pts_as_length = true 
)

Constructs a fitted_edge_segment_set from a set of detected edges

Parameters
edge_setthe detected edges
Edge_segment_set::Edge_segment_set ( const kjb::Edge_set edge_set,
const char *  filename 
)

Constructs an edge segment set by reading it from an input stream. The input edge_set is necessary to bind the fitted segments to the original detected edges

Parameters
edge_setset of edges fitted to the line segments to be read
filenamethe input file to read this edge segment set from
Edge_segment_set::Edge_segment_set ( const kjb::Edge_set edge_set,
std::istream &  in 
)

Constructs an edge segment set by reading it from an input stream. The input edge_set is necessary to bind the fitted segments to the original detected edges

Parameters
edge_setset of edges fitted to the line segments to be read
inthe input stream to read this edge segment set from
kjb::Edge_segment_set::Edge_segment_set ( const Edge_segment_set src)
inline
kjb::Edge_segment_set::~Edge_segment_set ( )
inline

Member Function Documentation

void kjb::Edge_segment_set::add_segment ( const Edge_segment isegment)
inline

Adds a line segment to this collection.

kjb::Edge_set * Edge_segment_set::convert_to_edge_set ( unsigned int  num_rows,
unsigned int  num_cols 
)
void Edge_segment_set::draw ( kjb::Image img,
double  ir,
double  ig,
double  ib,
double  width = 1.0 
) const

Draws this line segment set.

Draws the line segment on an image

Parameters
imgthe image
irthe red channel
igthe green channel
ibthe blue channel
widththe width of the segment to be drawn (in pixel)
void Edge_segment_set::find_vertical_segment_pairs ( std::vector< Segment_pair > &  pairs,
int  num_rows 
) const
const kjb::Edge& kjb::Edge_segment_set::get_edge ( unsigned int  i)
inline

returns the ith collection of edge points the segments were fitted to

const Edge_segment& kjb::Edge_segment_set::get_segment ( unsigned int  i) const
inline

returns the ith fitted line segment

const std::vector<Edge_segment>& kjb::Edge_segment_set::get_segments ( )
inline

Returns a vector containing the fitted line segments

void Edge_segment_set::init_from_edge_set ( const kjb::Edge_set edge_set,
bool  use_num_pts_as_length = true 
)
inline

Initialize this edge_segment_set from an edge_set. It fit an edge segment to each of the input edges in the input Edge_set

Parameters
edge_setthe input Edge_set
Edge_segment_set& kjb::Edge_segment_set::operator= ( const Edge_segment_set iseg)
inline
void Edge_segment_set::randomly_color ( kjb::Image img,
double  width = 1.0 
) const

Randomly colors this line segment set on an image.

Draws the line segment set using a different random color for each segment

Parameters
imgthe image
widththe width of the segment to be drawn (in pixel)
void Edge_segment_set::read ( std::istream &  in,
const kjb::Edge_set edge_set 
)

Reads this Edge_segment_set from an input stream.

Read an edge segment set from an input stream. The input edge_set is necessary to bind the fitted segments to the original detected edges

Parameters
edge_setset of edges fitted to the line segments to be read
inthe input stream to read this edge segment set from
void Edge_segment_set::read ( const char *  filename,
const kjb::Edge_set edge_set 
)

Reads this Edge_segment_set from an input file.

Read an edge segment set from an input file. The input edge_set is necessary to bind the fitted segments to the original detected edges

Parameters
edge_setset of edges fitted to the line segments to be read
inthe input file to read this edge segment set from
void Edge_segment_set::read ( std::istream &  in)
virtual

Reads this Edge_segment_set from an input stream.

Reads this Edge_segment_set from an input stream. Not implemented

Implements kjb::Readable.

void kjb::Edge_segment_set::read ( const char *  fname)
inlinevirtual

Reads this Edge_segment_set from an input file.

Reimplemented from kjb::Readable.

void Edge_segment_set::remove_frame_segments ( unsigned int  num_rows,
unsigned int  num_cols,
kjb::Edge_set edges 
)

In case there are multiple roughly collinear edge segments, only the longest one is kept. This function is mostly for debug purposes

Parameters
edgesThe edge_set this edge_segment_set was built from
void Edge_segment_set::remove_non_straight_segments ( kjb::Edge_set edges,
double  threshold 
)
void Edge_segment_set::remove_overlapping_segments ( kjb::Edge_set edges,
double  collinear_threshold = 0.12,
double  overlapping_threshold = 10 
)

In case there are multiple roughly collinear edge segments, only the longest one is kept. This function is mostly for debug purposes.

In case there are multiple roughly collinear edge segments, only the longest one is kept. This function is mostly for debug purposes

Parameters
edgesThe edge_set this edge_segment_set was built from
unsigned int kjb::Edge_segment_set::size ( ) const
inline

Returns the number of segments in this set

void Edge_segment_set::write ( std::ostream &  out) const
virtual

Writes this Edge_segment_set to an output stream.

Implements kjb::Writeable.

void kjb::Edge_segment_set::write ( const char *  fname) const
inlinevirtual

Writes this Edge_segment_set to a file.

Reimplemented from kjb::Writeable.


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