【问题标题】:Series of dicom images into specific format in matlab在matlab中将一系列dicom图像转换为特定格式
【发布时间】:2017-02-15 17:58:42
【问题描述】:

我有一系列属于单个患者的 matlab 图像。我在网上找到了一些代码,但它正在播下一些错误。我想要这样的东西,Image

这是我的代码。

% Preallocate the 256-by-256-by-1-by-20 image array.
X = repmat(int16(0), [256 256 1 20]);
% Read the series of images.
for p=1:20
filename = sprintf('brain_%03d.dcm', p);
X(:,:,1,p) = dicomread(filename);
end
% Display the image stack.
montage(X,[])

我从这里找到了这段代码: https://www.mathworks.com/company/newsletters/articles/accessing-data-in-dicom-files.html

Error using montage>validateColormapSyntax (line 339)

索引图像可以是 uint8、uint16、双精度、单精度或逻辑。

    Error in montage>parse_inputs (line 259)
    cmap = validateColormapSyntax(I,varargin{2});

   Error in montage (line 114)
  [I,cmap,mSize,indices,displayRange,parent] = parse_inputs(varargin{:});

  Error in Untitled2 (line 9)
  montage(X,[]);

【问题讨论】:

  • 错误是....什么?
  • @excaza Error in Untitled2 (line 9) montage(X,[]); 我使用了这个例子和他们给定的数据集。
  • edit完整错误消息和堆栈跟踪记录到您的问题中。
  • @excaza 我已经更新了问题以及 eroor。

标签: matlab dicom


【解决方案1】:

自编写代码示例以来,调用montage 函数的语法发生了变化(早在2002 年!)。正如File Exchange submission for the sample DICOM data files 的 cmets 部分所述,新的正确语法如下:

montage(X, 'DisplayRange', []);

您遇到了该错误,因为新语法将 montage(X, []); 解释为好像 X 是索引彩色图像(根据错误,它不允许是签名的 int16 类型),颜色为空地图[]

【讨论】:

  • 成功了。但是,我在以下行有疑问 filename = sprintf('brain_%03d.dcm', p); 如何更改文件夹中随机文件名的名称?我的意思是它将名为brain_01d.dcm 的一系列图像带到20,但每个dcm 文件都有不同的名称。我该怎么办?
  • 请帮我解决这个问题
  • @MuhammadUsman:由于我不知道您的文件是如何存储或命名的,因此无法提供具体帮助。您应该首先检查dir 函数。
猜你喜欢
  • 2020-11-09
  • 1970-01-01
  • 2011-05-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多