Question about outputting a matrix to a pgm file
2 ビュー (過去 30 日間)
古いコメントを表示
Hello, I'm new to matlab and I've got a question about outputting matrix to a pgm file. I know the most direct way of doing this is using imwrite function, but I want to ask if there's any other method or code that could output the matrix to pgm file without using imwrite function, for example, using functions like fwrite? Please let me know if there's any idea.
0 件のコメント
回答 (1 件)
Walter Roberson
2024 年 2 月 2 日
Yes, the PGM file format is relatively simple. You can fopen(), fprintf() several times, and fclose()
It is not clear why you would want to do this yourself, but...
Note: if you are writing uint16 data, then the most significant byte must be first -- corresponding to fopen() with 'ieee-be' option.
2 件のコメント
Walter Roberson
2024 年 2 月 2 日
Yes, fprintf() the header values.
You probably need to fwrite() the data
参考
カテゴリ
Help Center および File Exchange で Low-Level File I/O についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!