MATLAB File Help: cv.imread Index

Loads an image from a file

img = cv.imread(filename)
img = cv.imread(filename, 'OptionName',optionValue, ...)




The function cv.imread loads an image from the specified file and returns it. If the image cannot be read (because of missing file, improper permissions, unsupported or invalid format), the function issues an error.

Currently, the following file formats are supported:


The function determines the type of an image by the content, not by the file extension.

In the case of color images, the decoded images will have the channels stored in BGR order. If FlipChannels is set, the channels are flipped to RGB order.

On Microsoft Windows OS and MacOSX, the codecs shipped with an OpenCV image (libjpeg, libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs, and TIFFs. On MacOSX, there is also an option to use native MacOSX image readers. But beware that currently these native image loaders give images with different pixel values because of the color management embedded into MacOSX.

On Linux, BSD flavors and other Unix-like open-source operating systems, OpenCV looks for codecs supplied with an OS image. Install the relevant packages (do not forget the development files, for example, "libjpeg-dev", in Debian and Ubuntu) to get the codec support or turn on the OPENCV_BUILD_3RDPARTY_LIBS flag in CMake.

In the case you set WITH_GDAL flag to true in CMake and GDAL option to load the image, then GDAL driver ( will be used in order to decode the image by supporting the following formats: Raster (, Vector (

See also