S.EB
S.EB

Reputation: 2226

How to extract SIFT features from an image with normalized float values between 0 and 1?

I am using cv2 to compute SIFT features. The values of gray image is between 0 and 1 (continuous float values). The problem is that I am getting the following error if I don't save the type as 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

after saving as uint8:

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

I am getting a complete blank image. Could someone please suggest a solution?

Upvotes: 1

Views: 846

Answers (1)

S.EB
S.EB

Reputation: 2226

I could solve the problem by just bringing the floats values into 255 range. By the following commands:

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

Upvotes: 1

Related Questions