使用欧几里德距离显示图像 - opencv python [英] displaying the images using euclidean distance - opencv python

查看:374
本文介绍了使用欧几里德距离显示图像 - opencv python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我正在使用python和opencv(cv2)做一个项目。在这里,我分别计算数据集的图像的红色,绿色和蓝色均值,并计算GLCM(对比度,能量,同质性和相关性)并将其保存在不同的列表中。现在我已经计算了查询图像与DB图像之间的欧氏距离,但是我无法显示距离最小的图像。

i已经部分完成了代码,它就像:

  import  cv2 
来自 collections import *
import CBIR as cb
import 实验 as ex
来自 scipy.spatial import 距离
来自 matplotlib import pyplot as plt

result_list = list()
i = 0
a_list = list()
b_list = list()
a_list.append(ex.feature_matrix_ip)
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 ]))。键()
i = i + 1
result_list.sort()
res_list_sort = zip(result_list,result_list_sort)





CBIR给出红色,绿色和蓝色均值与GLCM(对比度,能量,同质性和相关性)的数据库图像和实验将给出查询图像的值。



如何显示图像。欢迎任何建议



谢谢!

解决方案

hey, I am doing a project using python and opencv(cv2). here i am calculating the dataset's image's red,green and blue mean separately and also calculating the GLCM( contrast, energy,homogeneity, and correlation) and saving it in different list's. Now i have calculated the euclidean distance between query image with DB images, but i am unable to display the images with least distance.
i have done the code partially, and it is like:

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)



CBIR gives red,green and blue mean with GLCM( contrast, energy,homogeneity, and correlation) of DB images and experiment will give the values of the query image.

how to display the images. Any suggestions are welcome

Thanks!

解决方案

这篇关于使用欧几里德距离显示图像 - opencv python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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