Java image analysis - counting vertical lines

前端 未结 4 1905
星月不相逢
星月不相逢 2020-12-30 10:49

I need a little help on an image analysis algorithm in Java. I basically have images like this: \"alt

So

4条回答
  •  青春惊慌失措
    2020-12-30 11:09

    A simple segmentation algorithm can help you out. Heres how the algorithm works:

    • scan pixels from left to right and record the position of the first black (whatever the color of your line is) pixel.
    • carry on this process unless you find one whole scan when you don't find the black pixel. Record this position as well.
    • We are just interested in the Y positions here. Now using this Y position segment the image horizontally.
    • Now we are going to do the same process but this time we are going to scan from top to bottom (one column at a time) in the segment we just created.
    • This time we are interested in X positions.
    • So in the end we get every lines extents or you can say a bounding box for every line.
    • The total count of these bounding boxes is the number of lines.

    You can do many optimizations in the algorithm according to your needs.

提交回复
热议问题