filename = 'eQ9ts.jpg'
im = np.asarray(Image.open(filename))
gray = im.sum(axis=-1)
bw = gray > THRESHOLD
label, n = ndi.label(bw)
indices = [np.where(label == ind) for ind in range(1, n)]
slices = [([slice(ind[i].min(), ind[i].max()) for i in (0, 1)] + [slice(
    None)]) for ind in indices]
images = [im[s] for s in slices]
images = [im for im in images if not np.any(np.asarray(im.shape[:-1]) <
    MIN_SHAPE)]
Автообрезка изображений с помощью PIL