分类: C/C++
2008-06-11 13:05:15
程序输入的参数中有一个是图片的文件名,因此输入….tif,却提示找不到文件,debug之后发现,默认的文件格式是pgm。因此用matlab的imread,imwrite把tif转成pgm的,但还是有问题,后发现程序中要求的pgm图片的开头是:
P2
n1,n2
255
而我转成的pgm的开头是P5的。原来,The first line, P2, is a magic number! P2 just means that the file is an ASCII PGM file. The only other valid value here is P5 which is a binary PGM file. 第二行的两个数字代表图片的宽和高。第三行的255代表intensity的个数,8bit的图像是255个intensity。
然而matlab默认的转成了P5,查看了matlab的help之后知可在imwrite中把Encoding这个参数中设置为ASCII,默认为rawbits。ASCII (plain) encoded with arbitrary color depth; raw (binary) encoded with up to 16 bits per gray value