import PIL.Image as pilimg
import numpy as np

# Read image
im = pilimg.open("../dataset/start.jpg")

# Display image

# Fetch image pixel data to numpy array
pix = np.array(im)

Project directory

(I’m no the author of the dataset, so I couldn’t upload the whole project file.)

I’m trying to read the image with Pillow and convert it to NumPy array. However, I tried several methods such as using absolute path and methods in PIL image.open() working for some images but not others except method using OpenCV. However, it makes FileNotFound always.

The absolute path of start.jpg is F:GIST 강의 자료2021 1학기EC3202 신호 및 시스템Programming Assignmentdatasetstart.jpg. and I believe the relative path to start.jpg from src/program.py is ../dataset/start.jpg.

I’m using conda 4.10.1 and python 3.8.8 and windows 10.