How to crop an image in OpenCV using Python

后端 未结 9 2098
面向向阳花
面向向阳花 2020-11-22 08:45

How can I crop images, like I\'ve done before in PIL, using OpenCV.

Working example on PIL

im = Image.open(\'0.png\').convert(\'L\')
im = im.crop((1         


        
9条回答
  •  伪装坚强ぢ
    2020-11-22 09:04

    to make it easier for you here is the code that i use :

    w, h = image.shape
    top=10
    right=50
    down=15
    left=80
    croped_image = image[top:((w-down)+top), right:((h-left)+right)]
    plt.imshow(croped_image, cmap="gray")
    plt.show()
    

提交回复
热议问题