Search code examples
graphicsquartz-graphicsedge-detection

Differentiate table line from big letters


I'm doing some graphics processing and I have a logic where in I have a bitmap with edges and I disregard all table edges from the letters E.g.

0000000000
0111111110
0100000010
0102220010
0100200010
0100200010
0100000010
0111111110
0000000000

0 - background color
1 - ignored edges
2 - edges I need

My logic is just simple, if a number of continuous pixels exceeds a certain threshold, e.g. 20pixels of continuous edges, it will consider it as a line and disregard it.

My problem is that on big font size and letters such as H and T, it will definitely exceed the threshold. Please advise is there a better way or additional logic i need to implement in order to separate table lines from letters.

[update] Additional consideration: Performance, this logic will be used during touch movement (dragging). It will be called a lot of times so it needs to be fast.


Solution

  • If table lines are guaranteed to be thin, then ignore thick lines. However, if the lines in your application are generated by edge detection (which are always 1-pixel thin) then connected-component will be needed.

    Basically, the "thickness" refers to thickness measured from an edge profile:

    • 00000000100000000 This line has thickness 1
    • 00000011111000000 This line has thickness 5. However, this cannot occur in the output of edge detection, because edge detection algorithms are specifically designed to remove this condition.
    • 00000000111111111 This is a transition from black to white.

    Table lines usually have small thickness. Large fonts usually have transition from black to white because their thickness is larger than the edge profile window.