Load Image from Specified File using OpenCV

Load Image from Specified File using OpenCV

While working with image processing, one of the first steps is load an image from a file.

OpenCV provides imread function that enables to load an image from a file. This function supports various image formats such as PNG, JPEG, BMP, WebP, and other. Image format is identified by the content of an image, not by the filename extension. Function loads an image where the order of the color channels is Blue, Green, Red (BGR) instead of RGB.

Python
C++
Java
import cv2 img = cv2.imread('test.jpg') cv2.imshow('Image', img) cv2.waitKey(0) cv2.destroyAllWindows()

Leave a Comment

Cancel reply

Your email address will not be published.