在matlab

时间:2017-02-15 17:58:42

标签: matlab dicom

我有一系列属于单个病人的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,double,single或logical。

    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,[]);

1 个答案:

答案 0 :(得分:2)

自编写代码示例以来,调用montage函数的语法已经改变(早在2002年!)。正如File Exchange submission for the sample DICOM data files的评论部分所述,新的正确语法是:

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

您收到该错误,因为新语法解释montage(X, []);,好像X是一个索引的彩色图像(不允许是签名的int16类型,根据错误)使用空的颜色映射[]

相关问题