problem with a PGM file

4 visualizaciones (últimos 30 días)
Fatma Gargouri
Fatma Gargouri el 22 de Mzo. de 2012
Respondida: John Labbate el 29 de Jun. de 2022
hello
I want to execute the code proposed by David low for the SIFT detector http://www.cs.ubc.ca/~lowe/keypoints/
it bloked in this lines :
f = fopen('tmp.pgm', 'w');
if f == -1
ferror(f)
end
fclose(f);
and I get this error message :
??? Error using ==> ferror
Invalid file identifier. Use fopen to generate a valid file
identifier.
PS: I work with windows 7
  1 comentario
Fatma Gargouri
Fatma Gargouri el 23 de Mzo. de 2012
I don't understand the use of a PGM file and what it does it mean ?

Iniciar sesión para comentar.

Respuestas (4)

John Labbate
John Labbate el 29 de Jun. de 2022
Doubt anyone is still working on this exact issue, but it is worth noting that if you are getting errors relating to the inputted .pgm file, make sure that your inputted file has the correct header in the way your SIFT code will recognize it.
For example, I was using the ezSIFT code by robertwgh that can be found on Github. Outputting a .pgm from MATLAB gives a different format than the ezSIFT software could take, so I had to write a new function within the C++ ezSIFT code that would successfully parse the .pgm that came out of MATLAB.
The .pgm file that is put into the ezSIFT software MUST have pixels that are size 8-bit and be a type P5 .pgm file (this means the image data must be formatted in binary. You can use the code below to get the correct file type to output to use with ezSIFT.
imwrite(8bit_image_matrix, "output_filename.pgm",'Encoding','rawbits');
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
It also should be noted that the header of a .pgm always includes the following information in ASCII:
pgm magic number (for ex. P5)
image width image height
maximum pixel size

lucy
lucy el 10 de Abr. de 2012
i am also studying on this, it will create a pgm file for temporal use..
f = fopen('tmp.pgm', 'w');
if f == -1
error('Could not create file tmp.pgm.');
end
fprintf(f, 'P5\n%d\n%d\n255\n', cols, rows);
fwrite(f, image', 'uint8');
fclose(f);
do you mean this part?
  1 comentario
Fatma Gargouri
Fatma Gargouri el 11 de Abr. de 2012
yes that's what I meant!!

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 10 de Abr. de 2012
The -1 value returned on error is not a file identifier, and so cannot be used in the call to ferror()
Instead, use
[f, message] = fopen('tmp.pgm', 'w');
Then if f is -1 then "message" holds the error message you would get hope to get back from ferror()

Juan Andrade
Juan Andrade el 14 de Sept. de 2013
I am stuck in the same error, does anybody have some clue about it?, thanks

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by