Reputation: 47
I have series of matlab images which belong to a single patient. I found some code online, but it is sowing some error. I want something like this, Image
Here is the code I have.
% 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('brain_%03d.dcm', p);
X(:,:,1,p) = dicomread(filename);
end
% Display the image stack.
montage(X,[])
I found this code from here: https://www.mathworks.com/company/newsletters/articles/accessing-data-in-dicom-files.html
Error using montage>validateColormapSyntax (line 339)
An indexed image can be uint8, uint16, double, single, or logical.
Error in montage>parse_inputs (line 259)
cmap = validateColormapSyntax(I,varargin{2});
Error in montage (line 114)
[I,cmap,mSize,indices,displayRange,parent] = parse_inputs(varargin{:});
Error in Untitled2 (line 9)
montage(X,[]);
Upvotes: 3
Views: 335
Reputation: 125854
The syntax for calling the montage
function has changed since that code sample was written (back in 2002!). As noted in the comments section of the File Exchange submission for the sample DICOM data files, the new correct syntax is this:
montage(X, 'DisplayRange', []);
You were getting that error since the new syntax interprets montage(X, []);
as if X
were an indexed color image (which isn't allowed to be a signed int16
type, according to the error) with an empty color map []
.
Upvotes: 2