Im trying to load a image file into a ndarray with something like this:
image_data = ndimage.imread(image_file).astype(float)
/home/milos/anaconda3/envs/tensorflow/lib/python3.5/site-packages/scipy/ndimage/io.py in imread(fname, flatten, mode)
23 if _have_pil:
24 return _imread(fname, flatten, mode)
---> 25 raise ImportError("Could not import the Python Imaging Library (PIL)"
26 " required to load image files. Please refer to"
27 " http://pypi.python.org/pypi/PIL/ for installation"
ImportError: Could not import the Python Imaging Library (PIL) required to load image files. Please refer to http://pypi.python.org/pypi/PIL/ for installation instructions.
Managed to do it in the end by bypassing scipy :
from PIL import Image img = Image.open(image_file) image_data = np.array(img).astype(float)
would still like to know what the problem is with scipy, so please post if you know it
Found a better solution:
import matplotlib.pyplot as plt import matplotlib.image as mpimg image_data = mpimg.imread(image_file)
this creates a numpy ndarray and normalizes the pixel depths to 0-1, and it worked nicely if i wanted to do a backwards conversion to check if its still good: