圖像相似度匹配——距離大全


https://blog.csdn.net/lly1122334/article/details/89431244

 

說明:

PIL.Image讀取圖片並resize同一尺寸
scipy.spatial.distance庫計算距離(也可用sklearn.metrics.pairwise_distances)
距離越小越匹配
文章目錄
一、測試圖片
二、歐氏距離
三、曼哈頓距離
四、切比雪夫距離
五、余弦距離
六、皮爾遜相關系數
七、漢明距離
八、傑卡德距離
九、布雷柯蒂斯距離
十、馬氏距離
十一、JS散度
十二、image-match匹配庫
十三、不裝庫匹配
十四、利用Keras預訓練模型提取特征進行匹配
腳本
總結
參考文獻
一、測試圖片
圖片來源見下方鏈接。

 

1.jpg 分辨率604×900


2.jpg 分辨率423×640

 

3.jpg 分辨率900×750


4.jpg 分辨率404×600

 

 

二、歐氏距離
d = ∑ i = 1 N ( x i 1 − x i 2 ) 2 d=\sqrt{\sum_{i=1}^N{\left( x_{i1}-x_{i2} \right) ^2}}d=

i=1
N

(x
i1

−x
i2

)
2


點到點的距離,越大越不匹配

考慮權值:標准歐氏距離,seuclidean
平方:歐式距離平方,sqeuclidean

import numpy as np
from PIL import Image
from scipy.spatial.distance import pdist


def euclidean(image1, image2):
X = np.vstack([image1, image2])
return pdist(X, 'euclidean')[0]


image1 = Image.open('image/1.jpg')
image2 = Image.open('image/2.jpg')
image2 = image2.resize(image1.size)
image1 = np.asarray(image1).flatten()
image2 = np.asarray(image2).flatten()

print(euclidean(image1, image2))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
圖片 1 2 3 4
1 0 40819 99266 42672

 


三、曼哈頓距離
d = ∑ i = 1 N ∣ x i 1 − x i 2 ∣ d=\sum_{i=1}^N{| x_{i1}-x_{i2} | }d=∑
i=1
N

∣x
i1

−x
i2

又稱城市街區距離,兩坐標軸距離之和

考慮權值:堪培拉距離,canberra。用於比較排名列表和計算機安全入侵檢測

import numpy as np
from PIL import Image
from scipy.spatial.distance import pdist


def manhattan(image1, image2):
X = np.vstack([image1, image2])
return pdist(X, 'cityblock')[0]


image1 = Image.open('image/1.jpg')
image2 = Image.open('image/2.jpg')
image2 = image2.resize(image1.size)
image1 = np.asarray(image1).flatten()
image2 = np.asarray(image2).flatten()

print(manhattan(image1, image2))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
圖片 1 2 3 4
1 0 41122193 97631252 39064477
堪培拉距離:

圖片 1 2 3 4
1 0 497302 848611 354084

 


四、切比雪夫距離
d = ∑ i = 1 N ( max ⁡ ( ∣ x i 1 − x i 2 ∣ , ∣ y i 1 − y i 2 ∣ ) ) d=\sum_{i=1}^N{\left( \max \left( |x_{i1}-x_{i2}|,|y_{i1}-y_{i2}| \right) \right)}d=∑
i=1
N

(max(∣x
i1

−x
i2

∣,∣y
i1

−y
i2

∣))

各座標數值差絕對值的最大值,取值范圍為0-255

import numpy as np
from PIL import Image
from scipy.spatial.distance import pdist


def chebyshev(image1, image2):
X = np.vstack([image1, image2])
return pdist(X, 'chebyshev')[0]


image1 = Image.open('image/1.jpg')
image2 = Image.open('image/2.jpg')
image2 = image2.resize(image1.size)
image1 = np.asarray(image1).flatten()
image2 = np.asarray(image2).flatten()

print(chebyshev(image1, image2))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
圖片 1 2 3 4
1 0 218 255 204

 


五、余弦距離
d = ∑ i = 1 N ( x i 1 x i 2 + y i 1 y i 2 ( x i 1 2 + y i 1 2 ) ( x i 2 2 + y i 2 2 ) ) d=\sum_{i=1}^N{\left( \frac{x_{i1}x_{i2}+y_{i1}y_{i2}}{\sqrt{\left( x_{i1}^{2}+y_{i1}^{2} \right) \left( x_{i2}^{2}+y_{i2}^{2} \right)}} \right)}d=∑
i=1
N

(
(x
i1
2

+y
i1
2

)(x
i2
2

+y
i2
2

)


x
i1

x
i2

+y
i1

y
i2



)

又稱余弦相似度,根據向量方向來判斷向量相似度

運算速度超級慢

import numpy as np
from PIL import Image
from scipy.spatial.distance import pdist


def cosine(image1, image2):
X = np.vstack([image1, image2])
return pdist(X, 'cosine')[0]


image1 = Image.open('image/1.jpg')
image2 = Image.open('image/2.jpg')
image2 = image2.resize(image1.size)
image1 = np.asarray(image1).flatten()
image2 = np.asarray(image2).flatten()

print(cosine(image1, image2))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
圖片 1 2 3 4
1 0 0.0715 0.4332 0.0782

 


六、皮爾遜相關系數
d = ∑ i = 1 N ( x i 1 − x ˉ 1 ) ( x i 2 − x ˉ 2 ) ∑ i = 1 N ( x i 1 − x ˉ 1 ) 2 ∑ i = 1 N ( x i 2 − x ˉ 2 ) 2 d=\frac{\sum_{i=1}^N{\left( x_{i1}-\bar{x}_1 \right) \left( x_{i2}-\bar{x}_2 \right)}}{\sqrt{\sum_{i=1}^N{\left( x_{i1}-\bar{x}_1 \right) ^2}}\sqrt{\sum_{i=1}^N{\left( x_{i2}-\bar{x}_2 \right) ^2}}}d=

i=1
N

(x
i1


x
ˉ

1

)
2




i=1
N

(x
i2


x
ˉ

2

)
2




i=1
N

(x
i1


x
ˉ

1

)(x
i2


x
ˉ

2

)

與余弦相似度類似,並且具有平移不變性的優點,越大越相關

import numpy as np
from PIL import Image


def pearson(image1, image2):
X = np.vstack([image1, image2])
return np.corrcoef(X)[0][1]


image1 = Image.open('image/1.jpg')
image2 = Image.open('image/2.jpg')
image2 = image2.resize(image1.size)
image1 = np.asarray(image1).flatten()
image2 = np.asarray(image2).flatten()

print(pearson(image1, image2))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
圖片 1 2 3 4
1 1 0.8777 0.0850 0.7413
皮爾遜距離 = 1 - 皮爾遜相關系數

import numpy as np
from PIL import Image
from scipy.spatial.distance import pdist


def manhattan(image1, image2):
X = np.vstack([image1, image2])
return pdist(X, 'correlation')[0]


image1 = Image.open('image/1.jpg')
image2 = Image.open('image/2.jpg')
image2 = image2.resize(image1.size)
image1 = np.asarray(image1).flatten()
image2 = np.asarray(image2).flatten()

print(manhattan(image1, image2))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

 


七、漢明距離
d = ∑ i = 1 N ( { 1 , x i 1 = x i 2 0 , x i 1 ≠ x i 2 ) d=\sum_{i=1}^N{\left( \left\{ \right. \right)}d=∑
i=1
N

({
1, x
i1

=x
i2


0, x
i1




=x
i2



)

通過比較向量每一位是否相同,若不同則漢明距離加1

一般用於信息編碼

import numpy as np
from PIL import Image


def hamming(image1, image2):
return np.shape(np.nonzero(image1 - image2)[0])[0]


image1 = Image.open('image/1.jpg')
image2 = Image.open('image/2.jpg')
image2 = image2.resize(image1.size)
image1 = np.asarray(image1)
image2 = np.asarray(image2)

print(hamming(image1, image2))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
圖片 1 2 3 4
1 0 0.9865 0.9933 0.9853

 


八、傑卡德距離
d = A △ B ∣ A ∪ B ∣ d=\frac{A\bigtriangleup B}{\left| A\cup B \right|}d=
∣A∪B∣
A△B

兩個集合中不同元素占所有元素的比例來衡量,其相似度=1-d

import numpy as np
from PIL import Image
from scipy.spatial.distance import pdist


def jaccard(image1, image2):
X = np.vstack([image1, image2])
return pdist(X, 'jaccard')[0]


image1 = Image.open('image/1.jpg')
image2 = Image.open('image/2.jpg')
image2 = image2.resize(image1.size)
image1 = np.asarray(image1).flatten()
image2 = np.asarray(image2).flatten()

print(jaccard(image1, image2))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
圖片 1 2 3 4
1 0 0.9865 0.9936 0.9853

 


九、布雷柯蒂斯距離
生態學中用來衡量不同樣地物種組成差異的測度

import numpy as np
from PIL import Image
from scipy.spatial.distance import pdist


def braycurtis(image1, image2):
X = np.vstack([image1, image2])
return pdist(X, 'braycurtis')[0]


image1 = Image.open('image/1.jpg')
image2 = Image.open('image/2.jpg')
image2 = image2.resize(image1.size)
image1 = np.asarray(image1).flatten()
image2 = np.asarray(image2).flatten()

print(braycurtis(image1, image2))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
圖片 1 2 3 4
1 0 0.2008 0.4877 0.1746

 


十、馬氏距離
協方差距離,考慮各種特性之間的聯系

兩兩之間計算,計算量過大

import numpy as np
from PIL import Image
from scipy.spatial.distance import pdist


def mahalanobis(image1, image2):
X = np.vstack([image1, image2])
XT = X.T
return pdist(XT, 'mahalanobis')


image1 = Image.open('image/1.jpg')
image2 = Image.open('image/2.jpg')
image2 = image2.resize(image1.size)
image1 = np.asarray(image1).flatten()
image2 = np.asarray(image2).flatten()

x=np.random.random(10)
y=np.random.random(10)
print(mahalanobis(x, y))

#print(mahalanobis(image1, image2))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

 


十一、JS散度
測量兩個概率分布之間相似距離,常用於生物信息學和基因組比較 ,歷史定量研究,機器學習

import numpy as np
from PIL import Image
from scipy.spatial.distance import pdist


def jensenshannon(image1, image2):
X = np.vstack([image1, image2])
return pdist(X, 'jensenshannon')[0]


image1 = Image.open('image/1.jpg')
image2 = Image.open('image/2.jpg')
image2 = image2.resize(image1.size)
image1 = np.asarray(image1).flatten()
image2 = np.asarray(image2).flatten()

print(jensenshannon(image1, image2))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
圖片 1 2 3 4
1 0 0.2008 0.4877 0.1746

 


十二、image-match匹配庫
image-match

image-match文檔

該庫類似pHash庫,包括一個數據庫后端,可輕松擴展到數十億張圖像,並支持持續的高速圖像插入

匹配原理是pHash離散余弦變換,歸一化距離小於0.40很可能匹配

安裝

pip install image_match
1
norm_diff = np.linalg.norm(b - a)
norm1 = np.linalg.norm(b)
norm2 = np.linalg.norm(a)
return norm_diff / (norm1 + norm2)
1
2
3
4
from image_match.goldberg import ImageSignature


def open(image):
return ImageSignature().generate_signature(image)


def distance(image1, image2):
return ImageSignature.normalized_distance(image1, image2)


image1 = open('image/1.jpg')
image2 = open('image/2.jpg')

print(distance(image1, image2))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
圖片 1 2 3 4
1 0 0.2360 0.6831 0.4296
加個濾鏡:

計算得到0.2027,匹配。

 

 

十三、不裝庫匹配
匹配代碼源自原庫

import numpy as np
from skimage.io import imread

def read(image):
# Step 1: Load image as array of grey-levels
im_array = imread(image, as_grey=True)

# Step 2a: Determine cropping boundaries
rw = np.cumsum(np.sum(np.abs(np.diff(im_array, axis=1)), axis=1))
cw = np.cumsum(np.sum(np.abs(np.diff(im_array, axis=0)), axis=0))
upper_column_limit = np.searchsorted(cw, np.percentile(cw, 95), side='left')
lower_column_limit = np.searchsorted(cw, np.percentile(cw, 5), side='right')
upper_row_limit = np.searchsorted(rw, np.percentile(rw, 95), side='left')
lower_row_limit = np.searchsorted(rw, np.percentile(rw, 5), side='right')
if lower_row_limit > upper_row_limit:
lower_row_limit = int(5 / 100. * im_array.shape[0])
upper_row_limit = int(95 / 100. * im_array.shape[0])
if lower_column_limit > upper_column_limit:
lower_column_limit = int(5 / 100. * im_array.shape[1])
upper_column_limit = int(95 / 100. * im_array.shape[1])
image_limits = [(lower_row_limit, upper_row_limit), (lower_column_limit, upper_column_limit)]

# Step 2b: Generate grid centers
x_coords = np.linspace(image_limits[0][0], image_limits[0][1], 11, dtype=int)[1:-1]
y_coords = np.linspace(image_limits[1][0], image_limits[1][1], 11, dtype=int)[1:-1]

# Step 3: Compute grey level mean of each P x P square centered at each grid point
P = max([2.0, int(0.5 + min(im_array.shape) / 20.)])
avg_grey = np.zeros((x_coords.shape[0], y_coords.shape[0]))
for i, x in enumerate(x_coords):
lower_x_lim = int(max([x - P / 2, 0]))
upper_x_lim = int(min([lower_x_lim + P, im_array.shape[0]]))
for j, y in enumerate(y_coords):
lower_y_lim = int(max([y - P / 2, 0]))
upper_y_lim = int(min([lower_y_lim + P, im_array.shape[1]]))
avg_grey[i, j] = np.mean(im_array[lower_x_lim:upper_x_lim,lower_y_lim:upper_y_lim])

# Step 4a: Compute array of differences for each grid point vis-a-vis each neighbor
right_neighbors = -np.concatenate((np.diff(avg_grey), np.zeros(avg_grey.shape[0]).reshape((avg_grey.shape[0], 1))),axis=1)
left_neighbors = -np.concatenate((right_neighbors[:, -1:], right_neighbors[:, :-1]), axis=1)
down_neighbors = -np.concatenate((np.diff(avg_grey, axis=0),np.zeros(avg_grey.shape[1]).reshape((1, avg_grey.shape[1]))))
up_neighbors = -np.concatenate((down_neighbors[-1:], down_neighbors[:-1]))
diagonals = np.arange(-avg_grey.shape[0] + 1, avg_grey.shape[0])
upper_left_neighbors = sum([np.diagflat(np.insert(np.diff(np.diag(avg_grey, i)), 0, 0), i) for i in diagonals])
lower_right_neighbors = -np.pad(upper_left_neighbors[1:, 1:], (0, 1), mode='constant')
flipped = np.fliplr(avg_grey)
upper_right_neighbors = sum([np.diagflat(np.insert(np.diff(np.diag(flipped, i)), 0, 0), i) for i in diagonals])
lower_left_neighbors = -np.pad(upper_right_neighbors[1:, 1:], (0, 1), mode='constant')
diff_mat = np.dstack(np.array([upper_left_neighbors, up_neighbors, np.fliplr(upper_right_neighbors), left_neighbors, right_neighbors,np.fliplr(lower_left_neighbors), down_neighbors, lower_right_neighbors]))

# Step 4b: Bin differences to only 2n+1 values
mask = np.abs(diff_mat) < 2 / 255.
diff_mat[mask] = 0.
positive_cutoffs = np.percentile(diff_mat[diff_mat > 0.], np.linspace(0, 100, 3))
negative_cutoffs = np.percentile(diff_mat[diff_mat < 0.], np.linspace(100, 0, 3))
for level, interval in enumerate([positive_cutoffs[i:i + 2] for i in range(positive_cutoffs.shape[0] - 1)]):
diff_mat[(diff_mat >= interval[0]) & (diff_mat <= interval[1])] = level + 1
for level, interval in enumerate([negative_cutoffs[i:i + 2] for i in range(negative_cutoffs.shape[0] - 1)]):
diff_mat[(diff_mat <= interval[0]) & (diff_mat >= interval[1])] = -(level + 1)

# Step 5: Flatten array and return signature
return np.ravel(diff_mat).astype('int8')


def distance(image1, image2):
norm_diff = np.linalg.norm(image1 - image2)
norm1 = np.linalg.norm(image1)
norm2 = np.linalg.norm(image2)
return norm_diff / (norm1 + norm2)


if __name__ == '__main__':
image1 = read('image/1.jpg')
image2 = read('image/2.jpg')
print(distance(image1, image2))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
結果與十二同。

 

 

十四、利用Keras預訓練模型提取特征進行匹配
此處預訓練模型使用VGG16,越大越匹配

import numpy as np
from numpy import linalg as LA
from keras.preprocessing import image
from keras.applications.vgg16 import VGG16
from keras.applications.vgg16 import preprocess_input


class VGGNet:
def __init__(self):
self.input_shape = (224, 224, 3)
self.model = VGG16(weights='imagenet', pooling='max', include_top=False,
input_shape=(self.input_shape[0], self.input_shape[1], self.input_shape[2]))

def extract_feat(self, img_path):
'''提取圖像特征

:param img_path: 圖像路徑
:return: 歸一化后的圖像特征
'''
img = image.load_img(img_path, target_size=(self.input_shape[0], self.input_shape[1]))
img = image.img_to_array(img)
img = np.expand_dims(img, axis=0)
img = preprocess_input(img)
feat = self.model.predict(img)
norm_feat = feat[0] / LA.norm(feat[0])
return norm_feat


if __name__ == '__main__':
model = VGGNet()
image1 = model.extract_feat('image/1.jpg')
image2 = model.extract_feat('image/2.jpg')
print(np.dot(image1, image2.T))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
圖片 1 2 3 4
1 1 0.8714762 0.60663277 0.67468536

 


腳本
1. 綜合比較

import numpy as np
from PIL import Image
from scipy.spatial.distance import pdist


def euclidean(image1, image2):
'''歐氏距離'''
X = np.vstack([image1, image2])
return pdist(X, 'euclidean')[0]


def manhattan(image1, image2):
'''曼哈頓距離'''
X = np.vstack([image1, image2])
return pdist(X, 'cityblock')[0]


def chebyshev(image1, image2):
'''切比雪夫距離'''
X = np.vstack([image1, image2])
return pdist(X, 'chebyshev')[0]


def cosine(image1, image2):
'''余弦距離'''
X = np.vstack([image1, image2])
return pdist(X, 'cosine')[0]


def pearson(image1, image2):
'''皮爾遜相關系數'''
X = np.vstack([image1, image2])
return np.corrcoef(X)[0][1]


def hamming(image1, image2):
'''漢明距離'''
return np.shape(np.nonzero(image1 - image2)[0])[0]


def jaccard(image1, image2):
'''傑卡德距離'''
X = np.vstack([image1, image2])
return pdist(X, 'jaccard')[0]


def braycurtis(image1, image2):
'''布雷柯蒂斯距離'''
X = np.vstack([image1, image2])
return pdist(X, 'braycurtis')[0]


def mahalanobis(image1, image2):
'''馬氏距離'''
X = np.vstack([image1, image2])
XT = X.T
return pdist(XT, 'mahalanobis')


def jensenshannon(image1, image2):
'''JS散度'''
X = np.vstack([image1, image2])
return pdist(X, 'jensenshannon')[0]


def image_match(image1, image2):
'''image-match匹配庫'''
try:
from image_match.goldberg import ImageSignature
except:
return -1
image1 = ImageSignature().generate_signature(image1)
image2 = ImageSignature().generate_signature(image2)
return ImageSignature.normalized_distance(image1, image2)


def vgg_match(image1, image2):
'''VGG16特征匹配'''
try:
from numpy import linalg as LA
from keras.preprocessing import image
from keras.applications.vgg16 import VGG16
from keras.applications.vgg16 import preprocess_input
except:
return -1

input_shape = (224, 224, 3)
model = VGG16(weights='imagenet', pooling='max', include_top=False, input_shape=input_shape)

def extract_feat(img_path):
'''提取圖像特征'''
img = image.load_img(img_path, target_size=(input_shape[0], input_shape[1]))
img = image.img_to_array(img)
img = np.expand_dims(img, axis=0)
img = preprocess_input(img)
feat = model.predict(img)
norm_feat = feat[0] / LA.norm(feat[0])
return norm_feat

image1 = extract_feat(image1)
image2 = extract_feat(image2)
return np.dot(image1, image2.T)


if __name__ == '__main__':
# 初始化
image1_name = 'image/1.jpg'
image2_name = 'image/2.jpg'
image3_name = 'image/3.jpg'

# 圖像預處理
image1 = Image.open(image1_name).convert('L') # 轉灰度圖,若考慮顏色則去掉
image2 = Image.open(image2_name).convert('L')
image3 = Image.open(image3_name).convert('L')
image2 = image2.resize(image1.size)
image3 = image3.resize(image1.size)
image1 = np.asarray(image1).flatten()
image2 = np.asarray(image2).flatten()
image3 = np.asarray(image3).flatten()

# 相似度匹配
print('歐氏距離', euclidean(image1, image2), euclidean(image1, image3))
print('曼哈頓距離', manhattan(image1, image2), manhattan(image1, image3))
print('切比雪夫距離', chebyshev(image1, image2), chebyshev(image1, image3))
print('余弦距離', cosine(image1, image2), cosine(image1, image3))
print('皮爾遜相關系數', pearson(image1, image2), pearson(image1, image3))
print('漢明距離', hamming(image1, image2), hamming(image1, image3))
print('傑卡德距離', jaccard(image1, image2), jaccard(image1, image3))
print('布雷柯蒂斯距離', braycurtis(image1, image2), braycurtis(image1, image3))
# print('馬氏距離', mahalanobis(image1, image2), mahalanobis(image1, image3))
print('JS散度', jensenshannon(image1, image2), jensenshannon(image1, image3))

print('image-match匹配庫', image_match(image1_name, image2_name), image_match(image1_name, image3_name))
print('VGG16特征匹配', vgg_match(image1_name, image2_name), vgg_match(image1_name, image3_name))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
2. 歐式相似度

import numpy as np
from PIL import Image
from scipy.spatial.distance import pdist


def euclidean(image1, image2, size):
'''歐氏相似度'''
black = Image.new('RGB', size, color=(0, 0, 0))
white = Image.new('RGB', size, color=(255, 255, 255))
white = np.asarray(white).flatten()
black = np.asarray(black).flatten()
X = np.vstack([white, black])
_max = pdist(X, 'euclidean')[0] # 兩圖最大歐氏距離
X = np.vstack([image1, image2])
return (_max - pdist(X, 'euclidean')[0]) / _max
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

 


總結
任務 使用距離
文本相似度 余弦距離
用戶相似度 皮爾遜相關系數

 


參考文獻
利用python PIL庫進行圖像模式的轉換
常見距離公式 numpy 實現
EdjoLabs/image-match: ? Quickly search over billions of images
Python計算圖片之間的相似度
相似度計算——歐氏距離、漢明距離、余弦相似度
Distance computations (scipy.spatial.distance)
距離度量以及python實現(一)
距離度量以及python實現(二)
基於VGG-16的海量圖像檢索系統(以圖搜圖升級版)
灰度值比較獲得圖片指紋
sklearn.metrics.pairwise.paired_distances
數據科學中的 9 種距離度量
————————————————
版權聲明:本文為CSDN博主「XerCis」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/lly1122334/article/details/89431244


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM