0

I am trying the alpha blending with two images both have alpha channel in OpenCV.

double r, g, b, a; //source image colors
double Rd, Gd, Bd, Ad; //destination image colors

....

double result_r = r∗a + Rd*(1−a);
double result_g = g∗a + Gd*(1−a);
double result_b = b∗a + Bd*(1−a);
double result_a = a∗a + Ad*(1−a);

It works fine if the destination image is opaque. But I need transparent Images on both source and destination. Are there any other calculation methods or functions of OpenCV?

Regards

mag.
  • 144
  • 1
  • 7

1 Answers1

2

Look at the cvFunction addWeighted(). It performs what you need Here is the link

rafaoc
  • 586
  • 7
  • 21
  • Thanks for your reply! It seems that the `addWeighted()` function takes same alpha values for all pixels. Can I apply different alpha values owned by src1 and src2 for each pixels? – mag. Dec 05 '14 at 11:52
  • No, it is not possible with addWeighted(). You could initialize the mat element and use multiply(). But, if my previous answer works for your first question, mark it as an accepted answer – rafaoc Dec 08 '14 at 05:31