Image Component Library (ICL)
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
icl::cv::RDPApproximation Class Reference

Ramer-Douglas-Peucker algorithm. More...

#include <RDPApproximation.h>

Classes

struct  ChainPoint
 

Public Member Functions

 RDPApproximation (float epsilon=0.1f, int max_corners=0, int search_iters=3)
 default constructor with given arguments More...
 
const std::vector< utils::Point32f > & approximate (const std::vector< utils::Point > &poly, bool polygon=true)
 approximates a polygon More...
 
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 More...
 
const std::vector< utils::Point32f > & getLastApproximation () const
 returns the last approximation result More...
 
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 More...
 
int approximateCurveWithCap (const ChainPoint *first, const ChainPoint *last, int cap)
 tries to approximates a curve with a maximum number of points More...
 
void approximatePolygon (const ChainPoint *cps, const int size, bool polygon)
 approximates a polygon More...
 
void approximateWithCap (const ChainPoint *cps, const int size, bool polygon)
 approximates a rectangle if possible More...
 

Private Attributes

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

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

◆ RDPApproximation()

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

◆ approximate() [1/3]

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

◆ approximate() [2/3]

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

◆ approximate() [3/3]

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

◆ approximateCurve()

void icl::cv::RDPApproximation::approximateCurve ( const ChainPoint first,
const ChainPoint last 
)
private

approximates a curve

◆ approximateCurveWithCap()

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

◆ approximatePolygon()

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

approximates a polygon

◆ approximateWithCap()

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

approximates a rectangle if possible

◆ drawAllPoints()

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

◆ getEpsilon()

float icl::cv::RDPApproximation::getEpsilon ( ) const
inline

◆ getLastApproximation()

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

returns the last approximation result

◆ getMaxCorners()

float icl::cv::RDPApproximation::getMaxCorners ( ) const
inline

◆ getSearchIterations()

float icl::cv::RDPApproximation::getSearchIterations ( ) const
inline

◆ setEpsilon()

void icl::cv::RDPApproximation::setEpsilon ( float  value)
inline

◆ setMaxCorners()

void icl::cv::RDPApproximation::setMaxCorners ( float  value)
inline

◆ setSearchIterations()

void icl::cv::RDPApproximation::setSearchIterations ( float  value)
inline

Member Data Documentation

◆ approximation

std::vector<utils::Point32f> icl::cv::RDPApproximation::approximation
private

result list

◆ epsilon

float icl::cv::RDPApproximation::epsilon
private

parameters

◆ max_corners

int icl::cv::RDPApproximation::max_corners
private

◆ search_iters

int icl::cv::RDPApproximation::search_iters
private

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