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

Performing simple image arithmetic

Images can be combined in different ways. Since they are regular matrices, they can be added, subtracted, multiplied, or divided. OpenCV offers various image arithmetic operators and their use is discussed in this recipe.

Getting ready

Let's work with a second image that we will combine to our input image using an arithmetic operator. The following represents the second image:

Getting ready

How to do it...

Here we add two images. This is useful when one wants to create some special effects or to overlay information over an image. We do this by calling the cv::add function, or more precisely here, the cv::addWeighted function since ...

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