From 1f77386ba34b5f9cc39e9592e582b773668bb3c1 Mon Sep 17 00:00:00 2001 From: CreepyMemes <61922260+CreepyMemes@users.noreply.github.com> Date: Wed, 25 Jan 2023 16:38:23 +0100 Subject: [PATCH] Update image_processing.py --- src/utils/image_processing.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/image_processing.py b/src/utils/image_processing.py index b2a51ae..3e1f7e7 100644 --- a/src/utils/image_processing.py +++ b/src/utils/image_processing.py @@ -1,8 +1,9 @@ -from PIL import Image +from PIL import Image, ImageEnhance -# Opens an image and converts to grayscale +# Opens an image, converts to grayscale and increases contrast def open_image(file): img = Image.open(file).convert('L') + img = ImageEnhance.Contrast(img).enhance(3) return img # Calculate height value to maintain the original aspect ratio @@ -40,7 +41,7 @@ def get_row_height_map(row, average): result = [] total = 0 for pixel in row: - total += pixel - average + total += pixel - average * 1.5 result.append(total) return [ pixel - total/2 for pixel in result ] @@ -48,4 +49,3 @@ def get_row_height_map(row, average): def get_height_map(pixels, cols, rows): average = get_average(pixels, cols, rows) return normalize( [ get_row_height_map(row, average) for row in pixels ] ) -