0

I am working with mammogram images. I have 3 folders with each folder consisting of 40 images. I want to read images from each folders so that I can extract features from each of the image and store them in a variable.

I don't know as how can I read images from multiple folders. It would be really helpful if anyone can help me with this.

martineau
  • 119,623
  • 25
  • 170
  • 301
Rohan Gupta
  • 35
  • 1
  • 4

2 Answers2

3

Use os.walk to recursively traverse a directory, and PIL to handle images.

import os
from PIL import Image

for path, _, files in os.walk('.')
    for file in files:
        foo = Image.open(file) 
        # now do something with the image
cs95
  • 379,657
  • 97
  • 704
  • 746
0

Hope This can be helpful

Browse files and subfolders in Python

http://pythoncentral.io/how-to-traverse-a-directory-tree-in-python-guide-to-os-walk/

RaTh0D
  • 323
  • 3
  • 19