简体   繁体   English

如何比较 Java 中的两个图像?

[英]How can I compare two images in Java?

I have 5 images by default in the program, and I will allow the user choose an image from the desktop.我的程序默认有 5 张图片,我将允许用户从桌面选择一张图片。 The program will determine which image between the 5 images is the closest one to the user image.该程序将确定 5 张图像中的哪张图像最接近用户图像。

Can anyone help me and take me to the start of the idea?任何人都可以帮助我并带我开始这个想法吗?

You can try to use a feature extraction algorithm like SIFT , SURF etc. Then compare extracted features with your database.您可以尝试使用SIFTSURF等特征提取算法。然后将提取的特征与您的数据库进行比较。 You can select the best matching image based on the number of correct matches.您可以根据正确匹配的数量 select 最佳匹配图像。

Generally SIFT works fine for 2D objects, like picture of a label or an advertisement board.通常 SIFT 可以很好地处理 2D 对象,例如 label 的图片或广告牌。 Rotation on 2D plane or scale wont matter if you are using SIFT.如果您使用 SIFT,则在 2D 平面或比例上的旋转无关紧要。 SURF is supposed to be an improvement of SIFT but I do not have much experience on it. SURF 应该是对 SIFT 的改进,但我没有太多经验。

These algorithms are said to be bit heavy.据说这些算法有点重。 Anyway if you are matching just 5 images it wont be much of a problem.(Or you can simply calculate the descriptors(features) of your images before hand and store them. Then at run time all you have to do is get the descriptor of the user image and compare it) But still if you are trying to match images of basic shapes like squares and circles, using square detection or circle detection might be efficient performance wise.无论如何,如果您只匹配 5 张图像,那将不是什么大问题。(或者您可以简单地预先计算图像的描述符(特征)并存储它们。然后在运行时您所要做的就是获取描述符用户图像并进行比较)但是,如果您尝试匹配正方形和圆形等基本形状的图像,则使用正方形检测或圆形检测可能会提高性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM