空/无SIFT描述符和在python中生成的关键点 [英] Null/No SIFT descriptor and keypoints generated in python

查看:249
本文介绍了空/无SIFT描述符和在python中生成的关键点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从一组图像补丁中创建一个密码本.我已将图像(Caltech 101)分成20 X 20图像块.我想为每个补丁创建一个SIFT描述符.但是对于某些图像补丁,它不返回任何描述符/关键点.我尝试使用OpenCV和vlfeat. 使用任何库的行为都是相同的.

I am trying to create a codebook from a set of image patches. I have divided the images (Caltech 101) into 20 X 20 image patches. I want to create a SIFT descriptor for each patch. But for some of the image patches, it does not return any descriptor/keypoint. I have tried using OpenCV and vlfeat. The behavior is same using any of the libraries.

以下是我使用OpenCV编写的代码-

Following is my code using OpenCV -

sift = cv2.SIFT()
img = cv2.imread('patch_temp.jpg',0)
imgptch = cv2.imread('image_patch.jpg',cv2.CV_LOAD_IMAGE_GRAYSCALE)
kp, des = sift.detectAndCompute(imgptch,None)
print des

des为无".如果我使用vlfeat,情况也是如此. 注意:如果我使用其他图像,则上述方法适用.对于某些图像,它返回None(10张中的6张).

des is 'None'. Same is the case if I use vlfeat. Note : Above works if I use a different image. It returns None for some of the images (6 out of 10).

我已经使用OpenCV索引创建了图像补丁-

I have created the image patch using OpenCV indexing -

patch = img[0:20,0:20]
cv2.imwrite('image_patch.jpg',img)

推荐答案

函数sift.detectAndCompute首先 尝试检测SIFT关键点然后找到位置.

The function sift.detectAndCompute will first try to detect a SIFT keypoint then compute a descriptor at the found location.

这不是您想要的:您希望每个补丁都有一个描述符. 您可以首先手工制作关键点位置(通过将其pt属性调整到补丁的中心,并将其size属性调整到补丁的大小). 然后,仅在这组位置上调用描述符提取器.

This is not what you want: you want to have a descriptor for each patch. You can hand craft the keypoint locations first (by adjusting their pt property to the center of your patches and adjusting their size property to your patch size). Then, call only the descriptor extractor on this set of locations.

这篇关于空/无SIFT描述符和在python中生成的关键点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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