/**
* Determines the closest level change (i.e. edge) to a given sample, which
* is useful for e.g. the "snap to edge" functionality.
/**
* Determines the closest level change (i.e. edge) to a given sample, which
* is useful for e.g. the "snap to edge" functionality.