# i want to know how to implement blendlinear() function

i want to blend two images together, and i have used the addweighted and i understand how it works, but am trying to use the blendlinear function(to my own understanding it can be used to blend images) but i cant actually understand how to use it.

blendLinear (   InputArray  src1, // this are Mat images and should be the same size as the src2
InputArray  src2,
InputArray  weights1,
InputArray  weights2, // i don't actually understand this two
OutputArray     dst     // the destination image it should also bee the same size and type as src1
)

edit retag close merge delete

can you show, what you tried (code) ? it's unclear.

( 2019-01-17 08:05:07 -0500 )edit

am talking about the blendlinear() function, this is the explanation on the website

Performs linear blending of two images:

dst(i,j)=weights1(i,j)∗src1(i,j)+weights2(i,j)∗src2(i,j) Parameters src1 It has a type of CV_8UC(n) or CV_32FC(n), where n is a positive integer.

src2 It has the same type and size as src1.

weights1 It has a type of CV_32FC1 and the same size with src1.

weights2 It has a type of CV_32FC1 and the same size with src1.

dst It is created if it does not have the same size and type with src1.

( 2019-01-17 08:08:37 -0500 )edit
1

not sure, can you please explain "Weight per pixel " for me please..

( 2019-01-17 08:09:59 -0500 )edit

Sort by » oldest newest most voted

main difference between addWeighted() and blendLinear() is, that the former has a single blending factor for the whole image, and the latter has a weights per pixel Mat for each image.

do you have such a thing ?

as an example:

Mat_<uchar> m1(2,2);  // 1st "demo" image
m1 << 1,1,
1,1;

Mat_<uchar> m2(2,2);  // 2nd image
m2 << 3,3,
3,3;

Mat_<float> w1(2,2);  // weights
w1 << .2, .4,         // 0.2 * 1st_pixel, 0.4 * 2nd_pixel, etc.
.4, .2;

Mat w2 = 1.0f - w1;

Mat result;
blendLinear(m1, m2, w1, w2, result);

cout << result << endl;

[  3,   2;
2,   3]

more

( 2019-01-17 08:31:22 -0500 )edit
1

also see this (maybe related)

( 2019-01-17 10:05:58 -0500 )edit

Official site

GitHub

Wiki

Documentation