Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering OpenCV Android Application Programming

You're reading from   Mastering OpenCV Android Application Programming Master the art of implementing computer vision algorithms on Android platforms to build robust and efficient applications

Arrow left icon
Product type Paperback
Published in Jul 2015
Publisher
ISBN-13 9781783988204
Length 216 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Storing images in OpenCV

OpenCV stores images as a custom object called Mat. This object stores the information such as rows, columns, data, and so on that can be used to uniquely identify and recreate the image when required. Different images contain different amounts of data. For example, a colored image contains more data than a grayscale version of the same image. This is because a colored image is a 3-channel image when using the RGB model, and a grayscale image is a 1-channel image. The following figures show how 1-channel and multichannel (here, RGB) images are stored (these images are taken from docs.opencv.org).

A 1-channel representation of an image is shown as follows:

Storing images in OpenCV

A grayscale (1-channel) image representation:

A more elaborate form of an image is the RGB representation, which is shown as follows:

Storing images in OpenCV

A RGB (3-channel) image representation

In the grayscale image, the numbers represent the intensity of that particular color. They are represented on a scale of 0-255 when using integer representations, with 0 being pure black and 255 being pure white. If we use a floating point representation, the pixels are represented on a scale of 0-1, with 0 being pure black and 1 being pure white. In an RGB image in OpenCV, the first channel corresponds to blue color, second channel corresponds to green color, and the third channel corresponds to red color. Thus, each channel represents the intensity of any particular color. As we know that red, green, and blue are primary colors, they can be combined in different proportions to generate any color visible to the human eye. The following figure shows the different colors and their respective RGB equivalents in an integer format:

Storing images in OpenCV
Storing images in OpenCV

Now that we have seen how an image is represented in computing terms, we will see how we can modify the pixel values so that they need less computation time when using them for the actual task at hand.

You have been reading a chapter from
Mastering OpenCV Android Application Programming
Published in: Jul 2015
Publisher:
ISBN-13: 9781783988204
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image