Crop black edges with OpenCV

后端 未结 7 1517
遥遥无期
遥遥无期 2020-12-01 01:08

I think it should be a very simple problem, but I cannot find a solution or an effective keyword for search.

I just have this image.

7条回答
  •  我在风中等你
    2020-12-01 01:19

    I thought this answer is much more succinct:

    def crop(image):
        y_nonzero, x_nonzero, _ = np.nonzero(image)
        return image[np.min(y_nonzero):np.max(y_nonzero), np.min(x_nonzero):np.max(x_nonzero)]
    

提交回复
热议问题