OpenCV
3.1.0
Open Source Computer Vision
|
In this tutorial you will learn:
From our previous tutorial, we know already a bit of Pixel operators. An interesting dyadic (two-input) operator is the linear blend operator:
\[g(x) = (1 - \alpha)f_{0}(x) + \alpha f_{1}(x)\]
By varying \(\alpha\) from \(0 \rightarrow 1\) this operator can be used to perform a temporal cross-dissolve between two images or videos, as seen in slide shows and film productions (cool, eh?)
As usual, after the not-so-lengthy explanation, let's go to the code:
Since we are going to perform:
\[g(x) = (1 - \alpha)f_{0}(x) + \alpha f_{1}(x)\]
We need two source images ( \(f_{0}(x)\) and \(f_{1}(x)\)). So, we load them in the usual way:
warning
Since we are adding src1 and src2, they both have to be of the same size (width and height) and type.
g(x)
image. For this, the function add_weighted:addWeighted comes quite handy: \[dst = \alpha \cdot src1 + \beta \cdot src2 + \gamma\]
In this case,gamma
is the argument \(0.0\) in the code above.