Null/No SIFT descriptor and keypoints generated in python

寵の児 提交于 2019-12-11 17:52:21

问题


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.

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

I have created the image patch using OpenCV indexing -

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

回答1:


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

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.



来源:https://stackoverflow.com/questions/27099760/null-no-sift-descriptor-and-keypoints-generated-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!