Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i read image using PILLOW image?

I wanted read a image using PIL.Image.open().But I've image in different path. The following is the path I've the python script

"D:\YY_Aadhi\holy-edge-master\hed\test.py"

The following is the path I've the image file.

"D:\YY_Aadhi\HED-BSDS\test\2018.jpg"

from PIL import Image
'''some code here'''
image = Image.open(????)

How should I fill the question mark to access the image file.

like image 218
Thiruvettai Athithiyan S Avatar asked May 07 '26 10:05

Thiruvettai Athithiyan S


1 Answers

you can simply do

from PIL import Image
image = Image.open("D:\\YY_Aadhi\\HED-BSDS\\test\\2018.jpg")

or

from PIL import Image
directory = "D:\\YY_Aadhi\\HED-BSDS\\test\\2018.jpg"
image = Image.open(directory)

like this.

you have to write escape sequence twice in windows, when you want to define as directory. and It will be great if you try some stupid code. It helps you a lot.

like image 185
SaGwa Avatar answered May 08 '26 23:05

SaGwa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!