Douglas-Peucker Algorithm, line simplification by #of points

버전 1.1 (7.02 KB) 작성자: Peter Seibold
This algorithm keeps with fewer points the shape of the original track as good as possible without moving the remaining original points.
다운로드 수: 5
업데이트 날짜: 2024/8/21

라이선스 보기

DouglasPeuckerInv returns a simplifed curve with a target number of points and the epsilon to reach this target number.
It is sometimes not reversible, since sometimes no epsilon will satisfy a certain target number and sometimes a few points with smallest perpendicular distance are revomed directly, without Douglas-Peuker algorithm.
Input:
  • points: List of points, double, N x [X, Y]
You may add identifiers for the points, then List = N x [X, Y, id]
  • target: number of points for the output curve, integer number scalar.
Output:
  • PointsOut: List of points for the simplified curve, target x [X, Y],
or target x [X, Y, id] if identifiers were included.
  • epsilon: No original point has a larger perpendicular distance epsilon to the simplified curve.
The maximal perpendicular distance to the original is never larger than epsilon, but may be considerably smaller.
If you need the exact maximal perpendicular distance, run afterwards 'epsilonExact.m'.
Example:
X = [8; 4; 5; 1; 0; 4; 8; 12; 11];
Y = [0; -2; 2; 4; 10; 14; 8; 2; 0];
id = (1:9)';%identifier
Points = [X,Y,id];
target = 5;% Number of points for the resulting curve
[PointsOut, epsilon] = DouglasPeuckerInv(Points,target);
figure(1);
plot(X,Y,'.r-',PointsOut(:,1),PointsOut(:,2),'+b--');
grid on;
axis equal
A demo file is included.

인용 양식

Peter Seibold (2024). Douglas-Peucker Algorithm, line simplification by #of points (https://www.mathworks.com/matlabcentral/fileexchange/171584-douglas-peucker-algorithm-line-simplification-by-of-points), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2020a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.1

Small correction in respect of returned epsilon.

1.0.0