图像相似度比较

发布于 2024-11-02 13:28:20 字数 778 浏览 1 评论 0原文

我最初在 cstheory.stackexchange.com 上提出这个问题,但建议将其移至 stats.stackexchange.com

是否有现有算法可以向我返回两个位图图像之间的相似性度量?我所说的“相似”是指人们会说这两张图像是根据同一张照片修改的。例如,算法应该说以下 3 个图像是相同的(原始、位置移动、缩小)。

相同

在此处输入图像描述 在此处输入图像描述 在此处输入图像描述

我不需要检测扭曲或翻转的图像。我也不需要检测它是否是不同方向的同一对象。

不同

在此处输入图像描述 “在此处输入图像描述”

我想使用此算法来防止我的网站上出现垃圾邮件。我注意到垃圾邮件发送者懒得更改他们的垃圾邮件图像。它不仅限于面孔。我已经知道已经有很多很棒的面部识别算法。垃圾邮件图像可以是任何内容,从 URL 到足球场再到裸体。

I originally asked this question on cstheory.stackexchange.com but was suggested to move it to stats.stackexchange.com.

Is there an existing algorithm that returns to me a similarity metric between two bitmap images? By "similar", I mean a human would say these two images were altered from the same photograph. For example, the algorithm should say the following 3 images are the same (original, position shifted, shrunken).

Same

enter image description here enter image description here enter image description here

I don't need to detect warped or flipped images. I also don't need to detect if it's the same object in different orientations.

Different

enter image description here enter image description here

I would like to use this algorithm to prevent spam on my website. I noticed that the spammers are too lazy to change their spam images. It's not limited to faces. I already know there's already many great facial recognition algorithms out there. The spam image could be anything from a URL to a soccer field to a naked body.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

假面具 2024-11-09 13:28:20

在堆栈溢出中有一个关于图像相似度算法的讨论。由于您不需要检测扭曲或翻转的图像,因此只要图像裁剪不太严重,直方图方法可能就足够了。

There is a discussion of image similarity algorithms at stack overflow. Since you don't need to detect warped or flipped images, the histogram approach may be sufficient providing the image crop isn't too severe.

冷默言语 2024-11-09 13:28:20

您可以使用 VGG 等现有深度学习架构从图像生成特征,然后使用余弦相似度等相似性度量来查看两个图像是否本质上相同。

整个管道非常容易设置,您不需要了解神经网络架构(您可以将其视为黑匣子)。此外,这些功能非常通用,可以应用于查找任何类型的对象之间的相似性,而不仅仅是面部。

这里有几个博客可以引导您完成整个过程。
http://blog.ethanrosenthal.com/2016/12/05/recasketch-喀拉斯/
https://erikbern.com/2015 /09/24/nearest-neighbor-methods-vector-models-part-1.html

You can use existing deep learning architectures like VGG to generate features from images and then use a similarity metric like cosine similarity to see if two images are essentially the same.

The whole pipeline is pretty easy to set up and you do not need to understand the neural network architecture (you can just treat it like a black box). Also, these features are pretty generic and can be applied to find similarity between any kind of objects, not just faces.

Here are a couple of blogs that walk you through the process.
http://blog.ethanrosenthal.com/2016/12/05/recasketch-keras/
https://erikbern.com/2015/09/24/nearest-neighbor-methods-vector-models-part-1.html

七月上 2024-11-09 13:28:20

Amazon 有一个名为 Rekognition 的新 API,它允许您比较两个图像的面部相似性。该 API 返回每张脸之间的相似度百分比以及每张脸的边界框。

Rekognition 还包括用于面部分析(返回性别、大致年龄和其他相关面部细节)和对象场景检测(返回图像中对象的标签)的 API。

Amazon has a new API called Rekognition which allows you to compare two images for facial similarity. The api returns a similarity percentage for each face with one another and the bounding boxes for each face.

Rekognition also includes an api for both Facial Analysis (returning the gender, approximate age, and other relevant facial details) and Object Scene Detection(returning tags of objects that are within in image).

征﹌骨岁月お 2024-11-09 13:28:20

计算图像相似度的一项重要技术是“平均结构相似度”。

import cv2
from skimage import compare_ssim


img = cv2.imread('img_1.png')
img_2 = cv2.imread('img_2.png')

print(compare_ssim(img, img_2))

One of the great technique to calculate similarity of images is "mean structural similarity".

import cv2
from skimage import compare_ssim


img = cv2.imread('img_1.png')
img_2 = cv2.imread('img_2.png')

print(compare_ssim(img, img_2))
柳若烟 2024-11-09 13:28:20

如果你只想要图像相似度,那是一回事,但面部相似度则是另一回事。两个截然不同的人可能出现在相同的背景中,并且图像相似性分析显示他们是相同的,而同一个人可以在两种不同的环境中拍摄,并且相似性分析显示他们是不同的。

如果您需要进行面部分析,您应该搜索特定的算法。这种分析通常会计算眼睛、鼻子和嘴巴的相对大小和位置。

If you just want image similarity that's one thing, but facial similarity is quite another. Two very different individuals could appear in the same background and an analysis of image similarity show them to be the same while the same person could be shot in two different settings and the similarity analysis show them to be different.

If you need to do facial analysis you should search for algorithms specific to that. Calculating relative eye, nose and mouth size and position is often done in this kind of analysis.

甜嗑 2024-11-09 13:28:20

使用 https://github.com/Netflix/vmaf 比较两组图像。

首先使用ffmpeg将图像转换为yuv422p,然后运行测试。注意分数差异。这可以用来判断图像是否相似或不同。对于这个示例,它们看起来非常相似...

ffmpeg -i .\different-pose-1.jpg  -s 1920x1080 -pix_fmt yuv422p different-pose-1.yuv
ffmpeg -i .\different-pose-2.jpg  -s 1920x1080 -pix_fmt yuv422p different-pose-2.yuv
.\vmafossexec.exe yuv422p 1920 1080 different-pose-1.yuv different-pose-2.yuv vmaf_v0.6.1.pkl --ssim --ms-ssim --log-fmt json --log different.json
Start calculating VMAF score...
Exec FPS: 0.772885
VMAF score = 2.124272
SSIM score = 0.424488
MS-SSIM score = 0.415149

ffmpeg.exe -i .\same-pose-1.jpg  -s 1920x1080 -pix_fmt yuv422p same-pose-1.yuv
ffmpeg.exe -i .\same-pose-2.jpg  -s 1920x1080 -pix_fmt yuv422p same-pose-2.yuv
.\vmafossexec.exe yuv422p 1920 1080 same-pose-1.yuv same-pose-2.yuv vmaf_v0.6.1.pkl --ssim --ms-ssim --log-fmt json --log same.json
Start calculating VMAF score...
Exec FPS: 0.773098
VMAF score = 5.421821
SSIM score = 0.285583
MS-SSIM score = 0.400130

参考文献 如何在 Ubuntu 上从 JPEG 或其他图像创建 YUV422 帧

Use https://github.com/Netflix/vmaf to compare the two sets of images.

First convert the images to yuv422p using ffmpeg and then run the test. Note the score difference. This can be used to tell if the image is similar or different. For this sample they both look quite similiar...

ffmpeg -i .\different-pose-1.jpg  -s 1920x1080 -pix_fmt yuv422p different-pose-1.yuv
ffmpeg -i .\different-pose-2.jpg  -s 1920x1080 -pix_fmt yuv422p different-pose-2.yuv
.\vmafossexec.exe yuv422p 1920 1080 different-pose-1.yuv different-pose-2.yuv vmaf_v0.6.1.pkl --ssim --ms-ssim --log-fmt json --log different.json
Start calculating VMAF score...
Exec FPS: 0.772885
VMAF score = 2.124272
SSIM score = 0.424488
MS-SSIM score = 0.415149

ffmpeg.exe -i .\same-pose-1.jpg  -s 1920x1080 -pix_fmt yuv422p same-pose-1.yuv
ffmpeg.exe -i .\same-pose-2.jpg  -s 1920x1080 -pix_fmt yuv422p same-pose-2.yuv
.\vmafossexec.exe yuv422p 1920 1080 same-pose-1.yuv same-pose-2.yuv vmaf_v0.6.1.pkl --ssim --ms-ssim --log-fmt json --log same.json
Start calculating VMAF score...
Exec FPS: 0.773098
VMAF score = 5.421821
SSIM score = 0.285583
MS-SSIM score = 0.400130

References How can I create a YUV422 frame from a JPEG or other image on Ubuntu

终陌 2024-11-09 13:28:20

强大的哈希函数可以做到这一点。但该领域仍有大量研究正在进行。我不确定是否已经有可用的原型。

希望有帮助。

Robust Hash Functions do that. But there's still a lot of research going on in that domain. I'm not sure if there are already usable prototypes.

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文