【问题标题】:How to extract SIFT features from an image with normalized float values between 0 and 1?如何从标准化浮点值在 0 到 1 之间的图像中提取 SIFT 特征?
【发布时间】:2018-07-19 13:23:58
【问题描述】:

我正在使用 cv2 来计算 SIFT 特征。灰度图像的值介于 0 和 1 之间(连续浮点值)。问题是如果我不将类型保存为 uint8,则会出现以下错误:

error: /io/opencv_contrib/modules/xfeatures2d/src/sift.cpp:1121: error: (-5) image is empty or has incorrect depth (!=CV_8U) in function detectAndCompute

保存为uint8后:

kp,des=sift.detectAndCompute(img,None)
plt.imshow(cv2.drawKeypoints(img, kp, out_img.copy()))
plt.show()

我得到一个完整的空白图像。有人可以提出解决方案吗?

【问题讨论】:

    标签: image-processing feature-extraction feature-detection sift cv2


    【解决方案1】:

    我可以通过将浮点值带入 255 范围来解决问题。通过以下命令:

    data = data / data.max() #normalizes data in range 0 - 255
    data = 255 * data
    img = data.astype(np.uint8)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-21
      • 1970-01-01
      • 2018-11-27
      • 1970-01-01
      • 2013-01-04
      • 1970-01-01
      • 2014-03-30
      • 2016-11-07
      相关资源
      最近更新 更多