1

I have a tuple (Keypoints, Descriptors) extracted from img1 using the method:

(kp, des) = sift.detectAndCompute(img1,None)

kp is a list containing cv2.KeyPoint objects, and des is a numpy.array containing their 128 dimensional descriptors

I want to retrieve for each keypoint a pixel value taken from another image img2 of the same size and store them in the tuple (kp, des) to have in the end a tuple like (kp, des, pixel_values)

Thank you very much in advance.

xiawi
  • 1,772
  • 4
  • 19
  • 21

1 Answers1

1

You can access pixel coordinates from kp. Like below:

kp[0].pt

and i think following code does what you want:

(kp[i], des[i], img2[kp[i].pt] for i in range(len(kp)))
  • Thank you for your answer, but I want to retrieve the pixels values from IMG2 and not the pixels coordinates. – Yahya ZEFRI Feb 04 '21 at 08:54
  • you need to use pixel coordinates to get pixel values. kp[i].pt returns pixel coordinates that ith keypoint points. if you want to get pixel value of this point thn you should use the coordinates. However, if what you want is match keypoints in both images than retrieving pixel value of corresponding keypoints, you should use feature matching methods like flann or BFMatcher. – KingOfTheLosers Feb 04 '21 at 11:27