Comparing images in Go

xuanbao · · 436 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I have a use case where I have to match images even pixel by pixel will do fine, shall I iterate through each pixel and check if first one is equal to the second one?</p> <hr/>**评论:**<br/><br/>dlsniper: <pre><p>It depends on what you want to achieve. If you want to check that they are pixel identical, then yes. But the same image might be just a bit more different than the other because of a different compression setting/format. There really is no good way to answer without more details and even then it might not be easy to implement (if at all possible). What happens if the images are on a different resolution? </p></pre>thewhitetulip: <pre><p>Yes I agree to your concerns about resolutions, but in the scenario in which I am to work that is plain and simple, say if someone uploads the same image ten times, then we have to say that there are 9 duplicates</p></pre>dlsniper: <pre><p>Then why not simply crc32 them and see if the hashes match? Or some other fast checksum such as xxhash (if that works)? </p></pre>TheMerovius: <pre><p>The standard go image types (for example <a href="https://godoc.org/image#NRGBA" rel="nofollow">NRGBA</a>) export Pix, an array of bytes. Using <code>bytes.Compare</code> of those should be considerably faster.</p></pre>TheMerovius: <pre><p>Also, if you&#39;re after byte-by-byte duplicates you should store a hash of Pix along with your Image in your database and look for that hash instead. Otherwise this won&#39;t even remotely scale.</p></pre>lkjhgfds2: <pre><p>pHash is possibly what you want here. <a href="https://www.reddit.com/r/golang/comments/2wnns5/findimagedupes_use_phash_to_find_visually_similar/" rel="nofollow">There was a thread</a> about it some time ago.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

436 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传