I have images like this ones:
In this images the red line is what I want to get from the image. Original images do not have that red lines, but only that green road.
What I want is to estimate the curve from image in form of a coeffitients of equation: A x^2 + B x + C = 0. In images there can be noise (black holes on edges as you see above).
I have tried to solve this by using least squares method (LSM), but there are two problems with this approach:
The method is too slow even on PC, because the points amount is high.
The road is too wide in the following case:
The curve on the left image is correctly recognized, but on the right side incorrectly. The reason is that the road is too wide and too short, I suppose.
As a solution for both cases I want to make the road narrow. In ideal case it is a red line in images above. Or I want to use LSM for line detection (A x + B = 0) for optimization of processing time.
I have tried eroding image - it is wrong approach. Skeleton also not the right solution.
Any ideas about how to achieve the desired result (make the road narrow)? Or any ideas of another approach for this problem?
Curve tracing and curve detection in images are important operations in image processing and computer vision. Their applications include road following, object tracking, fracture detection in borehole images and extraction of features from medical images.
Related work. Hough Transform (HT) is one of the most widely used algorithms for line detection [1], [2]. General Hough Transform (GHT) represents a modification of HT which is used to detect circles and even arbitrary curves [3].
The CurvatureAnalysis command visually evaluates surface curvature using false-color analysis. Note. ● These tools can be used to gain information about the type and amount of curvature on a surface. Gaussian and Mean curvature analysis can show if and where there may be anomalies in the curvature of a surface.
If you can rely on always having one axis as the dependent variable in your fit (looks like it should be the x
axis in the above "correct" examples, although your bottom right failure seems to be using y
), then you could do something like this:
y
, pick the median x
of the non-black pixelsYou now have a list of (x,y)
pairs, at most as many as there are scan lines. These represent guesses as to the midpoint of the road at each level. Fit a low order polynomial x=f(y)
(I'd go for linear or cubic, but you could do quadratic if you prefer) to these points by least squares.
For the sorts of images you've shown, the detail is very coarse, so you might be able to manage with just a subset of points. But even without that the processing cost should be reasonable unless you're using very constrained hardware.
If left-right paths occur often then you could fit both ways and then apply some kind of goodness of fit criterion. If paths loop back on themselves often, then this sort of midpoint approach won't give you a good answer, but then you're onto a loser with the fitting anyway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With