@@ -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