error on accessing images reading from sub folders.
    3 views (last 30 days)
  
       Show older comments
    
    sidra Rafique
 on 13 Sep 2018
  
    
    
    
    
    Commented: sidra Rafique
 on 13 Sep 2018
            Hi, i need to access jpg images from subfolders, for that i have read this and modify it according to my hierarchy. https://www.mathworks.com/matlabcentral/answers/266223-read-image-from-different-folders
after reading images i need to convert those images to gray. for that i have used this
    img_gray = rgb2gray(numberOfImageFiles);
at this line of code i am facing an error. which is given below:
Error using rgb2gray>parse_inputs (line 80)
MAP must be a m x 3 array.
Error in rgb2gray (line 52)
isRGB = parse_inputs(X);
Error in Untitled2 (line 34)
          img_gray = rgb2gray(numberOfImageFiles);
please help me in this. its just been a month i am using Matlab, still trying to learn it. waiting for your response. Thank You
0 Comments
Accepted Answer
  Guillaume
      
      
 on 13 Sep 2018
        
      Edited: Guillaume
      
      
 on 13 Sep 2018
  
      Assuming that numberOfImageFiles is indeed the number of image files, why are you passing that to rgb2gray which expects an image and doesn't care at all how many you have?
You need to pass the image that you've loaded with imread to rgb2gray.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!