我一直在尝试根据最小距离(欧几里德距离)显示图像,但我无法找到结果。
我的代码如下:
import cv2
from collections import *
import CBIR as cb
import experiment as ex
from scipy.spatial import distance
from matplotlib import pyplot as plt
result_list = list()
i = 0
a_list = list()
b_list = list()
a_list.append(ex.feature_matrix_ip)
while i < 50:
b_list.append(cb.feature_matrix_db[i])
dist = distance.euclidean(a_list,b_list[i])
result_list.append(dist)
result_list_sort = OrderedDict(sorted(enumerate(result_list),key=lambda x: x[0])).keys()
i = i + 1
result_list.sort()
res_list_sort = zip(result_list,result_list_sort)
images = cb.piclist
cv2.imshow('query image',ex.img)
plt.figure(2)
for i in xrange(6):
plt.subplot(3,2,i+1),plt.imshow(images[i],'Spectral')
plt.xticks([]),plt.yticks([])
plt.show()
我已将数据集中的图像编入索引。