jaitools
jaitools copied to clipboard
Improved contour simplification
Original author: [email protected] (October 05, 2012 00:58:57)
At the moment, the Contour operation simplifies contours by removing co-linear vertices. Martin Davis points out that this is overly conservative and that in many cases more vertices could be removed with very little effect on contour path.
Replace the current simplification step with use of the JTS DouglasPeuckerSimplifier and add an extra parameter to ContourDescriptor for the degree of simplification. This parameter value will be treated as follows:
- Find largest contour envelope based on length of diagonal E_d
- Calculate a distance tolerance as Max(E_d) * parameter_value
- Use this distance tolerance for simplification of all contours
Later, we might investigate using an alternative, faster simplifying algorithm.
Original issue: http://code.google.com/p/jaitools/issues/detail?id=207
From [email protected] on October 05, 2012 02:55:41 The new parameter will have a default value (e.g. 0.001 = 0.1% of largest contour envelope diagonal)
Setting the parameter to zero will give the same algorithm as present, ie. just remove co-linear vertices.
From [email protected] on October 06, 2012 08:43:16 Looks like it might be best to move the simplification step out of the Segments class and do it in the OpImage class instead. That way we can also put it after any Bezier smoothing.