## 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 this second image:

### How to do it...

Here, we add two images. This is useful when we want 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 we want a weighted sum as follows:

cv::addWeighted(image1,0.7,image2,0.9,0.,result);

The operation results in a new image, as seen in the following screenshot:

### How it works...

All binary arithmetic functions work the same way. Two inputs are provided and a third parameter specifies the output. In some cases, weights that are used as scalar multipliers...