De-resolution of Dicom Image

5 views (last 30 days)
Ducs
Ducs on 25 Oct 2019
Answered: Bjorn Gustavsson on 25 Oct 2019
Beginner to Matlab with radiology background
I am going to decrease the resolution for butch of DICOM image (40,000 MRI images ) from around 500(or 600) squre to 128 square and save them into the new folder and subfolder in same arrangement.
I have tried butch image processing addon, but it seems pretty dumb for saving output.
I know that imresize() can change the resolution, but I want save output dicom images in the folder and subfolders with the same name and arrangement.
could anyone help me generate some code
Read folder and subfolder with dicom file -> use imresize to chage the resolution to 128x128 -> save output dicom image in the same name and save them in the new created folder and subfolder with the same name

Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 25 Oct 2019
So you problem is that you cannot figure out how to save a file to a new same-name file in another directory?
If so something like this should be the pattern:
Dicomfiles = dir('*.dcm');
New_dir = 'Dir4newsmallimages';
mkdir(New_dir);
for iFile = 1:numel()
X = dicomread(Dicomfiles(iFile).name);
INFO = dicominfo(Dicomfiles(iFile).name);
% and whatever you need from the file
Xout = improcessing(X); % or whatever you need to do with the image
INFO = metadatafixing(INFO); % You might have to modify the meta-data to match Xout
outname = fullfile(New_dir,Dicomfiles(iFile).name)
dicomwrite(Xout, outname, INFO);
end
HTH

Categories

Find more on DICOM Format in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!