|MATLAB File Help: cv.imread||Index|
Loads an image from a file
1: no scaling (default).
2: image scaled by 1/2 factor.
4: image scaled by 1/4 factor.
8: image scaled by 1/8 factor.
>0: Return a 3-channel color image. Note that in the current implementation the alpha channel, if any, is stripped from the output image. For example, a 4-channel RGBA image is loaded as RGB if
Flags >= 0.
=0: Return a grayscale image
<0: Return the loaded image as is (with alpha channel if present).
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:
*.jpe(see the Notes section)
*.jp2(see the Notes section)
*.png(see the Notes section)
*.webp(see the Notes section)
*.tif(see the Notes section)
*.exr(see the Notes section)
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
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 (http://www.gdal.org) will be used in order
to decode the image by supporting the following formats: