Skip to content

Commit 1f77386

Browse files
authored
Update image_processing.py
1 parent 99deee1 commit 1f77386

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/utils/image_processing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
from PIL import Image
1+
from PIL import Image, ImageEnhance
22

3-
# Opens an image and converts to grayscale
3+
# Opens an image, converts to grayscale and increases contrast
44
def open_image(file):
55
img = Image.open(file).convert('L')
6+
img = ImageEnhance.Contrast(img).enhance(3)
67
return img
78

89
# Calculate height value to maintain the original aspect ratio
@@ -40,12 +41,11 @@ def get_row_height_map(row, average):
4041
result = []
4142
total = 0
4243
for pixel in row:
43-
total += pixel - average
44+
total += pixel - average * 1.5
4445
result.append(total)
4546
return [ pixel - total/2 for pixel in result ]
4647

4748
# Converts a whole image into a height map
4849
def get_height_map(pixels, cols, rows):
4950
average = get_average(pixels, cols, rows)
5051
return normalize( [ get_row_height_map(row, average) for row in pixels ] )
51-

0 commit comments

Comments
 (0)