Ask Your Question

Revision history [back]

My english is too bad to explain. Try :

import numpy as np
import cv2 as cv

# importing the main image
image = cv.imread("C:/Users/Laurent/Desktop/flower.jpg")
# importing the logo image
watermark = cv.imread("C:/Users/Laurent/Desktop/ydzJrDY.png")
(wH, wW) = watermark.shape[:2]
mask = watermark >0

img = cv.add(image[150:150+wH,200:200+wW],watermark,mask=mask[:,:,0].astype(np.uint8))
output = cv.addWeighted(image[150:150+wH,200:200+wW],1, img, 0.2,1)
image[150:150+wH,200:200+wW] = output
cv.imwrite("C:/Users/Laurent/Desktop/watermark.jpg",image)
cv.imshow("output", image)
cv.waitKey(0)
cv.destroyAllWindows()

image description

My english is too bad to explain. Try :

import numpy as np
import cv2 as cv

# importing the main image
image = cv.imread("C:/Users/Laurent/Desktop/flower.jpg")
# importing the logo image
watermark = cv.imread("C:/Users/Laurent/Desktop/ydzJrDY.png")
(wH, wW) = watermark.shape[:2]
mask = watermark >0

img = cv.add(image[150:150+wH,200:200+wW],watermark,mask=mask[:,:,0].astype(np.uint8))
output = cv.addWeighted(image[150:150+wH,200:200+wW],1, img, 0.2,1)
image[150:150+wH,200:200+wW] = output
cv.imwrite("C:/Users/Laurent/Desktop/watermark.jpg",image)
cv.imshow("output", image)
cv.waitKey(0)
cv.destroyAllWindows()

image description

and shadow is here :

image description

My english is too bad to explain. Try :

import numpy as np
import cv2 as cv
cv2

# importing the main image
image = cv.imread("C:/Users/Laurent/Desktop/flower.jpg")
cv2.imread("C:/Users/Laurent/Desktop/flower.jpg")
# importing the logo image
watermark = cv.imread("C:/Users/Laurent/Desktop/ydzJrDY.png")
cv2.imread("C:/Users/Laurent/Desktop/ydzJrDY.png",cv2.IMREAD_UNCHANGED)
(wH, wW) = watermark.shape[:2]
mask weight = watermark >0
1 - watermark[:,:,3] / 255  img image[150:150+wH,200:200+wW,0] = cv.add(image[150:150+wH,200:200+wW],watermark,mask=mask[:,:,0].astype(np.uint8))
np.multiply(image[150:150+wH,200:200+wW,0], weight).astype(np.uint8)
image[150:150+wH,200:200+wW,1] = np.multiply(image[150:150+wH,200:200+wW,1], weight).astype(np.uint8)
image[150:150+wH,200:200+wW,2] = np.multiply(image[150:150+wH,200:200+wW,2], weight).astype(np.uint8)
output = cv.addWeighted(image[150:150+wH,200:200+wW],1, img, 0.2,1)
cv2.addWeighted(image[150:150+wH,200:200+wW],1, watermark[:,:,0:3], 1,1)
image[150:150+wH,200:200+wW] = output
cv.imwrite("C:/Users/Laurent/Desktop/watermark.jpg",image)
cv.imshow("output", #cv2.copyTo(watermark[:,:,0:3],mask.astype(np.uint8),image[150:150+wH,200:200+wW])
cv2.imwrite("C:/Users/Laurent/Desktop/watermark.png",image)
cv2.imshow("output", image)
cv.waitKey(0)
cv.destroyAllWindows()
cv2.waitKey(0)
cv2.destroyAllWindows()

image descriptionimage description

and shadow is here :

image description