Hello I need MATLAB help
    4 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
dicomread to load the images but I am not sure how to go about loading the files from a folder. If anyone can help I would greatly appreciate it!
0 Commenti
Risposte (2)
  Jan
      
      
 il 1 Nov 2021
        1 Commento
  Walter Roberson
      
      
 il 1 Nov 2021
				This is a duplicate question with the topic under active discussion at https://www.mathworks.com/matlabcentral/answers/1576073-convert-500-dicom-files-into-one-txt-file-in-matlab#comment_1811433 
  Image Analyst
      
      
 il 4 Nov 2021
        % Specify the folder where the files live.
myFolder = pwd;  %'C:\Users\yourUserName\Documents\My Pictures';
% Check to make sure that folder actually exists.  Warn user if it doesn't.
if ~isfolder(myFolder)
    errorMessage = sprintf('Error: The following folder does not exist:\n%s\nPlease specify a new folder.', myFolder);
    uiwait(warndlg(errorMessage));
    myFolder = uigetdir(); % Ask for a new one.
    if myFolder == 0
        % User clicked Cancel
        return;
    end
end
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.dcm'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1 : length(theFiles)
    baseFileName = theFiles(k).name;
    fullFileName = fullfile(theFiles(k).folder, baseFileName);
    fprintf(1, 'Now reading %s\n', fullFileName);
    % Now do whatever you want with this file name,
    % such as reading it in as an image array with imread()
    imageArray = dicomread(fullFileName);
    imshow(imageArray, []);  % Display image.
    drawnow; % Force display to update immediately.
end
0 Commenti
Vedere anche
Categorie
				Scopri di più su Environment and Settings in Help Center e File Exchange
			
	Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



