Попробуйте Обрезать черные края с помощью OpenCV
import numpy as np
import cv2
img = cv2.imread('./data/q18.png')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
#play with parameters that all I changed in answer
_,thresh = cv2.threshold(gray,20,255,cv2.THRESH_BINARY)
# and here are 3 value returned not 2
_,contours,_ = cv2.findContours(thresh,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
cnt = contours[0]
x,y,w,h = cv2.boundingRect(cnt)
crop = img[y:y+h,x:x+w]
cv2.imwrite('./data/q18_1.png',crop)
Вывод: