user3480291
user3480291

Reputation: 11

Finding the middle point of 2 parallel contours

Couldn't find this with search but I'm not sure how to describe this anyway, which is one reason the problems been so hard to find the right approach for. Sorry if its already been asked or if the problem description is to vague.

The problem: I am detecting the contours of a curving, painted physical path of consistent width from an image using opencv's findcontours. I need to map a vector of points in the middle of those 2 edges along the length of the path so as to trace the painted path with a single vector.

I was wondering if there is a way to find points within a certain pixel distance in the imagespace, in various other contours. I can iterate through them all, and find the closest ones that way, but thats time intensive. If there was I could search the other contour vectors for points about the right width away and use the 2 points to estimate a mid point and add that to the growing middle vector.

Or if theres a better approach to converting the detected path into a single, workable vector that would work to.

Upvotes: 0

Views: 256

Answers (1)

MSalters
MSalters

Reputation: 179779

Sounds like you're looking for the "skeleton" - it helps if you know the terms.

If you can transform the image into a black&white image that still shows the path, it's trivial: iterate the erosion procedure until no more points are eroded.

Another approach is to realize that the operation is expensive once, but once you've found one pair of points, the next pair is easily found in the respective 3x3 neighborhoods.

Upvotes: 1

Related Questions