If you are trying to display OpenCV image using matplotlib, use the code below.

import numpy as np
import cv2
import matplotlib.pyplot as plt
%matplotlib inline  # if you are running this code in Jupyter notebook

# reads image 'opencv-logo.png' as grayscale
img = cv2.imread('/path_to_image/opencv-logo.png', 0) 
plt.imshow(img, cmap='gray')
Answer from An unfinished seeker on Stack Overflow
๐ŸŒ
LearnOpenCV
learnopencv.com โ€บ home โ€บ image processing โ€บ read, display and write an image using opencv
Read, Display and Write an Image using OpenCV - LearnOpenCV
July 31, 2026 - If you need to install OpenCV, please visit the relevant link below. ... We will use the following image to demonstrate all the functions here. Example input image we will use throughout this blog. First, go through this code example. It reads and displays the above image.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ opencv โ€บ opencv_reading_images.htm
OpenCV - Reading Images
import org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.imgcodecs.Imgcodecs; public class ReadingImages { public static void main(String args[]) { //Loading the OpenCV core library System.loadLibrary( Core.NATIVE_LIBRARY_NAME ); //Instantiating the Imagecodecs class Imgcodecs imageCodecs = new Imgcodecs(); //Reading the Image from the file String file ="C:/EXAMPLES/OpenCV/sample.jpg"; Mat matrix = imageCodecs.imread(file); System.out.println("Image Loaded"); } }
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ reading-image-opencv-using-python
Reading an image in OpenCV using Python - GeeksforGeeks
August 12, 2024 - Below codes are implementations to read images and display images on the screen using OpenCV and matplotlib libraries functions. Example #1 (Using OpenCV) :
๐ŸŒ
Medium
medium.com โ€บ analytics-vidhya โ€บ read-image-using-cv2-imread-opencv-python-idiot-developer-4b7401e76c20
Read Image using cv2.imread() โ€” OpenCV Python โ€” Idiot Developer | by Nikhil Tomar | Analytics Vidhya | Medium
January 23, 2024 - To use OpenCV in Python install the following libraries: ... To install the above libraries, use the following command. ... Here, we are going to import all the required libraries. ... To read an image cv2.imread() function is used.
๐ŸŒ
OpenCV
opencv.org โ€บ home โ€บ news โ€บ read, display and write an image using opencv
Read, Display and Write an Image using OpenCV
March 28, 2025 - The program will wait indefinitely for a key press (via waitKey(0)) before closing all image windows with destroyAllWindows(). This simple example shows how to handle different image formats and modes using OpenCV, providing flexibility for various image processing tasks. Vid4. Displaying all three formats of an image ... The third is again in color, as this was the original format of the image (which was read using IMREAD_UNCHANGED)
Find elsewhere
๐ŸŒ
OpenCV
docs.opencv.org โ€บ 4.13.0 โ€บ d4 โ€บ da8 โ€บ group__imgcodecs.html
OpenCV: Image file reading and writing
The imread function loads an image from the specified file and returns OpenCV matrix. If the image cannot be read (because of a missing file, improper permissions, or unsupported/invalid format), the function returns an empty matrix.
๐ŸŒ
LearnOpenCV
learnopencv.com โ€บ home โ€บ image processing โ€บ reading and writing videos using opencv
Reading and Writing Videos using OpenCV | LearnOpenCV
October 15, 2025 - Reading a video stream from a web camera is also very similar to the examples discussed above. Howโ€™s that possible? Itโ€™s all thanks to the flexibility of the video capture class in OpenCV, which has several overloaded functions for convenience that accept different input arguments.
๐ŸŒ
MachineLearningMastery
machinelearningmastery.com โ€บ home โ€บ blog โ€บ how to read and display videos using opencv
How to Read and Display Videos Using OpenCV - MachineLearningMastery.com
January 30, 2024 - We may include other lines of code inside the while loop to process every image frame after this has been grabbed by the capture.read() method. One example is to convert each BGR image frame into grayscale, for which we may use the same cvtColor ...
๐ŸŒ
OpenCV
docs.opencv.org โ€บ 4.13.0 โ€บ db โ€บ deb โ€บ tutorial_display_image.html
OpenCV: Getting Started with Images
As a first step, the OpenCV python library is imported. The proper way to do this is to additionally assign it the name cv, which is used in the following to reference the library. ... Now, let's analyze the main code. As a first step, we read the image "starry_night.jpg" from the OpenCV samples.
๐ŸŒ
LearnOpenCV
learnopencv.com โ€บ home โ€บ read, write and display a video using opencv
Read, Write and Display a video using OpenCV | LearnOpenCV
July 31, 2026 - A tutorial on how to read, write and display a video using OpenCV. OpenCV-Python and OpenCV-C++ Code is provided for practice and understanding.
๐ŸŒ
TutorialKart
tutorialkart.com โ€บ opencv โ€บ python โ€บ opencv-python-read-display-image
Read and Display an Image using OpenCV in Python
June 29, 2026 - import cv2 img = cv2.imread('/... not be read') else: print('Image shape:', img.shape) For a PNG image with transparency, the shape may show four channels. In OpenCV, these channels are usually Blue, Green, Red, and Alpha. You do not always need to pass an absolute path. If the image is in the same folder as your Python script, you can use a relative path. This keeps examples easier to ...
๐ŸŒ
LearnOpenCV
learnopencv.com โ€บ home โ€บ read an image in opencv ( python, c++ )
Read an Image in OpenCV ( Python, C++ ) | LearnOpenCV
October 23, 2025 - Satya Mallick Founder - Big Vision & LearnOpenCV Talk to our Team ยท A transparent image has four channels โ€” 3 for color, and one for transparency. These images can be read in OpenCV using the IMREAD_UNCHANGED flag.
๐ŸŒ
LabEx
labex.io โ€บ questions โ€บ how-to-read-an-image-using-opencv-8438
How to Read an Image in OpenCV | LabEx
June 8, 2026 - In this example, we first import the cv2 module, which provides the OpenCV functions and classes. We then use the cv2.imread() function to load the image from the specified file path and store it in the image variable.
๐ŸŒ
Medium
medium.com โ€บ @reddyyashu20 โ€บ chapter-1-read-images-video-webcam-opencv-a6e392c279c9
Chapter 1 โ€” Read Images Video Webcam(OpenCV) | by Yashwanth Reddy | Medium
April 1, 2023 - import cv2 frameWidth = 640 frameHeight = 480 cap = cv2.VideoCapture(0) cap.set(3, frameWidth) cap.set(4, frameHeight) cap.set(10, 150) while True: success, img = cap.read() cv2.imshow("Result", img) if cv2.waitKey(1) & 0xFF == ord('q'): break
๐ŸŒ
OpenCV
opencv.org โ€บ home โ€บ news โ€บ reading and writing videos using opencv
Reading and Writing Videos using OpenCV
March 28, 2025 - Reading Videos: OpenCVโ€™s VideoCapture() function allows us to read video files, capture frames from a webcam, or process image sequences as videos. Writing Videos: The VideoWriter() function enables saving processed frames into a new video ...
๐ŸŒ
Towards Data Science
towardsdatascience.com โ€บ home โ€บ data science โ€บ how to read images, video, webcam and screen in opencv - image analysis for beginners
How to read images, video, webcam and screen in OpenCV - image analysis for beginners | Towards Data Science
January 14, 2022 - Next we go about "filming" our screen. We can use this for analyzing the images we see on the screen (we'll get into this later). Lastly we'll start reading images from our webcam and from a video file. First we import OpenCV on line 1 (cv2 is OpenCV's module name in the Python implementation).