Removing borders from an image in Python

前端 未结 4 1004
孤城傲影
孤城傲影 2021-01-13 02:55

Some videos have frames that have black strips like borders. I have to remove them from the frames. I came up with a crude solution:

import sys, cv2, numpy
i         


        
4条回答
  •  忘掉有多难
    2021-01-13 03:33

    Why not calculate the frame and use PIL

    from PIL import Image
    
    img = Image.open('myImage.jpeg')
    box = (50, 50, 100, 100)
    area = img.crop(box)
    

提交回复
热议问题