- OpenCV Computer Vision Application Programming Cookbook Second Edition
- Robert Laganière
- 366字
- 2021-04-02 10:05:55
Introduction
In order to build computer vision applications, you need to be able to access the image content and eventually modify or create images. This chapter will teach you how to manipulate the picture elements (also known as pixels). You will learn how to scan an image and process each of its pixels. You will also learn how to do this efficiently, since even images of modest dimensions can contain hundreds of thousands of pixels.
Fundamentally, an image is a matrix of numerical values. This is why, as we learned in Chapter 1, Playing with Images, OpenCV 2 manipulates them using the cv::Mat
data structure. Each element of the matrix represents one pixel. For a gray-level image (a black-and-white image), pixels are unsigned 8-bit values where 0
corresponds to black and 255
corresponds to white. In the case of color images, three primary color values are required in order to reproduce the different visible colors. This is a consequence of the fact that our human visual system is trichromatic; three types of cone cells on our retinae convey the color information to our brain. This means that for a color image, three values must be associated to each pixel. In photography and digital imaging, the commonly used primary color channels are red, green, and blue. A matrix element is, therefore, made of a triplet of 8-bit values in this case.
Note that even if 8-bit channels are generally sufficient, there are specialized applications where 16-bit channels are required (medical imaging, for example).
As we saw in the previous chapter, OpenCV also allows you to create matrices (or images) with pixel values of other types, for example, integer (CV_32U
or CV_32S
) and floating point (CV_32F
) numbers. These are very useful to store, for example, intermediate values in some image-processing tasks. Most operations can be applied on matrices of any type; others require a specific type or work only with a given number of channels. Therefore, a good understanding of a function's or method's preconditions is essential in order to avoid common programming errors.
Throughout this chapter, we use the following color image as the input (refer to the book's graphics PDF to view this image in color):

- Word排版技術大全(第2版)
- InDesign CS6中文版基礎與實例教程
- 游戲引擎原理與實踐·卷1:基礎框架
- Office 2013入門與提高
- 跟李銳學Excel數據分析
- Excel+PPT+Word+PS+短視頻剪輯+PDF+思維導圖+居家辦公+辦公設備9合1
- Access 2010數據庫實用教程
- Matlab R2016a從入門到精通 (CAX工程應用叢書)
- Excel數據透視表從入門到精通
- Excel數據可視化:從圖表到數據大屏
- 文秘辦公自動化培訓教程
- 如何高效辦公:Excel 2013經典應用技巧大全
- 做好PPT就靠這幾招:圖解力 吸引力 說服力(全彩圖解版)
- WOW!電腦辦公可以這樣簡單
- Office 2013應用技巧實例大全