mirror of https://github.com/AlfredoSequeida/fvid
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.
This commit is contained in:
parent
832effad59
commit
83084dc456
12
fvid/fvid.py
12
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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue