【问题标题】:Converting a 3D array into GDF format将 3D 数组转换为 GDF 格式
【发布时间】:2014-08-05 16:06:13
【问题描述】:

我使用 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

请帮忙。提前谢谢!

【问题讨论】:

  • @Schorsch,我期待 s 也是一个维度为 100x100x10 的 3 维文件。正在编写文件s,但它是一个值为 3 的一维变量。我将编辑问题以使其更清楚我的期望。谢谢
  • 是的,很抱歉回复晚了。

标签: image matlab


【解决方案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)。这可能只是解释了如何将数据“输出”到文件中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-10
    • 1970-01-01
    相关资源
    最近更新 更多