Class MinimizeEnergyPrune


public class MinimizeEnergyPrune
extends Object

Prunes corners from a pixel level accuracy contour by minizing a penalized energy function. The energy of a line segment is defined as Euclidean distance squared of each point from the line summed plus a penalty divided by the distance between two end points of the line. When a corner is removed the location of its neighbors are optimized again.

Energy of line segment = [Sum( distance points from line squared) + penalty ] / (segment length)

  • Constructor Details

    • MinimizeEnergyPrune

      public MinimizeEnergyPrune​(double splitPenalty)
  • Method Details

    • prune

      public boolean prune​(List<Point2D_I32> contour, DogArray_I32 input, DogArray_I32 output)
      Given a contour and initial set of corners compute a new set of corner indexes
      contour - List of points in the shape's contour
      input - Initial set of corners
      output - Pruned set of corners
      true if one or more corners were pruned, false if nothing changed
    • energyRemoveCorner

      protected double energyRemoveCorner​(int removed, DogArray_I32 corners)
      Returns the total energy after removing a corner
      removed - index of the corner that is being removed
      corners - list of corner indexes
    • computeSegmentEnergy

      protected double computeSegmentEnergy​(DogArray_I32 corners, int cornerA, int cornerB)
      Computes the energy for a segment defined by the two corner indexes
    • getContour

      protected Point2D_I32 getContour​(int index)
    • circularDistance

      protected int circularDistance​(int start, int end)
      Distance the two points are apart in clockwise direction