Read DICOM files and create a Montage

6 vues (au cours des 30 derniers jours)
Praz Sam
Praz Sam le 9 Oct 2015
Commenté : Ryan Harris le 19 Mar 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?

Réponse acceptée

Stalin Samuel
Stalin Samuel le 9 Oct 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 commentaires
Daniel Bridges
Daniel Bridges le 22 Juin 2016
Modifié(e) : Daniel Bridges le 22 Juin 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 le 19 Mar 2018
So i'm getting an error for the very last line montage(x,[]). Why do you think this is?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur DICOM Format dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by