Read DICOM files and create a Montage

6 ビュー (過去 30 日間)
Praz Sam
Praz Sam 2015 年 10 月 9 日
コメント済み: Ryan Harris 2018 年 3 月 19 日
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 Center および File ExchangeDICOM Format についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by