title: SURF features in EmguCv: how to extract a fixed number of features
body: <p>I want to train a neural network in order to classify different classes of grayscale images.</p>
  
  <p>As input of this network, I want to use the features extracted by the SURF-128 algorithm. The following code (a semplification of the <a href="http://www.emgu.com/wiki/index.php/SURF_feature_detector_in_CSharp" rel="nofollow noreferrer">example provided with EmguCV library</a>) shows how I use the API:</p>
  
  <pre><code>SURFDetector surfCPU = new SURFDetector(500, true);
  VectorOfKeyPoint observedKeyPoints;
  
  BriefDescriptorExtractor descriptor = new BriefDescriptorExtractor();
  
  observedKeyPoints = surfCPU.DetectKeyPointsRaw(img, null);
  Matrix&lt;Byte&gt; observedDescriptors = descriptor.ComputeDescriptorsRaw(img, null, observedKeyPoints);
  </code></pre>
  
  <p>By using the following code:</p>
  
  <pre><code>observedDescriptors.Save(@"SURF.bmp");
  </code></pre>
  
  <p>I can save some results. The following image shows that the above code extracts features with different sizes (on the right, there are the results saved with the previous line of code):</p>
  
  <p><img src="https://i.stack.imgur.com/geGo9.png" alt="Image tests"></p>
  
  <p>What I want is to obtain a vector with a fixed size.</p>
  
  <p>How can I transform a generic grayscale image in a 128-dimensional array, using the API provided by the EmguCV library for C#?</p>