Error is getting when median filter is applied to dicom images. The code i am tried is here
조회 수: 3 (최근 30일)
이전 댓글 표시
info=dicominfo(filenames{1});
X = zeros([info.Height info.Width info.SamplesPerPixel file_num],'uint16');
for y = 1:file_num
thisinfo=dicominfo(filenames{y});
if thisinfo.Height~=info.Height||thisinfo.Width~=info.Width
error('%s does not have the expected height or width',filenames{y})
elseif thisinfo.SamplesPerPixel~=info.SamplesPerPixel
error('%s does not have the expected number of channels',filenames{y})
elseif isfield(thisinfo,'NumberOfFrames') && thisinfo.NumberOfFrames>1
error('%s is a multiframe image',filenames{y})
end
[rows, columns, numberOfColorChannels] = size(filenames);
if numberOfColorChannels > 1
Igray = rgb2gray(filenames);
else
Igray = filenames;
end
X(:,:,:,y) = im2uint16(dicomread(Igray{y}));
g = im2double(Igray);
m = medfilt2(g);
end
And the errors i am getting is Error using im2double Expected input number 1, Image, to be one of these types:
double, logical, uint8, uint16, int16, single
Error in im2double (line 36)
validateattributes(img,{'double','logical','uint8','uint16','int16','single'},{}, ...
Pls help me to apply image filters. Any help is appreciated
Error using im2double
Expected input number 1, Image, to be one of these types:
double, logical, uint8, uint16, int16, single
Error in im2double (line 36)
validateattributes(img,{'double','logical','uint8','uint16','int16','single'},{}, ...
댓글 수: 0
답변 (1개)
Jan
2021년 4월 10일
편집: Jan
2021년 4월 10일
This looks, like filename is a cell string, containing file names:
info=dicominfo(filenames{1});
Then getting the sizes of the cell array is strange:
[rows, columns, numberOfColorChannels] = size(filenames);
I assume, the size of filenames is [1,1] or maybe a vector. But it is unlikely, that the list of file names has 3 dimensions. I assume, you do not mean the name of the files, but the contents of an imported file - maybe:
img = dicomread(filenames{1});
[rows, columns, numberOfColorChannels] = size(img);
The same applies for
Igray = rgb2gray(filenames); % Converting the name of the file?!?
else
Igray = filenames;
end
X(:,:,:,y) = im2uint16(dicomread(Igray{y})); % Fine: import the contents!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 DICOM Format에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!