1. Home
  2. Docs
  3. Computer Vision
  4. Introduction to OpenCV
  5. Opening Image Files in a Noteook

Opening Image Files in a Noteook

Working with PIL

The pillow or PIL is a popular library for working with images in python. You could install via PIP package,

pip install pillow

Import the image module in PIL

from PIL import Image

Load the image and create a PIL image object

image_ = Image.open("my_image.jpg")

Plot the image using show() or matplotlib

image_.show(title="my_image.jpg")

Image shown outside of the notebook

import matplotlib.pyplot as plt
plt.imshow(image_)
Good to Know
  • The attribute format tells the extension or format of the image
  • The attribute size is the number of pixels that make up the width and height
  • The attribute mode is the color space
image.format
image.size #(represents a tuple width and height)
image.mode

Loading

Views: 4

Articles

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments