4

I get edges from canny algorithm, but between lines are little spaces. I need to connect lines together and reduce this space. For example: example image

I work with opencv in Android.

Has anyone an idea how to do it?

RAM
  • 2,257
  • 2
  • 19
  • 41
user1247373
  • 173
  • 1
  • 11

1 Answers1

4

Consider using cvDilate() to dilate the image after canny is executed. This is one way to connect the line segments, and if the image gets too dilated for your purpose, you might want to execute Canny on the dilated image.

karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • but what if there is a large gap ? i mean if 3 of the 4 edges of the rectangle are detected perfectly and there is a huge gap in the 4th edge ? can dilation work in such situations and if yes ,what kernel structure should be used in this case ? – Ankur Gautam Jan 24 '14 at 08:21
  • @Ankur It depends on the input image. Do you have one to share? – karlphillip Jan 24 '14 at 17:28
  • @karlphillip please look at my original question.My target is to detect white paper document from an image(the main problem comes when the document is kept on the almost white background) http://stackoverflow.com/questions/21324950/how-to-select-the-best-set-of-parameters-in-canny-edge-detection-algorithm-imple – Ankur Gautam Jan 24 '14 at 17:37