在图像中找到完全相同的模板
我想在输入图像中找到一个字符。当我从图像中裁剪炭并使用模板匹配时,几乎在所有情况下,它都可以完美。但是,如果我将该模板用于另一个图像,并以较小的char形状出现失败。
这是我的问题:如何在与模板类似的图像中找到对象,但是斜率或线厚度有些略有不同?模板匹配有什么办法,还是根据您的经验建议其他方法?
我将感谢任何相关的答案。
I want to find a character in my input image. When I crop char from an image and use template matching, in almost all cases, it works perfect; but if I use that template for another image with a little different shape of char it fails.
This is my question: How can I find object in my images similar to my template but with a little variety in slope or line thickness or ... ? Is there any way with template matching or do you suggest another methods according to your experience?
I will appreciate any related answer in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您在这里面临模板匹配的限制。似乎您已经在使用正确的度量标准(归一化互相关)。也许您可以做的最后一件事是检查5个模板:一个“完美”一个(从完美的图像中获取)和4个旋转版本。然后,对于每个模板,您都会找到最佳的匹配,然后将5个最佳匹配互相比较以选择其中的最好。
根据您想要投资的时间以及您希望完成的鲁棒性水平,您也可以使用神经网络!它将成为解决此问题的更强大方法。当然,有一些神经网络训练了角色检测,例如在这里,还有一些可用的教程< a href =“ https://pyimagesearch.com/2018/08/20/opencv-text-detection-east-east-east-text-detector/” rel =“ nofollow noreferrer”>喜欢这个。
如果您不想使用NN,则可以想到另一种可以与线路检测一起使用的方法。一个“/”字符具有相当特征的形状:一个封闭的路径,以一定角度旋转,围绕一个单轴旋转,“惯性”。这很容易用检测到的封闭形状的某些数学特性来描述。这种方法称为形状描述符,并且被描述(例如)在这里/a>。我认为,如果您对文本的大小有一些了解,并且图像质量相当好,那么这种“低级”方法具有一定的潜力。它通常效果很好。
我希望这可以帮助您解决问题。
I think you are facing a limitation of template matching here. It seems like you are already using the right metric (normalised cross-correlation). Maybe one last thing you can do is to check for 5 templates: a 'perfect' one (take from a perfect image) and 4 rotated versions. Then, for each template you find the best match, and then compare the 5 best matches against each other to pick the best of them.
Depending on how much time you want to invest, and what robustness level you wish to accomplish, you can also use Neural Network ! It will b the more robust approach to this problem. Of course, there are some neural network trained for character detection, for instance here, and some available tutorial like this one.
If you don't want to use NN, you could think of another method which could work with line detection. A '/' character has a quite characteristic shape: a closed path, rotated with a certain angle, with 'inertia' around one single axis. That is easy to describe with some mathematical properties of the detected closed shape. This approach is called shape descriptor and is described (for instance) here. I think that if you have some knowledge on the size of the text, and pretty good image quality, then this 'low-level' approach has some potential. It often works really well.
I hope this helps you to solve your problem.