Removing borders from an image in Python

前端 未结 4 986
孤城傲影
孤城傲影 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:28

    I think that you will find that the problem goes away if you work from the other side of the image, as you are checking the first column (col[0] - it's black so you delete it and the black col[1] becomes col[0] then you check the col[1] - skipping the new col[0]....

    If you start from the max it would work or if you stay on any given col once you have deleted it. Alternatively you can make a list of which to delete, reverse it and then do the deletions.

提交回复
热议问题