Montage reshape produces white images
이전 댓글 표시
Hello,
I'm following an example to create a montage of from an array of dicom files. Everything is working from reading the files, etc. The problem arises as the example wants to reshape the image and when it does, the entire montage is blank (white). I can reproduce the individual dicom images with matlab and it shows the correct image. Just when entered into this example is when the error arises.
I understand that also 'DisplayRange' can make pictures white if the wrong LOW and HIGH parameters are set, so I tried the same montage with 'Size' and it still comes out white.
Here is the code:
if true
% code
fileFolder = fullfile(pwd, 'DICOM');
files = dir(fullfile(fileFolder, '*.dcm'));
fileNames = {files.name};
info = dicominfo(fullfile(fileFolder,fileNames{1}));
SliceThickness=1;
PixelSpacing=[1;1];
voxel_size = [PixelSpacing; SliceThickness];
numImages = length(fileNames);
hWaitBar = waitbar(0,'Reading DICOM files');
AcquisitionMatrix=[0;256;256;0];
X = zeros(info.Rows, info.Columns, numImages, class(AcquisitionMatrix));
for i=length(fileNames):-1:1
fname = fullfile(fileFolder, fileNames{i});
X(:,:,i) = uint16(dicomread(fname));
waitbar((length(fileNames)-i+1)/length(fileNames))
end
delete(hWaitBar)
montage(reshape(uint16(X), [size(X,1), size(X,2), 1, size(X,3)]),'Size',[5 5]);
end
Why does it need to reshape? Can this be omitted.
Any help would be greatly appreciated. Thank you.
Cheers, Edwin
댓글 수: 1
Edwin Baldelomar
2012년 7월 10일
답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 DICOM Format에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!