Read DICOM files and create a Montage

6 次查看(过去 30 天)
Hi all, I'm quiet new to MatLab and started doing some DICOM Image processing tasks for my project. I am following this Mathworks article to make a montage as a simple exercise. But it gives me an error though I follow the same code segments.
The simple code is
% 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('DICOM/brain_%03d.dcm', p);
X(:,:,1,p) = dicomread(filename);
end
% Display the image stack.
montage(X,[])
It gives me the error,
>> ReadDicomFiles
Error using montage>validateColormapSyntax (line 334)
An indexed image can be uint8, uint16, double, single, or logical.
Error in montage>parse_inputs (line 254)
cmap = validateColormapSyntax(I,varargin{2});
Error in montage (line 114)
[I,cmap,mSize,indices,displayRange,parent] = parse_inputs(varargin{:});
Error in ReadDicomFiles (line 9)
montage(X,[])
I'm using the same dataset they provided. What will be the reason?

采纳的回答

Stalin Samuel
Stalin Samuel 2015-10-9
s = dicomread('IM-0001-0001.dcm');%read one image to find the size
[r c] = size(s);
X = repmat(double(0), [r c 1 9]);
for p=1:9
filename = sprintf('IM-0001-000%d.dcm', p);
X(:,:,1,p) =double(dicomread(filename));
end
% Display the image stack.
montage(X,[])
  3 个评论
Daniel Bridges
Daniel Bridges 2016-6-22
编辑:Daniel Bridges 2016-6-22
I had the same error Praz did, using my own DICOM files, and I think it was from the data being int16 instead of uint16: Wrapping dicomread(filename) in the uint16 or double function gets montage to work.
It seems I should use uint16 rather than double to keep the data as 16-bit rather than convert it to 64-bit unnecessarily.
Ryan Harris
Ryan Harris 2018-3-19
So i'm getting an error for the very last line montage(x,[]). Why do you think this is?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 DICOM Format 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by