findLocalMaxima

fun RectifiedContour.findLocalMaxima(samples: Int, windowSize: Double, f: ShapeContour.(Double) -> Double): List<LocalMaximum>(source)

Finds local maxima of f sampled along RectifiedContour, using arc-length-uniform sampling so that windowSize (expressed as a fraction of curve length) means the same thing everywhere on the contour, regardless of how unevenly the original contour's segments are distributed.

Parameters

samples

number of evenly arc-length-spaced samples to scan

windowSize

the size of the local neighborhood used to decide whether a sample is a maximum, as a fraction of the total curve length (e.g. 0.05 = 5% of the curve's length on each side... actually total window width, see below)

f

a function evaluated on the ORIGINAL ShapeContour at a given ut, e.g. ShapeContour::curvature or a custom metric