views:

94

answers:

3

I want to find an algorithm which can find broken lines or shapes in a bitmap. consider a situation in which I have a bitmap with just two colors, back and white ( Images used in coloring books), there are some curves and lines which should be connected to each other, but due to some scanning errors, white bits sit instead of black ones. How should I detect them? (After this job, I want to convert bitmaps into vector file. I want to work with potrace algorithm).

If you have any Idea, please let me know.

+2  A: 

Here is a simple algorithm to heal small gaps:

First, use a filter which creates a black pixel when any of its eight neighbors is black. This will grow your general outline.

Next, use a thinning filter which removes the extra outline but leaves the filled gaps alone.

See this article for some filters and parameters: Image Processing Lab in C#

Aaron Digulla
+1  A: 

The simplest approach is to use a morphological technique called closing. This will work only if the gaps in the lines are quite small in relation to how close the different lines are to each other.

How you choose the structuring elemt to perform the closing can also make performance better or worse.

The Wikipedia article is very theoretical (or mathematical) so you might want to turn to Google or any book on Image Processing to get a better explanation on how it is done.

kigurai
+1  A: 

Maybe Hough Transform can help you. Bonus: you get the lines parameters for your vector file.

TH