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 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