Ask Your Question
1

i want to know how to implement blendlinear() function

asked 2019-01-17 08:03:28 -0600

Allaye gravatar image

updated 2019-01-17 08:06:09 -0600

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 flag offensive close merge delete

Comments

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

berak gravatar imageberak ( 2019-01-17 08:05:07 -0600 )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.

Allaye gravatar imageAllaye ( 2019-01-17 08:08:37 -0600 )edit
1

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

Allaye gravatar imageAllaye ( 2019-01-17 08:09:59 -0600 )edit

1 answer

Sort by » oldest newest most voted
3

answered 2019-01-17 08:08:43 -0600

berak gravatar image

updated 2019-01-17 08:22:54 -0600

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]
edit flag offensive delete link more

Comments

no please, thanks

Allaye gravatar imageAllaye ( 2019-01-17 08:31:22 -0600 )edit
1

also see this (maybe related)

sturkmen gravatar imagesturkmen ( 2019-01-17 10:05:58 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-01-17 08:03:28 -0600

Seen: 857 times

Last updated: Jan 17 '19