Skip to content

Commit 5bf8fb6

Browse files
Fix comments in raw to 8bit bayer
1 parent a7daca4 commit 5bf8fb6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/labthings_picamera2/thing.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,19 @@ def raw_to_8bit_bayer(raw: np.ndarray, size: tuple[int, int]) -> np.ndarray:
192192
# raw_w is Raw data width in bytes which is:
193193
# pixel width * bits_per_pixel / bits_per_byte
194194
# This is calculated as below because the data is saved as:
195-
# [8-bit R pixel, 8-bit G pixel, 8-bit R pixel, 8-bit G pixel, extra bits]
195+
# For each red line
196+
# [8-bit R pixel, 8-bit G pixel, 8-bit R pixel, 8-bit G pixel, extra bits, ...]
197+
# For each blue line
198+
# [8-bit G pixel, 8-bit B pixel, 8-bit G pixel, 8-bit B pixel, extra bits, ...]
196199
# where the extra bits are the 2 bits for the previous 4 pixels
197200
raw_w = bayer8bit.shape[1] // 4 * 5
198-
# Red
201+
# First pixel in block of 5 bytes
199202
bayer8bit[:,::4] = raw[:, : raw_w : 5]
200-
# Green 1
203+
# 2nd pixel in block of 5 bytes
201204
bayer8bit[:,1::4] = raw[:, 1: raw_w+1 : 5]
202-
# Green 2
205+
# 3rd pixel in block of 5 bytes
203206
bayer8bit[:,2::4] = raw[:, 2: raw_w+2 : 5]
204-
# Blue
207+
# 4th pixel in block of 5 bytes
205208
bayer8bit[:,3::4] = raw[:, 3: raw_w+3 : 5]
206209
return bayer8bit
207210

0 commit comments

Comments
 (0)