- Mastering OpenCV Android Application Programming
- Salil Kapur Nisarg Thakkar
- 320字
- 2021-07-16 13:36:47
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:

A grayscale (1-channel) image representation:
A more elaborate form of an image is the RGB representation, which is shown as follows:

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:


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.
- Java入門經(jīng)典(第6版)
- Delphi程序設(shè)計基礎(chǔ):教程、實驗、習題
- 區(qū)塊鏈架構(gòu)與實現(xiàn):Cosmos詳解
- Python Deep Learning
- 精通軟件性能測試與LoadRunner實戰(zhàn)(第2版)
- Mastering LibGDX Game Development
- Python自然語言處理(微課版)
- JavaScript 程序設(shè)計案例教程
- Learning Salesforce Einstein
- Elasticsearch Server(Third Edition)
- Oracle 18c 必須掌握的新特性:管理與實戰(zhàn)
- AIRIOT物聯(lián)網(wǎng)平臺開發(fā)框架應(yīng)用與實戰(zhàn)
- Mastering Akka
- 網(wǎng)絡(luò)數(shù)據(jù)采集技術(shù):Java網(wǎng)絡(luò)爬蟲實戰(zhàn)
- MySQL從入門到精通