[英]Octave: How to cirumvent the "imresize: IM must be a grayscale or RGB image" error?
[英]OCTAVE - ind2rgb: X must be an indexed image
我正在嘗試使用以下幾行將一些氣象數據繪制並保存到png圖像文件中。
imag = data2image(flipud(vari'));
imag = gray2ind(imag);
imwrite(imag,colormap('jet'),'PSFC_RIO_im.png','png');
其中data2image
是自定義函數,可重新縮放圖像功能以供圖像函數使用。
function image = data2image(data)
HIGH = max(data(:));
LOW = min(data(:));
image = (data - LOW)/(HIGH-LOW);
end
不幸的是, imwrite
抱怨以下錯誤:
error: ind2rgb: X must be an indexed image
error: called from:
error: /usr/local/share/octave/3.6.4/m/image/ind2rgb.m at line 44, column 5
error: /usr/local/share/octave/3.6.4/m/image/imwrite.m at line 176, column 16
error: /home/tufts/Documents/Octave/geomat.m at line 53, column 1
第53行是上面代碼中的imwrite
。 這個錯誤對我來說毫無意義,因為imag已通過gray2ind
函數轉換為索引圖像。 我還通過使用有效的imshow
進行了測試。
編輯-imag類:
octave:9> class(imag)
ans = double
我將在一個不相關的問題中無意中回答我自己的問題,弄清楚如何做。
MATLAB中索引的圖像的最小值為1。我的功能是獲取數據的最小值,並將其等於0。
保重,就可以解決問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.