用python的opencv怎么拼接两张图片?

图片说明

如图想把图片1和图片2拼接起来变成图片3应该怎么写代码

最简单的代码即可
比如image3 = def function(image1,image2)

主要是这个def function怎么写

 def function(image1,image2):
    h1,w1,c1 = image1.shape
    h2,w2,c2 = image2.shape
    if c1 != c2:
        print("channels NOT match, cannot merge")
        return 
    else:
        if w1 > w2:
            tmp = np.zeros([h2,w1-w2,c1])
            image3 = np.hstack([image2,tmp])
            image3 = np.vstack([image1,image3])
        elif w1 == w2:
            image3 = np.vstack([image1,image2])
        else:
            tmp = np.zeros([h1,w2-w1,c2])
            image3 = np.hstack([image1,tmp])
            image3 = np.vstack([image3,image2])
    return image3

https://www.cnblogs.com/ToBeDeveloper-Zhen/p/9314760.html