aboutsummaryrefslogtreecommitdiff
path: root/decoder.py
diff options
context:
space:
mode:
authorAnthony Wang2024-04-22 23:48:42 -0400
committerAnthony Wang2024-04-22 23:48:42 -0400
commit67f14d072ec892fc5aaa20a043e479289f31613e (patch)
tree2ed0a38b9944b8f8231a332756f2d3efb6ecbf89 /decoder.py
parent51548066f6660ef944afcd6876bf268e385d95c5 (diff)
Encoder: 4bit color, space out RS chunks
Diffstat (limited to 'decoder.py')
-rw-r--r--decoder.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/decoder.py b/decoder.py
index f9829d5..860d585 100644
--- a/decoder.py
+++ b/decoder.py
@@ -73,7 +73,12 @@ while data is None:
u = queue.popleft()
for d in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
v = (u[0] + d[0], u[1] + d[1])
- if 0 <= v[0] < X and 0 <= v[1] < Y and not vis[v] and np.linalg.norm(raw_frame[v] - raw_frame[s]) < 125:
+ if (
+ 0 <= v[0] < X
+ and 0 <= v[1] < Y
+ and not vis[v]
+ and np.linalg.norm(raw_frame[v] - raw_frame[s]) < 125
+ ):
vis[v] = True
pos += np.array(v)
col += raw_frame[v]
@@ -132,7 +137,9 @@ while data is None:
raw_color_frame = raw_frame[np.round(xp).astype(np.int64), np.round(yp).astype(np.int64), :]
# color_frame = raw_color_frame.astype(np.uint8)
color_frame = np.clip(np.squeeze(F @ (raw_color_frame - origin)[..., np.newaxis]), 0, 255).astype(np.uint8)
- frame = (color_frame[:, :, 0] >> 5) + (color_frame[:, :, 1] >> 2 & 0b00111000) + (color_frame[:, :, 2] & 0b11000000)
+ frame = (
+ (color_frame[:, :, 0] >> 5) + (color_frame[:, :, 1] >> 2 & 0b00111000) + (color_frame[:, :, 2] & 0b11000000)
+ )
frame_data = np.concatenate(
(
frame[:cheight, cwidth : args.width - cwidth].flatten(),