1

Is there any way in which we can limit the number of keypoints to the 100 in OPENCV SURF? Will the keypoints obtained be ordered according to their strength? How to obtain the strength of the descriptor? I am working on OPENCV in a LINUX system with a cpp program.

regards, shiksha

My code is: int main( int argc, char** argv ) {

         Mat img_1 = imread( argv[1], CV_LOAD_IMAGE_GRAYSCALE );
         Mat img_2 = imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE );



          //-- Step 1: Detect the keypoints using SURF Detector
         int minHessian = 500;

         SurfFeatureDetector detector( minHessian,1,2,false,true );

         std::vector<KeyPoint> keypoints_1p;

         std::vector<KeyPoint> keypoints_2p;



         detector.detect( img_1, keypoints_1p );
         detector.detect( img_2, keypoints_2p);


          // computing descriptors
          SurfDescriptorExtractor extractor(minHessian,1,1,1,0);
          Mat descriptors1, descriptors2;

          extractor.compute(img_1, keypoints_1p, descriptors1);
          extractor.compute(img_2, keypoints_2p, descriptors2);
wireless_lab
  • 177
  • 1
  • 4
  • 18

2 Answers2

1

You can get at most 100. I could imagine images (say for example a constant image) that have no SIFT descriptor. There are many ways to limit the keypoints to 100. There are easy solutions and hard solutions to your problem. You can get at most 100, by randomly selecting 100 keypoints from as many keypoints you get.

There is no such thing as the strength of the keypoint. You're going to have to define your own concept of strength.

There are a wide variety of parameter in the original Lowe paper that filter the keypoints (one of them is that they don't match an image edge, section 4.1 of Lowe's paper). There are 2 or 3 other parameters. You would need to adjust the parameters systematically in such a way that you only get 100. If you get less than 100 you filter less, and if you get more than 100 you filter more.

carlosdc
  • 12,022
  • 4
  • 45
  • 62
  • thanks for the reply. I just wanted to get the strongest 100 features of the image.Can it not be done using some parameter of SIFT algorithm? What does the response parameter of Keypoint specify? – wireless_lab Mar 28 '14 at 08:11
1

see the question here. And see my answer there how to limit the number of keypoints.

Community
  • 1
  • 1
skm
  • 5,015
  • 8
  • 43
  • 104
  • I tried using the format: FeatureDetectorExtractor extractor(100) to extract 100 keypoints. But the number of keypoints was same as previous itself i.e 75. I even tried for 50 keypoints but there was no change. What else can be done? Can u send the book to me if u still have a copy.. – wireless_lab Apr 01 '14 at 06:08
  • give me your email id....btw there is nothing related to this topic in that book. furthermore, if you write 100 but image do not have 100 keypoints then it may give you less than 100 point...but opposite is not true (which is happening in your case) – skm Apr 01 '14 at 06:32
  • you did it wrong..you used `FeatureDetectorExtractor extractor(100)`...but see my answer there carefully.....Specify the number of points for `detector` not for `extractor` – skm Apr 01 '14 at 06:33
  • no I tried that also. The number of features was increased to somewhere around 1000. I used SurfFeatureDetector detector(50). – wireless_lab Apr 01 '14 at 06:41
  • my mail_id is shiksha.murthy@honeywell.com – wireless_lab Apr 01 '14 at 06:44
  • did I do anything wrong again? If I am not wrong the value with detector() specifies the minHessain value.. – wireless_lab Apr 01 '14 at 09:03
  • Mat img_1 = imread( argv[1], CV_LOAD_IMAGE_GRAYSCALE ); Mat img_2 = imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE ); int minHessian = 500; SurfFeatureDetector detector( minHessian,1,2,false,true ); std::vector keypoints_1p; std::vector keypoints_2p; detector.detect( img_1, keypoints_1p ); detector.detect( img_2, keypoints_2p); // computing descriptors SurfDescriptorExtractor extractor(minHessian,1,1,1,0); Mat descriptors1, descriptors2; extractor.compute(img_1, keypoints_1p, descriptors1); extractor.compute(img_2, keypoints_2p, descriptors2); – wireless_lab Apr 02 '14 at 04:52