I have continuous digital curves that are close to a line segment, except maybe at both ends.
How would you delimit the linear section (say remove the red parts) ? The solution needn't be very accurate, but fast.
I have continuous digital curves that are close to a line segment, except maybe at both ends.
How would you delimit the linear section (say remove the red parts) ? The solution needn't be very accurate, but fast.
There is an algorithm called Douglas-Peucker, which takes a curve described by points (or rather the straight lines between them) and simplifies it to be described by fewer points. The output is an approximation consisting of longer straight lines.
I would walk along your line, extracting the coordinates of each pixel in the right order, then apply Douglas-Peucker. The longest line segment in the output will be the one you need to keep. The trick there is to find the right parameter to the algorithm (the parameter is the maximum distance allowed between the approximation and the original line).