O'Reilly logo

Computer Vision with Python 3 by Saurabh Kapur

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reading an image

OpenCV has the imread() function to read an image. It takes the name of the file and returns the image matrix. The imshow() function can be used to display the image. The imshow() function takes the title and the image matrix as parameters. The following is an example of reading an image:

>>> import cv2>>> img = cv2.imread("image.jpg")>>> cv2.imshow("image",img)

The following figure is the output of the preceding code:       

Figure 1

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required