How do I crop an image on a white background with python?
问题 I am scanning old photos, so I have the image and a white background from the scanner. My aim is to take the picture, removing the white background. How can I do that ? An example picture is the following: My simple approach: import os import time from PIL import Image from collections import Counter import numpy as np def get_cropped_image(image, crop_folder, threshold): image_name = image.split("\\")[-1] im = Image.open(image) pixels = im.load() width, height = im.size rows = [] for h_index