Q:

runtime error of vlsift: input image contains a malformed PGM header

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.

A:

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).

