在matlab中将一系列dicom图像转换为特定格式
Series of dicom images into specific format in matlab
我有一系列属于单个患者的 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,[]);
调用montage
function has changed since that code sample was written (back in 2002!). As noted in the comments section of the File Exchange submission for the sample DICOM data files的语法,新的正确语法是:
montage(X, 'DisplayRange', []);
您收到该错误是因为新语法将 montage(X, []);
解释为就好像 X
是索引彩色图像(不允许是带符号的 int16
类型,根据到错误)与一个空的颜色映射 []
.
我有一系列属于单个患者的 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,[]);
调用montage
function has changed since that code sample was written (back in 2002!). As noted in the comments section of the File Exchange submission for the sample DICOM data files的语法,新的正确语法是:
montage(X, 'DisplayRange', []);
您收到该错误是因为新语法将 montage(X, []);
解释为就好像 X
是索引彩色图像(不允许是带符号的 int16
类型,根据到错误)与一个空的颜色映射 []
.