vigra - Geometry

[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

| Geometry |

## Classes
class | Polygon< POINT >

## Functions
double | arcLengthQuantile (double quantile) const
bool | closed () const
| Returns true iff the last and first points are equal or the polygon is empty.
bool | contains (const_reference point, coordinate_type tolerance) const
template<class PointArray1 , class PointArray2 >
void | convexHull (const PointArray1 &points, PointArray2 &convex_hull)
| Compute convex hull of a 2D polygon. More...
template<class T , class S , class PointArray >
void | extractContour (MultiArrayView< 2, T, S > const &label_image, Shape2 const &anchor_point, PointArray &contour_points)
| Create a polygon from the interpixel contour of a labeled region. More...
template<class Point , class T , class S , class Value >
void | fillPolygon (Polygon< Point > const &p, MultiArrayView< 2, T, S > &output_image, Value value)
| Render closed polygon p into the image output_image. More...
Point | interpolate (unsigned int index, double offset) const

## Detailed Description

## Function Documentation

Point interpolate | ( | unsigned int | index,
|  | double | offset
| ) |  | const

Linearly interpolate at `offset` between knots `index` and `index+1`.

Preconditions: `0 <= index < size()-1` and `0 <= offset <= 1`.

bool contains | ( | const_reference | point,
|  | coordinate_type | tolerance
| ) |  | const

Tests whether the given point lies within this polygon. Requires that this polygon is closed.

Points which lie directly on the polylines or coincide with a knot are considered inside (this behavior is consistent with fillPolygon()). Parameter tolerance (interpreted as an absolute error bound) controls the numerical accuracy of this test.

double arcLengthQuantile | ( | double | quantile | ) | const

Find the point on the polygon that corresponds to the given quantile.

quantile must be in `[0.0, 1.0]`. The result of this function can be used as input to `interpolate()`. For example, the following code computes the point in the middle of the polygon:

double c = poly.arcLengthQuantile(0.5);
Point center = poly.interpolate((int)floor(c), c - floor(c));

void vigra::extractContour | ( | MultiArrayView< 2, T, S > const & | label_image,
|  | Shape2 const & | anchor_point,
|  | PointArray & | contour_points
| ) |  |

Create a polygon from the interpixel contour of a labeled region.

The point anchor_point must be in the region whose contour we want to extract, and must be adjacent to the contour. The algorithm uses the 'left hand on the wall' algorithm to trace the connected component whose label equals the label of the anchor_point. The contour is returned in countour_points as a closed polygon that circles the region counter-clockwise in the image coordinate system (i.e. the coordinate system where x points to the right and y points downwards). Since the resulting polygon represents the interpixel contour, all points will have one integer and one half-integer coordinate.

void vigra::convexHull | ( | const PointArray1 & | points,
|  | PointArray2 & | convex_hull
| ) |  |

Compute convex hull of a 2D polygon.

The input array points contains a (not necessarily ordered) set of 2D points whose convex hull is to be computed. The array's `value_type` (i.e. the point type) must be compatible with std::vector (in particular, it must support indexing, copying, and have `size() == 2`). The points of the convex hull will be appended to the output array convex_hull (which must support `std::back_inserter(convex_hull)`). Since the convex hull is a closed polygon, the first and last point of the output will be the same (i.e. the first point will simply be inserted at the end again). The points of the convex hull will be ordered counter-clockwise, starting with the leftmost point of the input. The function implements Andrew's Monotone Chain algorithm.

void vigra::fillPolygon | ( | Polygon< Point > const & | p,
|  | MultiArrayView< 2, T, S > & | output_image,
|  | Value | value
| ) |  |

Render closed polygon p into the image output_image.

All pixels on the polygon's contour and in its interior are set to the given value. Parts of the polygon outside the image region are clipped. The function uses a robust X-intersection array algorithm that is able to handle all corner cases (concave and self-intersecting polygons, knots on integer coordinates).

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.11.1 (Fri May 19 2017)