質問

I have images like this ones:

enter image description here enter image description here enter image description here enter image description here

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:

  1. The method is too slow even on PC, because the points amount is high.

  2. 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. enter image

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?

役に立ちましたか?

解決

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:

  • for each scanline y, pick the median x of the non-black pixels
  • if there are no non-black pixels (or fewer than some chosen noise threshold), skip the line

You 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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top