【问题标题】:How to find the relative position of visual vocabulary in an image?如何找到图像中视觉词汇的相对位置?
【发布时间】:2018-07-23 05:46:37
【问题描述】:

我创建了一个大小为 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】:

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

    首先导入必要的模块:

    import numpy as np
    import matplotlib.pyplot as plt
    

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

    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()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-15
      • 2012-05-13
      • 1970-01-01
      • 1970-01-01
      • 2015-08-13
      • 2015-04-12
      • 2011-01-26
      相关资源
      最近更新 更多