From 83084dc4561001178b21d7ecd183bf3dcdcb0237 Mon Sep 17 00:00:00 2001 From: Theelgirl <43764914+Theelgirl@users.noreply.github.com> Date: Thu, 8 Oct 2020 13:59:24 +0000 Subject: [PATCH] Make pixel_bin_rep a string with literals That way we don't have to call str() on pixel_bin_rep when adding bits, as literal constructions are faster than function calls iirc. --- fvid/fvid.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fvid/fvid.py b/fvid/fvid.py index 84a1013..e0b93fc 100644 --- a/fvid/fvid.py +++ b/fvid/fvid.py @@ -58,13 +58,13 @@ def get_bits_from_image(image): pixel = px[x, y] - pixel_bin_rep = 0 + pixel_bin_rep = "0" # for exact matches if pixel == white: - pixel_bin_rep = 1 + pixel_bin_rep = "1" elif pixel == black: - pixel_bin_rep = 0 + pixel_bin_rep = "0" else: white_diff = tuple(np.absolute(np.subtract(white, pixel))) # min_diff = white_diff @@ -73,12 +73,12 @@ def get_bits_from_image(image): # if the white difference is smaller, that means the pixel is closer # to white, otherwise, the pixel must be black if np.less(white_diff, black_diff).all(): - pixel_bin_rep = 1 + pixel_bin_rep = "1" else: - pixel_bin_rep = 0 + pixel_bin_rep = "0" # adding bits - bits += str(pixel_bin_rep) + bits += pixel_bin_rep return (bits, done)