[英]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.