Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Member Functions | Private Member Functions | Private Attributes
icl::cv::RDPApproximation Class Reference

Ramer-Douglas-Peucker algorithm. More...

#include <RDPApproximation.h>

List of all members.

Classes

struct  ChainPoint

Public Member Functions

 RDPApproximation (float epsilon=0.1f, int max_corners=0, int search_iters=3)
 default constructor with given arguments
const std::vector
< utils::Point32f > & 
approximate (const std::vector< utils::Point > &poly, bool polygon=true)
 approximates a polygon
const std::vector
< utils::Point32f > & 
approximate (const std::vector< utils::Point32f > &poly, bool polygon=true)
const std::vector
< utils::Point32f > & 
approximate (const utils::Point *begin, const utils::Point *end, const int size, bool polygon=true)
void drawAllPoints (core::ImgBase *img, const icl64f &value)
 draws all points to the first channel of the given image with the given value
const std::vector
< utils::Point32f > & 
getLastApproximation () const
 returns the last approximation result
void setEpsilon (float value)
void setMaxCorners (float value)
void setSearchIterations (float value)
float getEpsilon () const
float getMaxCorners () const
float getSearchIterations () const

Private Member Functions

void approximateCurve (const ChainPoint *first, const ChainPoint *last)
 approximates a curve
int approximateCurveWithCap (const ChainPoint *first, const ChainPoint *last, int cap)
 tries to approximates a curve with a maximum number of points
void approximatePolygon (const ChainPoint *cps, const int size, bool polygon)
 approximates a polygon
void approximateWithCap (const ChainPoint *cps, const int size, bool polygon)
 approximates a rectangle if possible

Private Attributes

float epsilon
 parameters
int max_corners
int search_iters
std::vector< utils::Point32fapproximation
 result list

Detailed Description

Ramer-Douglas-Peucker algorithm.

The algorithm takes an array of contour points as input. If a polygon should be approximated, then the two farthest points are found approximately. This points divide the polygon in two curves. For all curves the following is done recursively: First the perpendicular distance is calculated between each point and the line, which contains the first and last point of the curve. Afterwards the maximum distance is compared with an epsilon. The algorithm divides the curve further if the value is higher than the epsilon. Otherwise the begin and end point are taken for the result approximation. (see http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm for more information)

Parameters for the algorithm are:


Constructor & Destructor Documentation

icl::cv::RDPApproximation::RDPApproximation ( float  epsilon = 0.1f,
int  max_corners = 0,
int  search_iters = 3 
) [inline]

default constructor with given arguments


Member Function Documentation

const std::vector<utils::Point32f>& icl::cv::RDPApproximation::approximate ( const std::vector< utils::Point > &  poly,
bool  polygon = true 
)

approximates a polygon

the param polygon shows, if the list is a polygon or a curve

const std::vector<utils::Point32f>& icl::cv::RDPApproximation::approximate ( const std::vector< utils::Point32f > &  poly,
bool  polygon = true 
)
const std::vector<utils::Point32f>& icl::cv::RDPApproximation::approximate ( const utils::Point begin,
const utils::Point end,
const int  size,
bool  polygon = true 
)
void icl::cv::RDPApproximation::approximateCurve ( const ChainPoint first,
const ChainPoint last 
) [private]

approximates a curve

int icl::cv::RDPApproximation::approximateCurveWithCap ( const ChainPoint first,
const ChainPoint last,
int  cap 
) [private]

tries to approximates a curve with a maximum number of points

the param cap shows how much points can be in between of the first and the last point

void icl::cv::RDPApproximation::approximatePolygon ( const ChainPoint cps,
const int  size,
bool  polygon 
) [private]

approximates a polygon

void icl::cv::RDPApproximation::approximateWithCap ( const ChainPoint cps,
const int  size,
bool  polygon 
) [private]

approximates a rectangle if possible

void icl::cv::RDPApproximation::drawAllPoints ( core::ImgBase img,
const icl64f value 
)

draws all points to the first channel of the given image with the given value

float icl::cv::RDPApproximation::getEpsilon ( ) const [inline]
const std::vector<utils::Point32f>& icl::cv::RDPApproximation::getLastApproximation ( ) const [inline]

returns the last approximation result

float icl::cv::RDPApproximation::getMaxCorners ( ) const [inline]
void icl::cv::RDPApproximation::setEpsilon ( float  value) [inline]
void icl::cv::RDPApproximation::setMaxCorners ( float  value) [inline]
void icl::cv::RDPApproximation::setSearchIterations ( float  value) [inline]

Member Data Documentation

result list

parameters


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