Reputation: 2606
I have two image like this:
I create two mask, which show me position of each image on scene.
I create mask which show me intersection of two images.
I create intersection mask with
cv::bitwise_and(mask_left, mask_right, mask_intersection);
I want adding two images together. Where pixels of mask_intersection
is white, I want use average value of pixels on both images. Here is result, where I just add one image on another. The problem is sharp border, which I want to solve with averaging of both images only on mask_intersection
.
I don't know how to solve this problem the easiest way.
Upvotes: 1
Views: 337
Reputation: 4542
For averaging the two images where the mask intersect, you could use copyTo
.
Supposing you have maskIntersection
, image1
, image2
and finalImage
, the code would look something like:
((image1 + image2) * 0.5).copyTo(finalImage, maskIntersection)
Even though this answers your question of averaging the two images, I don't think it will provide very good results. Blending two images together is usually a more involved process. Take a look at this class to have a quick overview of what is required.
Upvotes: 2