看板 MATLAB 關於我們 聯絡資訊
我有一個 512*512 的矩陣 R,我將它畫成figure, colormap是我自己的設定, 我想將這個figure存成 R.tiff 於是我使用了以下的指令: map=colormap; 註:我只用藍色&紅色兩個顏色(藍-> 紅) imwrite(R,map,'R.tiff','tiff') 問題來了,我怎麼存都沒辦法存成我在matlab畫出來的樣子, 全部是一片藍色! 不知道是那個步驟錯誤?凡請各位前輩開示指點! 另,我看help imwrite, 他說要存的那個 variable can be M-by-N-by-4 for TIFF file 我對以上那段不太清楚,所以variable 是 "can be" or "should be" 三維矩陣? 若是should be 那我的變數 R (512*512) 的確不符合要求! try了很久,麻煩大家了! 謝謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.4.183
Raymond0710:R的型態是uint8嗎? 11/21 02:50
lemdas:是double! 11/21 23:56
lemdas:i find the answer! the value in R should be 0 ~ 255. 11/22 02:49
lemdas:another question is: how can i define the colormap 11/22 02:50
lemdas:according to the value in R (before re-nomalized)? 11/22 02:51
Raymond0710:uint8(R) 11/22 03:46
Raymond0710:你用colormap 要注意index是double 還是uint8 有差 11/22 03:48
lemdas:我試了很多次,基本上R裡面的element都是0~3的數字, 11/23 15:46
lemdas:即使我使用了uint(R)再去存圖,顯示出來的圖依然是藍色一片 11/23 15:47
lemdas:就是colormap(jet)低數值的顏色... 11/23 15:48
lemdas:看來我還是只能將R裡面的數值normalized再乘上255,存的圖 11/23 15:50
lemdas:才會正常顯示!! 謝謝一樓的解答 :) 11/23 15:50