<< cvtColor | Input output | imwrite >>

scicv >> Input output > imread

# imread

Loads an image

### Syntax

    img = imread(filename[, flags])

### Parameters

filename

  Path of file to be loaded (`string`).

flags

  Flag specifying the color type of the loaded image (`int`):

  - `CV_LOAD_IMAGE_ANYDEPTH`: return a 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
  - `CV_LOAD_IMAGE_COLOR`: convert to a color image.
  - `CV_LOAD_IMAGE_GRAYSCALE`: convert to a grayscale image.
img

  Loaded image (Mat).

### Description

`imread` loads an image from the specified file path and returns the Mat object containing it.

### Examples

    scicv_Init();

    img = imread(getSampleImage("lena.jpg"));

    matplot(img);

    delete_Mat(img);

    scicv_Init();

    img_gray = imread(getSampleImage("lena.jpg"), CV_LOAD_IMAGE_GRAYSCALE);

    matplot(img_gray);

    delete_Mat(img_gray);

### See also

- imwrite
- Mat

Report an issue
<< cvtColor | Input output | imwrite >>