reading multiple images from a folder in Matlab
    9 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    yasmine
 el 7 de Nov. de 2011
  
    
    
    
    
    Comentada: Emily Leung
 el 18 de Jun. de 2021
            I want to read many images from a folder in the Matlab directory using imread() and then make different operations in every image individually , i wrote this code but it disagrees about (+k+):
num_file=1;  
file = dir('image.orig');
num_file = numel(file);
NF=num_file;
Y=1;Z=1;
images = cell(1,NF,T);
T=cell(Y,Z,3); 
for k = 1:NF
      images{1,k}(Y,Z,3) = imread('C:Work\image.orig\'+k-1+'.JPEG');
end
also, i want to save the matrix of each image in a cell array and i don't if what i wrote is right or not and i cannot have a permission to read from the folder, i checked the folder and found that it is read only, what do you think?
Thank you in advance
0 comentarios
Respuesta aceptada
  Walter Roberson
      
      
 el 7 de Nov. de 2011
        file = dir('image.orig');
NF = length(file);
images = cell(NF,1);
for k = 1 : NF
  images{k} = imread(fullfile('image.orig', file(k).name));
end
8 comentarios
  Walter Roberson
      
      
 el 10 de Nov. de 2011
				I would put a breakpoint in and check each step -- for example, does file come out empty?
Check to be sure that you have not accidentally created your own dir.m or imread files:
which -all dir
which -all imread
Más respuestas (4)
  Image Analyst
      
      
 el 8 de Nov. de 2011
        It's always worth throwing in a plug for the FAQ:  http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
0 comentarios
  yasmine
 el 8 de Dic. de 2011
        6 comentarios
  Walter Roberson
      
      
 el 9 de Dic. de 2011
				I think this should definitely have gone in its own thread ;-)
You are trying to apply imhist() to a (subsection of) a truecolor image (which is thus a 3D matrix). imhist() is only for grayscale images. You should convert your whole image to grayscale before you break it up in to blocks; or you should convert each block to grayscale and imhist that as you go; or you should imhist() each of the three color planes separately.
  Shaveta Arora
 el 9 de Abr. de 2016
        If I have .tiff images and .tif images that I want to read, how they can be read ? I know how to read one type of images but how to read two types of images.
4 comentarios
  Walter Roberson
      
      
 el 18 de Jun. de 2021
				@Emily LeungIn the code I posted here, the filenames would come up empty if you do not have any .tif or .tiff files in the current directory.
In some cases, depending upon operating system configuration, files ending with extension .TIF or .TIFF might not be treated as if they ended in .tif or .tiff -- sometimes files are case sensitive.
The code I posted is not designed to look for files in a different directory; the changes to look in a different directory are not difficult though.
  Emily Leung
 el 18 de Jun. de 2021
				@Walter Roberson i solved the issue, thank you very much this approach saved me many an if loop!
  Kumar Vaibhav
 el 1 de Ag. de 2016
        
      Editada: Walter Roberson
      
      
 el 1 de Ag. de 2016
  
       I=imread(sprintf('C:/Users/kumar.vaibhav/Documents/MATLAB/Visually Similar Images/%d.jpeg',i));
1 comentario
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





