Reader small image

You're reading from  Computer Vision with OpenCV 3 and Qt5

Product typeBook
Published inJan 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781788472395
Edition1st Edition
Languages
Right arrow
Author (1)
Amin Ahmadi Tazehkandi
Amin Ahmadi Tazehkandi
author image
Amin Ahmadi Tazehkandi

Amin Ahmadi Tazehkandi is an Iranian author, developer, and a computer vision expert.Amin Ahmadi Tazehkandi is an Iranian author, developer, and a computer vision expert. He completed his computer software engineering studies in Iran and has worked for numerous software and industrial companies around the world.
Read more about Amin Ahmadi Tazehkandi

Right arrow

Reading images using OpenCV


Now that we learned all about the Mat class in OpenCV, we can move on to learn to read images and fill a Mat class with an image to further process it. As you have seen briefly in the previous chapters, the imread function can be used to read images from the disk. Here's an example:

    Mat image = imread("c:/dev/test.jpg", IMREAD_GRAYSCALE | 
      IMREAD_IGNORE_ORIENTATION); 

imread simply takes a C++ std::string class as the first parameter and an ImreadModes flag as the second parameter. If for any reason the image cannot be read, then it returns an empty Mat class (data == NULL), otherwise, it returns a Mat class filled with the image pixels with the type and color specified in the second parameter. Depending on the availability of some image types in the platform, imread can read the following image types:

  • Windows bitmaps: \*.bmp, \*.dib
  • JPEG files: \*.jpeg, \*.jpg, \*.jpe
  • JPEG 2000 files: \*.jp2
  • Portable Network Graphics: \*.png
  • WebP: \*.webp
  • Portable image format...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Computer Vision with OpenCV 3 and Qt5
Published in: Jan 2018Publisher: PacktISBN-13: 9781788472395

Author (1)

author image
Amin Ahmadi Tazehkandi

Amin Ahmadi Tazehkandi is an Iranian author, developer, and a computer vision expert.Amin Ahmadi Tazehkandi is an Iranian author, developer, and a computer vision expert. He completed his computer software engineering studies in Iran and has worked for numerous software and industrial companies around the world.
Read more about Amin Ahmadi Tazehkandi