File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 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
44def 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
4849def 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-
You can’t perform that action at this time.
0 commit comments