正方形检测、图像处理
我正在寻找一种有效的方法来检测数字周围的小框(参见图片)? 我已经尝试使用霍夫变换但没有成功。有什么想法吗?我需要一些提示!我正在使用opencv...
I am looking for an efficient way to detect the small boxes around the numbers (see images)?
I already tried to use hough transformation with no success. Any ideas? I need some hints! I am using opencv...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如需灵感,您可以查看
或者,如果您总是在寻找相同的网格,您可以部署如下内容:
x = Ax'
。然后可以使用该转换将模板网格映射到目标图像上。至少,这将为您提供一些先验信息,以帮助指导进一步的细分。仿射矩阵
A
估计的思想要点和示例可以在 Zissermans 的书 计算机视觉中的多视图几何 和 彼得·科维西For inspiration, you can have a look at the
Alternatively, if you are always hunting for the same grid you could deploy something like this:
x = Ax'
between the template and the target image. That transformation can then be used to map the template grid onto the target image. At the very least this will give you some prior information to help guide further segmentation.The gist of the idea and examples of the estimation of affine matrix
A
can be found on the site of Zissermans book Multiple View Geometry in Computer Vision and Peter Kovesi我首先尝试检测整个纸张的矩形边界,然后应用透视变换使其成为真正的矩形。裁剪掉图像的该部分。如果可能的话,尝试使交替的白色和灰色子矩形具有相同的背景亮度 - 也许可以尝试 自适应直方图均衡。
那么霍夫变换可能会表现得更好。或者,您可以采用与 Robert Bemis 在 MATLAB Central 上进行的演示(它分析的是 DNA 微阵列图像而不是乐透卡,但它本质上是查找排列在网格中的项目的边界框)。在较高层面上,该方法是计算沿像素列和行的自相关性,以检测网格中项目的周期性,并使用它对每个项目施加边界框。
抱歉,以上建议主要是基于 MATLAB 的;恐怕我不是 opencv 用户,但希望它至少能给你一些想法。
I'd start by trying to detect the rectangular boundary of the overall sheet, then applying a perspective transform to make it truly rectangular. Crop that portion of the image out. If possible, then try to make the alternating white and grey sub-rectangles have an equal background brightness - maybe try adaptive histogram equalization.
Then the Hough transform might perform better. Alternatively, you could then take an approach that's broadly similar to this demonstration by Robert Bemis on MATLAB Central (it's analysing a DNA microarray image rather than Lotto cards, but it's essentially finding bounding boxes of items arranged in a grid). At a high level, the approach is to calculate the autocorrelation along columns and rows of pixels to detect the periodicity of the items in the grid, and use that to impose a bounding box on each item.
Sorry the above advice is mostly MATLAB-based; I'm afraid I'm not an opencv user, but hopefully it will give you some ideas at least.