1

I am trying to test sift detector of vlfeat computer vision library by running sift.c file in src folder. I have successfully compiled and run the program. However, I got the error: the input image contains a malformed PGM header. I am sure it is not the problem of image file inputed. Could anyone explain that.

neouyghur
  • 1,577
  • 16
  • 31

1 Answers1

0

This corresponds to the VL_ERR_PGM_INV_HEAD error code which is issued by the PGM decoder if the file is less than 2 bytes or has a not supported or invalid magic number.

Please note that vlfeat only supports P2 (ASCII) and P5 (binary) formats. So you should inspect your magic to control if it fits these requirements, e.g.:

$ xxd -c 1 -l 2 foo.pgm
0000000: 50  P
0000001: 35  5

$ xxd -c 1 -l 2 bar.pbm
0000000: 50  P
0000001: 34  4

Here foo.pgm is valid (graymap in binary format) but bar.pbm is not supported by vlfeat (black & white bitmap in binary format).

deltheil
  • 15,496
  • 2
  • 44
  • 64
  • Thank you for replying. In that case what should I do for extracting features from my image. Actually, I have found another code, it use opencv to read image, then convert the opencv result to vlfeat format. – neouyghur Jul 24 '15 at 07:34
  • You should use the OpenCV API used to write / encode an image into PGM, or convert your image a priori with e.g. ImageMagick: `convert foo.jpg foo.pgm`. – deltheil Jul 24 '15 at 07:36