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.
Best Answer