How could I make the discontinuous contour of an image consistant?

后端 未结 6 1275
孤街浪徒
孤街浪徒 2021-02-04 15:32

In the task, I got an discontinuous edge image, how could make it closed? in other word make the curve continuous. And the shape could be any kind, cause this the coutour shadow

6条回答
  •  佛祖请我去吃肉
    2021-02-04 16:17

    My proposal:

    • find the endpoints; these are the pixels with at most one neighbor, after a thinning step to discard "thick" endpoints. Endpoints should come in pairs.

    • from all endpoints, grow a digital disk until you meet another endpoint which is not the peer.

    Instead of growing a disk, you can preprocess the set of endpoints and prepare it for a nearest-neighbor search (2D-tree for instance). You will need to modify the search to avoid hitting the peer.

    This approach does not rely on standard functions, but it has the advantage to respect the original outline.

    On the picture, the original pixels are in white or in green when they are endpoints. The yellow pixels are digital line segments drawn between the nearest endpoint pairs.

提交回复
热议问题