Search code examples
python-2.7opencvoverlaytransparencyalpha-transparency

Colour intensity while Overlaying images in OPEN CV Python


Solution of the following code I am writing this code which overlays two images with black circles (on white background). The problem is when I write this code, the solution overlays these two circles at respective positions but the colours of the circles fade away a little. Please can you help me write a script which adds both circles but the resulting picture shows both circles as they originally are and not faded?

import cv2
import numpy as np
import matplotlib.pyplot as plt


img1 = cv2.imread('16.bmp') 
img2 = cv2.imread('17.bmp')

img = cv2.addWeighted(img1,0.5,img2,0.5,0)

plt.imshow(img,cmap="gray")
plt.colorbar()
plt.show()

Solution

  • Why don't you just go with:

    img=cv2.min(img1,img2)

    Link: https://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#min