Image Component Library (ICL)
|
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::Point32f > | approximation |
result list More... | |
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:
|
inline |
default constructor with given arguments
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 |
||
) |
|
private |
approximates a curve
|
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
|
private |
approximates a 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
|
inline |
|
inline |
returns the last approximation result
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
result list
|
private |
parameters
|
private |
|
private |