Read DICOM files and create a Montage

6 Ansichten (letzte 30 Tage)
Praz Sam
Praz Sam am 9 Okt. 2015
Kommentiert: Ryan Harris am 19 Mär. 2018
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?

Akzeptierte Antwort

Stalin Samuel
Stalin Samuel am 9 Okt. 2015
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 Kommentare
Daniel Bridges
Daniel Bridges am 22 Jun. 2016
Bearbeitet: Daniel Bridges am 22 Jun. 2016
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 am 19 Mär. 2018
So i'm getting an error for the very last line montage(x,[]). Why do you think this is?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu DICOM Format finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by