2

I have already searched the answer in python. But I don't know how to convert it into C#

Python code: (copy from [overlay a smaller image on a larger image python OpenCv)

import cv2
s_img = cv2.imread("smaller_image.png")
l_img = cv2.imread("larger_image.jpg")
x_offset=y_offset=50
l_img[y_offset:y_offset+s_img.shape[0],x_offset:x_offset+s_img.shape[1]] = s_img

//alpha channel

s_img = cv2.imread("smaller_image.png", -1)
for c in range(0,3):
l_img[y_offset:y_offset+s_img.shape[0], 
x_offset:x_offset+s_img.shape[1], c] =  s_img[:,:,c] * (s_img[:,:,3]/255.0) +  l_img[y_offset:y_offset+s_img.shape[0], x_offset:x_offset+s_img.shape[1], c] * (1.0 - s_img[:,:,3]/255.0)
stevec
  • 31
  • 1

0 Answers0