简单的图像识别:网格上的黑白石头
我目前想知道一个图像识别问题,这个问题应该很简单,但到目前为止还找不到一个简单的解决方案。
输入是一张约 1 兆像素的矩形图片,显示浅色木质表面。它上面有一个薄但可见的网格。网格呈黑黑色,规则且几乎呈正方形(长比宽约8%)。网格大小正好是 19x19。一般板的颜色是“木色”,它可能会有所不同,但往往是浅棕色。 (更多信息)
表面放置着许多小而圆、黑白相间的石头。它们总是放置在交叉路口,但由于人为错误,它们可能会稍微偏离。它们的颜色是纯黑色和白色。
棋盘上覆盖有 0 到大约 300 个棋子(361 个交叉点的 80%)。黑色和白色石子的数量大约相同。
边界(未放置棋子的棋盘边缘)的大小各不相同,但已知为“小”。
光线可能会导致棋盘上出现石头的阴影。此外,它还会导致石头上出现一个白点(沿光的方向)。
我想检测网格上石头的位置。
我的想法是查看每个像素的亮度,并将它们分为 3 类:浅色(白色石头)、中等(木板)和深色(黑色石头)。具有许多黑色像素的区域被认为是黑色石头,等等。
之后,可以使用黑色和白色区域的大小来计算实际网格大小。
另一个想法是识别网格线并使用它们来计算网格大小和位置。由于线条非常细(并且经常被石头覆盖),我不知道该怎么做。
我很想听听您对这个问题的想法。有没有看起来合适的算法?你能想出一些很有帮助的酷技巧吗?我是不是疯了,这个问题无法解决?我正在使用 C# 工作,但欢迎使用任何语言。
I'm currently wondering about an image recognition problem that is supposed to be easy, but could not find an easy solution so far.
Input is a rectangular picture of something around 1 megapixel that shows a light, wooden surface. It has a thin, but visible grid on it. The grid is of black black color, regular and almost squared (about 8% longer than wide). The grid size is exactly 19x19. The general board color is "wood", it can vary but tend to be a light brown-ish. (more info)
There are lots of small, round, black and white stones placed on the surface. They are always placed on the intersections, but due to human error they may be slightly off. Their color is pure black and white.
The board is covered by 0 to around 300 stones (80% of 361 intersections). The number of black and white stones is about the same.
The size of the border (edges of the board where no stones are ever placed) varies, is but known to be "small".
Light may cause shadows of stones to appear on the board. Also, it causes a single white dot to appear on the stones (in the direction of the light).
I'd like to detect the position of the stones on the grid.
My idea would be to look at the brightness of each pixel and sort them into 3 classes: light (white stones), medium (board) and dark (black stones). Areas with many black pixels are considered to be black stones, and so on.
Afterwards, the size of the black and white areas could be used to calculate the actual grid size.
Another idea is to recognize the grid lines and use them to, well, calculate the grid size and position. Since the lines are very thin (and often covered by stones), I'm not sure how to do that.
I'd love to hear you ideas on this issue. Are there algorithms that seem fitting? Can you think of cool tricks that help greatly? Am I insane and this problem is unsolvable? I'm working in C# but any language is welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您将在此处找到一些信息,包括一些 OpenCV原语:
我也在用 OpenCV 和一个小电子板制作交互式五子棋(OpenCV 用于识别,标准 LED 用于指示对手走法)。
祝您发展愉快!
You'll find here some information, including some OpenCV primitives:
I am also on the road to make with OpenCV and a small electronic board an interactive Goban (OpenCV for recognition, standard LEDs for opponent moves indication).
Have fun in your development!
也不要错过gocam。它附带源代码和一篇解释算法的论文:http://users.ics.aalto .fi/thirsima/gocam/
您可以在 kifu-snap 的网站上找到一系列链接和论文:http://www.remi-coulom.fr/kifu-snap/
最近一个非常好的结果是 PhotoKifu:
http://www.oipaz.net/PhotoKifu.html
Also don't miss gocam. It comes with source code and a paper to explain the algorithms: http://users.ics.aalto.fi/thirsima/gocam/
You'll find a collection of links and papers on the web site of kifu-snap: http://www.remi-coulom.fr/kifu-snap/
A really nice recent result is PhotoKifu:
http://www.oipaz.net/PhotoKifu.html
这称为blob 分析。基本上,您根据要匹配的颜色对图像进行二值化,然后对二值图像应用斑点查找算法以查找斑点的坐标。你猜对了,每个斑点都是一块石头。
和往常一样,我相信 OpenCV 拥有做到这一点的一切。
This is called blob analysis. Basically you binarize your image based on the color of what you want to match, and then apply blob-finding algorithm on the binary image to find the coordinates of the blobs. You guessed right, each blob is a stone.
As usual I believe OpenCV has everything to do this.