Class Downsampling
All methods accept a sorted List<T extends Point> and return a List<T>,
preserving the concrete point type throughout. The input list must be sorted by
Point.getX() in monotonically non-decreasing order. No method mutates the input
list or its elements.
Algorithms:
lttb(java.util.List<T>, int)— Largest-Triangle Three-Buckets. Bucket-based; output size isbuckets + 2. Thebucketsparameter controls how many middle points are selected.rdp(java.util.List<T>, double)— Ramer-Douglas-Peucker. Distance-based; output size is data-driven. Theepsilonparameter is the minimum perpendicular distance for a point to be retained — larger values produce smaller outputs.pip(java.util.List<T>, int)— Perceptually Important Points. Iterative; output size is always exactlytargetSize. ThetargetSizeparameter is the desired total number of output points including first and last.
-
Method Summary
Modifier and TypeMethodDescriptionDownsamplesinputusing the Largest-Triangle Three-Buckets algorithm with theBucketizationStrategy.DYNAMICstrategy.lttb(List<T> input, int buckets, BucketizationStrategy strategy) Downsamplesinputusing the Largest-Triangle Three-Buckets algorithm with the specifiedBucketizationStrategy.Downsamplesinputusing the Perceptually Important Points algorithm.Downsamplesinputusing the Ramer-Douglas-Peucker algorithm.
-
Method Details
-
lttb
Downsamplesinputusing the Largest-Triangle Three-Buckets algorithm with theBucketizationStrategy.DYNAMICstrategy.The output contains
buckets + 2points: one selected from each middle bucket, plus the first and last points of the input.- Type Parameters:
T- the type of thePointelements- Parameters:
input- the sorted input list of pointsbuckets- the number of middle buckets (and therefore middle output points)- Returns:
- the downsampled list
-
lttb
public static <T extends Point> List<T> lttb(List<T> input, int buckets, BucketizationStrategy strategy) Downsamplesinputusing the Largest-Triangle Three-Buckets algorithm with the specifiedBucketizationStrategy.With
BucketizationStrategy.DYNAMICthe output contains exactlybuckets + 2points. WithBucketizationStrategy.FIXED, empty x-span intervals are skipped so the output may contain fewer thanbuckets + 2points.- Type Parameters:
T- the type of thePointelements- Parameters:
input- the sorted input list of pointsbuckets- the number of middle bucketsstrategy- the bucketization strategy to use- Returns:
- the downsampled list
-
rdp
Downsamplesinputusing the Ramer-Douglas-Peucker algorithm.The output size is determined by the data shape and
epsilon: every retained interior point has a perpendicular distance greater thanepsilonfrom the line connecting its enclosing retained neighbours. A largerepsilonretains fewer points;epsilon = 0retains all points.- Type Parameters:
T- the type of thePointelements- Parameters:
input- the sorted input list of pointsepsilon- the minimum perpendicular distance for a point to be retained- Returns:
- the downsampled list; always includes the first and last input points
-
pip
Downsamplesinputusing the Perceptually Important Points algorithm.The output contains exactly
targetSizepoints (or all input points iftargetSize >= input.size()). Points are selected greedily in order of decreasing perpendicular distance to their currently-selected neighbours.- Type Parameters:
T- the type of thePointelements- Parameters:
input- the sorted input list of pointstargetSize- the desired total number of output points, including first and last- Returns:
- the downsampled list
-