You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to use multiply effect and I got this error
TypeError: The blend_modes function "multiply" received a numpy array with 3 layers for its argument "img_in". The function however expects a 4-layer array representing red, green, blue, and alpha channel for this argument. Please supply a numpy array that includes all 4 layers to the "img_in" argument.
here is my code :
# Import background image
background_img_float = cv2.imread('bg.jpg', -1).astype(float)
# Import foreground image
foreground_img_float = cv2.imread('personal.jpg', -1).astype(float)
# Blend images
opacity = 0.7 # The opacity of the foreground that is blended onto the background is 70 %.
blended_img_float = multiply(background_img_float, foreground_img_float, opacity)
# Display blended image
blended_img_uint8 = blended_img_float.astype(np.uint8) # Convert image to OpenCV native display format
cv2.imshow('window', blended_img_uint8)
cv2.waitKey() # Press a key to close window with the image.
The text was updated successfully, but these errors were encountered:
defadd_alpha_channel(image):
height, width=image.shape[:2]
# Create an alpha channel with full opacity for every pixelalpha_channel=np.ones((height, width, 1), dtype=image.dtype) *255returnnp.concatenate((image, alpha_channel), axis=-1)
background_img_float=add_alpha_channel(cv2.imread('bg.jpg', -1).astype(float))
I tried to use multiply effect and I got this error
here is my code :
The text was updated successfully, but these errors were encountered: