如何在图像中找到视觉词汇的相对位置?

问题描述 投票:0回答:1

我创建了一个大小为20的可视单词字典。下面显示了特定图像中的单词频率数组:

[ 3.  2.  1.  3.  3.  ...  2.  2.  3.  1.  3.  .....      2.  1. ] 

我计算在图像中观察特定视觉词汇的次数:

unique, counts = np.unique(A[:,img_idx], return_counts=True)  #
dict(zip(unique, counts))  
OUT: {0.0: 47,
     1.0: 89,
     2.0: 89,
     3.0: 79,
     4.0: 42,
     5.0: 25,
     6.0: 10,
     7.0: 12,
     8.0: 3,
     9.0: 2,
     10.0: 1,
     11.0: 1}   #Here, 11 visual vocab. has been observed in image

如何在图像中找到每个视觉词汇的相对位置?谢谢

python opencv image-processing sift cv2
1个回答
0
投票

您可以通过matplotlib显示每个视觉单词的相对位置。

首先导入必要的模块:

import numpy as np
import matplotlib.pyplot as plt

然后生成模拟数据(visual_wordsis实际上是您的特征提取器的输出):

dict_size = 5
img_shape = (9, 16)
visual_words = np.random.randint(low=0, high=dict_size, size=img_shape)

最后在整个图像中显示特征的空间排列:

cmap = plt.get_cmap('rainbow', dict_size)
im = plt.imshow(visual_words, cmap=cmap, vmin=-.5, vmax=dict_size-.5)
plt.colorbar(im, ticks=range(dict_size), label='Visual words')
plt.show()

Map of visual words

© www.soinside.com 2019 - 2024. All rights reserved.