使用Java识别2个相同的图像 [英] Identifying 2 same images using Java

查看:148
本文介绍了使用Java识别2个相同的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网络抓取工具中遇到问题,我试图从特定网站检索图像。问题是我经常看到的是完全相同但URL不同的图像,即它们的地址。

I have a problem in my web crawler where I am trying to retrieve images from a particular website. Problem is that often I see images that are exactly same but different in URL i.e. their address.

是否有任何Java库或实用程序可以识别2个图像的内容是否完全相同(即像素级别)。

Is there any Java library or utility that can identify if 2 images are exactly same in their content (i.e. at pixel level).

我的输入将是我可以下载它们的图像的URL。

My input will be URLs for the images where I can download them.

推荐答案

我之前在Java中做过类似的事情,我发现 java.awt.image 包的api非常有帮助(如果不是非常必要的话)。

I've done something very similar to this before in Java and I found that the PixelGrabber class inside the java.awt.image package of the api is extremely helpful (if not downright necessary).

另外你肯定想看看 ColorConvertOp类,它可以对源图像中的数据执行逐像素颜色转换,并将得到的颜色值缩放到精度目的地形象。文档继续说,图像甚至可以是相同的图像,在这种情况下,检测它们是否相同是非常简单的。

Additionally you would definitely want to check out the ColorConvertOp class which can performs a pixel-by-pixel color conversion of the data in the source image and the resulting color values are scaled to the precision of the destination image. The documentation goes on to say that the images can even be the same image in which case it would be quite simple to detect if they are identical.

如果您检测到相似性,您需要使用某种形式的平均方法,如这个问题

If you were detecting similarity, you need to use some form of averaging method as mentioned in the answer to this question

如果可以的话,还可以查看Horstman的Core Java(第8版)第2卷第7章,因为有大量的例子图像转换等,但再次确保在java.awt.image包中找到它,因为您应该发现几乎所有东西都准备好了:)

If you can, also check out Volume 2 chapter 7 of Horstman's Core Java (8th ed) because there's a whole bunch of examples on image transformations and the like, but again, make sure to poke around the java.awt.image package because you should find you have almost everything prepared for you :)

G '运气!

这篇关于使用Java识别2个相同的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆