mbedward / jaitools

Raster image processing for Java developers
17 stars 15 forks source link

Improved contour simplification #205

Open mbedward opened 11 years ago

mbedward commented 11 years ago

Original author: michael.bedward@gmail.com (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:

  1. Find largest contour envelope based on length of diagonal E_d
  2. Calculate a distance tolerance as Max(E_d) * parameter_value
  3. 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

mbedward commented 11 years ago

From michael.bedward@gmail.com 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.

mbedward commented 11 years ago

From michael.bedward@gmail.com 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.