Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

blending two color images


I have two color images (each in a cv::Mat of the same dimensions and type) and I wish to blend them into a third.

I am more-or-less successful using addWeighted but it seems like each of my source images gets "darker" during the process.

Below is an example of three images (these are not my images or even context, but the blended version of "C" from "A" & "B" represents exactly what I am going after)

image description

I assume I have to specify an "alpha" value of <1 to determine blending level, but if I do something like this (where a,b,c refer to the sample image tiles) addWeighted(a, 0.5, b, 0.5, 0.0, c)

I end up with "C" that blends "A" and "B" but it's as if the overall intensity of both A and B were reduced in the process. This example I've posted here seems to retain full intensity.

So what would be the proper way, using OpenCV, to take A and B and make C?