Clear Filters
Clear Filters

Extracting key points from a set of contour points

7 views (last 30 days)
I extracted points (x and y coordinates) from the contour plot (Please, find attached x and y coordinates). I want to mark and extract the set of key points (that is, those points where the features change from straight line to fillet and fillet to straight line). This is the procedure:
1. Beginning with the starting point of a boundary loop, compute the four slopes of the lines between the first point and the following four points.
slope 12 = (y2 - y1)/(x2 - x1)
slope 13 = (y3 - y1)/(x3 - x1)
slope 14 = (y4 - y1)/(x4 - x1)
slope 15 = (y5 - y1)/(x5 - x1)
2. If these slopes change beyond a threshold (threshold = 0.5), then the previous feature (that is, straight line or fillet) ends at the point where a large slope change occurs (threshold > 0.5), and the first point is marked and extracted as a key point.
3. Otherwise, no key point can be found among the current five points.
4. With the newly located key point, or the fifth point, the slopes of next five points will be examined in the same way, until the corresponding boundary loop ends.
5. Save the key points to workspace and plot them.
Please, kindly help me to translate this to Matlab code. Thank you.

Answers (1)

Vijay Anand
Vijay Anand on 18 Jan 2018
[latout,lonout] = reducem(latin,lonin) [latout,lonout] = reducem(latin,lonin,tol) [latout,lonout,cerr] = reducem(...) [latout,lonout,cerr,tol] = reducem(...)
Description [latout,lonout] = reducem(latin,lonin) reduces the number of points in vector map data. In this case the tolerance is computed automatically.
[latout,lonout] = reducem(latin,lonin,tol) uses the provided tolerance. The units of the tolerance are degrees of arc on the surface of a sphere.
[latout,lonout,cerr] = reducem(...) in addition returns a measure of the error introduced by the simplification. The output cerr is the difference in the arc length of the original and reduced data, normalized by the original length.
[latout,lonout,cerr,tol] = reducem(...) also returns the tolerance used in the reduction, which is useful when the tolerance is computed automatically

Community Treasure Hunt

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

Start Hunting!