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

Maybe insight on the image is needed. I can properly open up the dicom image via
if true
% code
[uint16,map]=dicomread('0005.dcm');
map=[256;256];
montage(uint16, map,'Size',[1 1]);
end

댓글을 달려면 로그인하십시오.

답변 (1개)

Edwin Baldelomar
Edwin Baldelomar 2012년 7월 10일

0 개 추천

Problem Solved. Even though I was either putting empty '[]' for 'DisplayRange' or the actual LOW and HIGH values in the brackets, the max was somehow defaulted at 100. I just went into the ColorMap editor and it allowed me to change it and I saw the images.
Maybe someone could explain why it defaulted at 100? Thank you.
Cheers, Edwin

카테고리

도움말 센터File Exchange에서 DICOM Format에 대해 자세히 알아보기

질문:

2012년 7월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by