如何实现Java图像处理做模板匹配?
我做了很多搜索,但找不到任何解决方案。
我有一个图像(假设它是 400*400),并且我有一小部分(133*133),我想找到大图像中小图像片段的起点(x,y)。
换句话说,我希望能够知道小图像位于大图像内的位置。
有什么建议如何使用java实现它而不使用外部库吗?
I've been doing a lot of searching and i could not find any solution.
I've an image ( assume it's 400*400) and i have a small piece of it (133*133) i want to locate where is the starting point (x,y) of the small image piece in the large image.
in another word i want to be able to know where the small image is located inside the big image.
any suggestions how to implement it using java without using external libraries?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的方法是迭代所有可能的起点并计算(平方和)差异< /a> 模板和图像之间。
但这是极其低效的。您应该研究频域过滤并实现您自己的快速傅里叶变换(即使使用自制的 FFT 算法处理也应该快得多而不是计算每个点的差异)。
The simplest way is to iterate through all possible starting points and calculate the (sum of squared) differences between the template and the image.
This is horribly inefficient, though. You should look into filtering in the frequency domain and implement your own Fast Fourier Transform (even with a home made FFT algorithm processing should be far faster than calculating differences at each point).