From b9eee98a25825692fa45599ae4ddd7060d5ae6d1 Mon Sep 17 00:00:00 2001 From: Theelgirl <43764914+Theelgirl@users.noreply.github.com> Date: Thu, 8 Oct 2020 14:45:08 +0000 Subject: [PATCH] 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! --- fvid/fvid.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fvid/fvid.py b/fvid/fvid.py index e0b93fc..f4d83ad 100644 --- a/fvid/fvid.py +++ b/fvid/fvid.py @@ -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