您的位置:首页 > 编程语言 > MATLAB

mat文件存储struct结构,使用matlab显示图像

2017-11-09 20:21 676 查看
使用matlab显示.mat文件的图像(ground truth)

将数组或者矩阵保存为一个mat格式的文件,进行load命令读取a=load('gth.mat');

当进行imshow(a,[]);显示图像时

发生报错:

Error using imageDisplayValidateParams

Expected input number 1, I, to be one of these types:

  double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64, logical

Instead its type was struct.

Error in imageDisplayValidateParams (line 12)

validateattributes(common_args.CData, {'numeric','logical'},...

Error in imageDisplayParseInputs (line 79)

common_args = imageDisplayValidateParams(common_args);

Error in imshow (line 198)

  [common_args,specific_args] = ...

报错原因:得到的a是struct类型的数据,而imshow()显示应该是一个矩阵或者数组。

如何修改:将命令改写为:a=cell2mat(struct2cell(load('gth.mat')));得到的a即为矩阵。imshow(a,[]);可正常显示。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息