将3D数组转换为GDF格式

时间:2014-08-05 16:06:14

标签: image matlab

我使用cat函数堆叠了10张图片,获得了标记为myImage的图像堆栈,其尺寸为:100x100x10(每张图片都有100x100维度)。我想使用write_gdf将此文件转换为GDF文件。但是,当我尝试运行此转换时,

myImage = cat(3,X{1:NumberOfFiles});
s = write_gdf('stack.gdf',myImage);

我希望s成为尺寸为100x100x10的3D矩阵,其值等于myImage的值。相反,我只是将s变为一维变量:s=3

write_gdf帮助中,提到了:

NAME:
        write_gdf
   PURPOSE:
        write data files in gdf format.
   CATEGORY:
        General Purpose Utility
   CALLING SEQUENCE:
        fid = write_gdf(filename,data)
   INPUTS:
        file:   Complete pathname of the file to be written.
   OUTPUTS:
        data:   Data structure.  For example, if the original
            data was stored as an array of bytes, then
            DATA will be returned as an array of bytes also.
   RESTRICTIONS:
        Current implementation does not support structures or
        arrays of structures.
   PROCEDURE:
        Reasonably straightforward.
        Determines if the file is ASCII or binary, reads the size
        and dimension info from the header, and reads in the data

请帮忙。提前谢谢!

1 个答案:

答案 0 :(得分:1)

我认为帮助部分会产生误导。如果您检查the code,您会发现以下内容:

function [fid]=write_gdf(fn, data)

fid=fopen(fn,'w');

注意:我删除了所有不相关的代码部分 您向函数提供文件名(fn)和数据(data)。在内部,它在文件名上调用fopen并将文件ID存储在fid中。来自fopen文档:

  

fileID:打开文件的文件标识符,指定为整数。

这是Matlab这个函数的唯一输出。这就是你所看到的s=3


为什么帮助段落说:

%  OUTPUTS:
%       data:  Data structure.  For example, if the original
%              data was stored as an array of bytes, then
%              DATA will be returned as an array of bytes also.

我只能猜测。也许这意味着data是输出文件(但不是Matlab)。这可能只是解释如何数据“输出”到文件中。