Major optimization by removing calls to tuple()

This brought the time taken by get_bits_from_image from 6.35 seconds to 4.9 seconds on my processor!
This commit is contained in:
Theelgirl 2020-10-08 14:45:08 +00:00 committed by GitHub
parent 83084dc456
commit b9eee98a25
1 changed files with 2 additions and 2 deletions

View File

@ -66,9 +66,9 @@ def get_bits_from_image(image):
elif pixel == black:
pixel_bin_rep = "0"
else:
white_diff = tuple(np.absolute(np.subtract(white, pixel)))
white_diff = np.absolute(np.subtract(white, pixel))
# min_diff = white_diff
black_diff = tuple(np.absolute(np.subtract(black, pixel)))
black_diff = np.absolute(np.subtract(black, pixel))
# if the white difference is smaller, that means the pixel is closer
# to white, otherwise, the pixel must be black