square detection, image processing

一个人想着一个人 提交于 2019-12-22 13:30:24

问题


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...


回答1:


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.




回答2:


For inspiration, you can have a look at the

  • Matlab video sudoku solver demo and explanation
  • Sudoku Grab, an Iphone App, whose author explains the computer vision part on his blog

Alternatively, if you are always hunting for the same grid you could deploy something like this:

  • Make a perfect artificial template of the grid and detect or save all coordinates from all corners.
  • In the target image, do the same thing, for example with Harris points. Be creative, you might also be able to use the distinct triangles that can be found in your images.
  • Using the coordinates from the template and the found harris points, determine the affine transformation 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



来源:https://stackoverflow.com/questions/8164366/square-detection-image-processing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!