Java图像分析 - 计算垂直线 [英] Java image analysis - counting vertical lines

查看:228
本文介绍了Java图像分析 - 计算垂直线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个帮助在Java中的图像分析算法。我基本上有这样的图像:


$ b $



你认为最好的方法是什么?



谢谢,
Smaug

解决方案

一个简单的分割算法可以帮助你。了解算法的工作原理:




  • 从左到右扫描像素,
    记录第一个
    黑色的位置(无论你的
    行的颜色是什么)像素。

  • 继续这个过程
    ,除非你找到一个整体扫描,当
    时没有找到黑色像素。

  • 我们是
    只是对Y位置感兴趣
    在这里。现在使用这个Y位置
    水平分段图像。

  • 现在
    我们将执行相同的过程
    ,但是这次我们要从上到下扫描
    (一列为
    time)。

  • 这次我们对X
    位置感兴趣。

  • 所以最后我们得到每个
    行扩展,或者你可以为每一行指定一个
    边界框。

  • 这些边框的
    总计数
    是行数。



您可以根据需要在算法中进行许多优化。


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

So, as you might guessed, I need to count the lines.

What approach do you think would be best?

Thanks, Smaug

解决方案

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.

这篇关于Java图像分析 - 计算垂直线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆