close

PGM 為 Portable GrayMap的縮寫。PGM 檔案為黑白的圖片,亦即每個像素只差在亮度的深淺而已。

PGM 檔案 能夠以純文字或是位元碼儲存。

PGM 檔案的副檔名是 .pgm。

 

PGM 檔案的例子:

P2
# A diagonal line with 10 pixels length and the image has 10 pixels wide and 10 pixels high.
10 10
255
0 255 255 255 255 255 255 255 255 255
255 0 255 255 255 255 255 255 255 255
255 255 0 255 255 255 255 255 255 255
255 255 255 0 255 255 255 255 255 255
255 255 255 255 0 255 255 255 255 255
255 255 255 255 255 0 255 255 255 255
255 255 255 255 255 255 0 255 255 255
255 255 255 255 255 255 255 0 255 255
255 255 255 255 255 255 255 255 0 255
255 255 255 255 255 255 255 255 255 0 

 

line 1 :  P2 是指檔案版本。

line 2 : # A diagonal line with 10 pixels length and the image has 10 pixels wide and 10 pixels high. 在pgm file以#開始的一整行都是註解。

line 3 : 10 10 這個pgm file 的寬度為10,高度為10。

line 4 : 255 這個pgm file的每個pixel的最大值為255(白色)。

line 5 ~ line 14 : 用palin text來描述這張 pgm image 的每個 pixel的亮度。

 

實作一個pgm image

可至 

http://www.irfanview.com/

下載irfanview

並依循下列的步驟產生一張pgm image

 

1. 使用irfanview 開啟一張圖片

step1.PNG

 

2. 選擇save as

step2.PNG

 

3. 存檔類型選擇 PGM,並選擇ASCII encoding(這樣才會以純文字的方式儲存圖檔。)

step3.PNG

 

arrow
arrow
    全站熱搜

    awesq123 發表在 痞客邦 留言(0) 人氣()