O'Reilly logo

OpenCV 2 Computer Vision Application Programming Cookbook by Robert Laganière

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Scanning an image with pointers

In most image processing tasks, one needs to scan all pixels of the image in order to perform a computation. Considering the large number of pixels that will need to be visited, it is essential to perform this task in an efficient way. This recipe, and the next one, will show you different ways of implementing an image scanning loop. This recipe uses pointer arithmetic.

Getting ready

We will illustrate the image scanning process by accomplishing a simple task: reducing the number of colors in an image.

Color images are composed of 3-channel pixels. Each of these channels corresponds to the intensity value of one of the three primary colors (red, green, blue). Since each of these values is an 8-bit unsigned char, the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required