DECIMER-Image-Segmentation icon indicating copy to clipboard operation
DECIMER-Image-Segmentation copied to clipboard

PIL.Imag.ANTIALIAS is outdated

Open UniquerWong opened this issue 3 months ago • 0 comments

In decimer_segmentation.py,thePIL.Imag.ANTIALIAS is outdated. You need to install an older version of Pillow. So the another solution is replaced with Image in newer Pillow versions PIL.Imag.LANCZOS. `from PIL import Image

def get_square_image(image, desired_size): old_size = image.size # old_size[0] is in (width, height) format ratio = float(desired_size) / max(old_size) new_size = tuple([int(x * ratio) for x in old_size]) # resize the image grayscale_image = image.resize(new_size, Image.ANTIALIAS) # 使用 Image.ANTIALIAS # create a new image and paste the resized on it new_image = Image.new("L", (desired_size, desired_size)) new_image.paste(grayscale_image, ((desired_size - new_size[0]) // 2, (desired_size - new_size[1]) // 2)) return new_image`

UniquerWong avatar Nov 26 '24 15:11 UniquerWong