First input must be a file name or a file identifier.
조회 수: 16 (최근 30일)
이전 댓글 표시
I get the error at line
[Img] = DicomReader(theFiles)
and
dicom_header = dicominfo(filename);
The code:
N=15;
img_dir = 'D:\stelios phd files\DesMoines\karadokei\'
filePattern = fullfile(img_dir, '*.dcm');
theFiles = dir(filePattern);
for k= 1:length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(img_dir, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
imageArray = dicomread(baseFileName);
end
D = squeeze(imageArray)
[Img] = DicomReader(D,N)
댓글 수: 4
답변 (2개)
Ameer Hamza
2018년 5월 10일
dir() only return file names, not complete paths. You need to specify the full path to dicomread(), Change the line like this
imageArray = dicomread(fullFileName);
Guillaume
2018년 5월 10일
function Img = DicomReader(filename,N)
Clearly your function expects a filename as the first argument
D = squeeze(imageArray)
[Img] = DicomReader(D,N)
Yet, you give it an imagearray. I don't understand why you expected that to work.
In addition, you're creating the imageArray in the loop but at each iteration you're overwriting the previous imageArray. So after the loop, imageArray is just the last image and you've discarded all the other ones.
댓글 수: 2
Guillaume
2018년 5월 10일
편집: Guillaume
2018년 5월 10일
The name of the variable is irrelevant. No matter what you call it you are still passing an image to DicomReader, not a filename.
I have no idea what you're trying to do but your code makes no sense. You read images in a loop to immediately discard the images without doing anything with them. After the loop, you're left with the last image only, which you pass to another function which expects a filename not an image.
참고 항목
카테고리
Help Center 및 File Exchange에서 3-D Volumetric Image Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!