Converting Multiple Dicom Images into Jpeg

3 visualizaciones (últimos 30 días)
Brian Ngo
Brian Ngo el 28 de En. de 2020
Comentada: Brian Ngo el 28 de En. de 2020
Hi,
Im trying to convert multiple Dicom Files into Jpeg files instead of doing it manually. Most of the Dicom files I have are labeled with numbers such as '000001, 0000002.... and so on' without the .dcm ( for example pdf files has a .pdf).
input = '/Users/brianngo/Desktop/CT-imaging/';
output = '/Users/brianngo/Desktop/CT-imaging-Jpeg/';
filePattern = fullfile(input, '\d');
FileList = dir(filePattern);
N = size(FileList,1);
for k = 1:N
filename = FileList(k).name;
if (~any(filename == '.'))
X = dicomread([input, filename]);
out_filename = [filename, '.', 'jpg'];
imwrite(X, [outdir, out_filename]);
end
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 28 de En. de 2020
input = '/Users/brianngo/Desktop/CT-imaging/';
output = '/Users/brianngo/Desktop/CT-imaging-Jpeg/';
ext = '.png'
FileList = dir(filePattern);
filenames = {FileList.name};
filenames = filenames(cellfun(@isempty,strfind({filenames '.'))));
N = length(filenames);
for k = 1 : N
filename = filenames{k};
X = dicomread(fullfile(input, filename));
imwrite(X, fullfile(output, [filename ext]));
end
Note that if you do this, then you should not process the .jpg files for anything other than display to the user. The jpg compression process creates artifacts that make automated processing more difficult. We recommend that you use png instead of jpg if you are doing analysis.

Más respuestas (0)

Categorías

Más información sobre Medical Physics en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by