Stitching Photos together

前端 未结 5 674
长情又很酷
长情又很酷 2020-12-05 03:31

So for this project I\'m working on, I have 2 photos. These two photos need to be stitched together, one on the top and one on the bottom, and then you will be able to see t

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-05 03:53

    This is some code from Jan Erik Solems computer vision with python book; you can probably edit it to fit your top/bottom needs

    def stitchImages(im1,im2):
        '''Takes 2 PIL Images and returns a new image that 
        appends the two images side-by-side. '''
    
        # select the image with the fewest rows and fill in enough empty rows
        rows1 = im1.shape[0]    
        rows2 = im2.shape[0]
    
        if rows1 < rows2:
            im1 = concatenate((im1,zeros((rows2-rows1,im1.shape[1]))), axis=0)
        elif rows1 > rows2:
            im2 = concatenate((im2,zeros((rows1-rows2,im2.shape[1]))), axis=0)
        # if none of these cases they are equal, no filling needed.
    
        return concatenate((im1,im2), axis=1)
    

提交回复
热议问题