Shape optimizer, which removes points within close range to shapes' body.

Namespace:  AForge.Math.Geometry
Assembly:  AForge.Math (in AForge.Math.dll) Version: (


public class LineStraighteningOptimizer : IShapeOptimizer


This shape optimizing algorithm checks all points of the shape and removes those of them, which are in a certain distance to a line connecting previous and the next points. In other words, it goes through all adjacent edges of a shape and checks what is the distance between the corner formed by these two edges and a possible edge, which could be used as substitution of these edges. If the distance is equal or smaller than the specified value, then the point is removed, so the two edges are substituted by a single one. When optimization process is done, the new shape has reduced amount of points and none of the removed points are further away from the new shape than the specified limit.

The shape optimizer does not optimize shapes to less than 3 points, so optimized shape always will have at least 3 points.

For example, the below circle shape comprised of 65 points, can be optimized to 8 points by setting MaxDistanceToRemove to 10.

Inheritance Hierarchy


See Also