diff --git a/fonts/scientifica.ttf b/fonts/scientifica.ttf new file mode 100644 index 0000000..1753d31 Binary files /dev/null and b/fonts/scientifica.ttf differ diff --git a/sobel.py b/sobel.py index 32b2c5d..871f000 100644 --- a/sobel.py +++ b/sobel.py @@ -7,10 +7,11 @@ import os from PIL import Image, ImageFilter import pygame as pg -IMAGE_PATH = 'sample-images/engine.PNG' +IMAGE_PATH = 'sample-images/sunflower.jpg' +FONT_PATH = 'fonts/scientifica.ttf' BLUR_STRENGTH_1 = 1 -BLUR_STRENGTH_2 = 2.5 +BLUR_STRENGTH_2 = 1.2 DOG_THRESHOLD = 8 @@ -31,7 +32,7 @@ if not os.path.exists('./debug/') and DEBUG: os.makedirs('./debug') # '█@?OPoci. ' -CHARS = [ +CHARS = list(reversed([ u'█', '@', '?', @@ -42,7 +43,7 @@ CHARS = [ 'i', '.', ' ' -] +])) def main(): @@ -81,7 +82,7 @@ def main(): text_grind_height = h / SCALED_HEIGHT pg.init() - font = pg.font.SysFont("Monocraft Medium", 12) + font = pg.font.Font(FONT_PATH, 12) window = pg.display.set_mode((text_grid_width * TEXT_WIDTH, text_grind_height * TEXT_HEIGHT)) y_offset = 0 @@ -127,7 +128,7 @@ def main(): score = histogram[char] most_common = char - rendered_char = font.render(most_common, 1, color_avg) + rendered_char = font.render(str(most_common), True, color_avg) window.blit(rendered_char, (x * TEXT_WIDTH, y * TEXT_HEIGHT)) x_offset += SCALED_WIDTH @@ -144,7 +145,7 @@ def main(): # Draw only the ASCII edges pg.init() - font = pg.font.SysFont("Monocraft Medium", 12) + font = pg.font.Font(FONT_PATH, 12) window = pg.display.set_mode((text_grid_width * TEXT_WIDTH, text_grind_height * TEXT_HEIGHT)) y_offset = 0 @@ -190,7 +191,7 @@ def main(): score = histogram[char] most_common = char - rendered_char = font.render(most_common, 1, color_avg) + rendered_char = font.render(most_common, True, color_avg) window.blit(rendered_char, (x * TEXT_WIDTH, y * TEXT_HEIGHT)) x_offset += SCALED_WIDTH @@ -202,7 +203,7 @@ def main(): pg.quit() - + def subtract_colors(t1: tuple, t2: tuple) -> tuple: