user1307376
user1307376

Reputation: 371

extract lines from image OpenCvSharp

Here i am trying to trace lines from image. i used below steps

  1. threshold image
  2. dilate image
  3. thinning of image
  4. findcontours from image

here i am getting vector lines at the both sides of edges of line. but i want to generate a single vector line at the middle of each line.

Any one one help me how to do this.

below is the result i got.

enter image description here

Upvotes: 0

Views: 888

Answers (1)

Darren
Darren

Reputation: 495

One approach is to use a thinning algorithm. A thinning algorithm basically takes a thick line and finds the middle (depending on the impelmentation) so you're left with a single line.

So you'd do something like this.

  1. Load Image
  2. Threshold Image
  3. Dilate Image
  4. Thin Image with some type of skeleton algorithm.

Here are a few links on thinning. They're not OpenCvSharp but could be ported.

Answers.OpenCV

http://answers.opencv.org/question/3207/what-is-a-good-thinning-algorithm-for-getting-the-skeleton-of-characters-for-ocr/

OpenCV-Code Blog by Nashruddin Amin

http://opencv-code.com/quick-tips/implementation-of-thinning-algorithm-in-opencv/

http://opencv-code.com/quick-tips/implementation-of-guo-hall-thinning-algorithm/

Upvotes: 1

Related Questions