Accessing pixels

Apart from using an ROI to access the pixels in a rectangular region of an image, as we did in the previous sections, there are a few other methods for achieving the same goal or even for accessing individual pixels of an image. To be able to access any single pixel in an image (in other words, a Mat object), you can use the at function, as seen in the following example:

image.at<TYPE>(R, C) 

In the preceding example, in the usage of the at function, TYPE must be replaced with a valid type name that is in accordance with the number of channels and depth of the image. R must be replaced with the row number, and C with the column number of the pixels we want to have access to. Notice that this is slightly different from the ...

Get Hands-On Algorithms for Computer Vision now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.