Error is getting when median filter is applied to dicom images. The code i am tried is here

3 visualizaciones (últimos 30 días)
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'},{}, ...

Respuestas (1)

Jan
Jan el 10 de Abr. de 2021
Editada: Jan el 10 de Abr. de 2021
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!

Categorías

Más información sobre DICOM Format en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by